Proposal for a design for signed kernel/modules/etc

Warner Losh imp at bsdimp.com
Sun Apr 9 16:50:38 UTC 2017


On Sun, Apr 9, 2017 at 10:01 AM, Eric McCorkle <eric at metricspace.net> wrote:
> On 04/09/2017 11:52, Edward Tomasz Napierała wrote:
>> On 0409T1040, Eric McCorkle wrote:
>>> On 04/08/2017 07:52, Edward Tomasz Napierała wrote:
>>>> On 0408T0803, Eric McCorkle wrote:
>>>>> On 04/08/2017 07:11, Edward Tomasz Napierała wrote:
>>>>>> On 0327T1354, Eric McCorkle wrote:
>>>>>>> Hello everyone,
>>>>>>>
>>>>>>> The following is a design proposal for signed kernel and kernel module
>>>>>>> loading, both at boot- and runtime (with the possibility open for signed
>>>>>>> executables and libraries if someone wanted to go that route).  I'm
>>>>>>> interested in feedback on the idea before I start actually writing code
>>>>>>> for it.
>>>>>>
>>>>>> I see two potential problems with this.
>>>>>>
>>>>>> First, our current loader(8) depends heavily on Forth code.  By making
>>>>>> it load modified 4th files, you can do absolutely anything you want;
>>>>>> AFAIK they have unrestricted access to hardware.  So you should preferably
>>>>>> be able to sign them as well.  You _might_ (not sure on this one) also
>>>>>> want to be able to restrict access to some of the loader configuration
>>>>>> variables.
>>>>>
>>>>> Loader is handled by the UEFI secure boot framework, though the concerns
>>>>> about the 4th code are still valid.  In a secure system, you'd want to
>>>>> do something about that, but the concerns are different enough (and it's
>>>>> isolated enough) that it could be done separately.
>>>>
>>>> Unless the way to address those ends up being a signature mechanism
>>>> that doesn't depend on the format of the files being signed.
>>>
>>> I explored the idea of wrapped or detached signatures in the previous
>>> discussion.  Envelopes or detached signatures could make sense for the
>>> 4th files.  It's a small, obscure set of code that probably isn't
>>> changed very often.
>>>
>>> Envelopes or detached signatures for kernel modules and especially
>>> signed executables and libraries both have extensive, far-reaching
>>> consequences for system administration, packaging, tooling, the ports
>>> collection, and so on, whereas signing the executable with an additional
>>> section has no such consequences.
>>>
>>> Config files (and the 4th files really are more like config files) have
>>> a different set of constraints, and detached signatures are probably the
>>> way to go there.  So loader should probably support detached PKCS#7
>>> signature checks.
>>
>> The third way that might be worth considering would be to just append
>> the signature.  This would work for both 4th (if you prepend it with
>> whatever is the 4th comment character) and ELF, without the need for
>> changing or extending either format.
>
> No, that won't work at all.  That's going to break the tooling for ELF
> files as well as applications that use them, and it won't work for any
> configuration file aside from loader.4th  It wouldn't even work for
> boot.conf, for example.
>
> More generally, that's basing an entire standard off a dead language
> that's used in only one place, and in a way the precludes compatibility
> with any file format that uses a different comment character.  It also
> mandates some kind of ASCII encoding scheme to avoid newlines.

You don't need to avoid new lines with 4th. It doesn't even need to be
an ASCII encoding scheme, unless you are doing something crazy like
trying to push the signature through the 4th parser, which is nuts.
Forth can read binary files just fine. But I think arguing over the
4th stuff is a distraction, dee below.

> If I was going to adopt a solution that broke existing tooling, I'd at
> least go with a proper envelope scheme.

That would be preferable.

But why the either-or dichotomy? Seems like you're looking at the
problem wrong if you are arguing about 4th code. You should be
thinking more in terms of, at most, a couple of 4th words that can
implement this stuff (so the loader could show that the kernel is
signed and valid vs is not signed vs is signed, but the signature is
bogus). 99% of the functionality should be in C, and should be
sharable between the loader, the kernel and whatever else may wish to
verify signatures before loading. It would also allow the same
functionality to be pushed into the on-again-off-again LUA boot
project (which seems to have momentum this time).

Warner


More information about the freebsd-security mailing list