From: David Howells <dhowells@redhat.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: James Bottomley <James.Bottomley@hansenpartnership.com>,
Josh Boyer <jwboyer@fedoraproject.org>,
Jason Cooper <jason@lakedaemon.net>,
"ksummit-discuss@lists.linuxfoundation.org"
<ksummit-discuss@lists.linuxfoundation.org>,
Mark Brown <broonie@sirena.org.uk>
Subject: Re: [Ksummit-discuss] [TOPIC] Secure/verified boot and roots of trust
Date: Wed, 03 Aug 2016 11:43:50 +0100 [thread overview]
Message-ID: <27174.1470221030@warthog.procyon.org.uk> (raw)
In-Reply-To: <CALCETrXTusbj3vTQ=DmyiYG-ZqYOtHXD6rQpY-4+qtqsKmoD4g@mail.gmail.com>
Andy Lutomirski <luto@amacapital.net> wrote:
> I got module hashing working. It ended up being fairly
> straightforward.
It's not particularly difficult to use a flat hash table (assuming that's what
you've done), however, it's redundant, less efficient when not being used and
makes the build process more complicated.
To elaborate:
(1) We have to keep the module signing by keys stuff in the kernel along with
a supply of keys for it to use *anyway*. Yes, we might then be able to
drop the build-time transient key, but that doesn't account for very much
image space or memory.
(2) The x86_64 Fedora RPMs for the kernel running on my desktop right now
contain 8783 modules. Assuming we have a SHA256 hash for each of those
(to keep UEFI compatibility), that's 274KiB - assuming you have just a
simple contiguous array of hashes with no metadata of any sort.
Add to this approx 1135 firmware binaries for another 35KiB of space.
Assuming you bake this into the kernel image, that increases both the
image size and the memory usage by more than a quarter of a Meg - and,
due to the nature of the data, it cannot be compressed.
[Note that using signatures on modules and firmware blobs does also
require at least this much space on the *medium*, but it's (i)
distributed and (ii) may in some cases get lost in the fs block size,
and the amount you require inside the initrd image is automatically kept
small.]
Now, you can alleviate this in various ways:
(a) You could demand-load the entire table as one lump and have a single
hash in the kernel to cover the table. This means (i) having some
mechanism to do the loading before any modules or firmware is loaded,
and (ii) getting the table into the initrd/initramfs image.
(b) You could split the table up, but then the kernel needs a hash for
each segment. You could have a hash-of-table-hashes that the kernel
loads (and would also need a hash for), but this means demand-loading
still, and now the mechanism is getting more complicated.
If you did do this, you could split the table up mechanically, but
then mkinitrd would have to be able to work out which hash segments
in needs to load a particular module/firmware blob (it could do this
by hashing the blob and then scanning the tables for a match, then
selecting that table).
Or you could try and anticipate at build time what modules the
initial boot process would need and split the table that way.
(c) You could bake in just the module/firmware hashes that you think the
boot process might need and then discard those and load the full
table
(3) If someone adds or updates a firmware blob, you can't simply add a new
hash to the table without rebuilding your kernel. So you need to fall
back to using a key-based signature for this.
(4) Unless you want to implement demand loading of the table, you can't
discard it, which means it eats resources. If you demand load each time
you load a module and then discard after, that's much less efficient than
key checking.
You could alleviate this by not discarding the table during boot, but
only initiate discarding at the end of the boot process since most of the
module loading is done by that point.
(5) The build process gets more complicated. You can't do the hashing
procedure until after the builder has had a chance to strip the modules.
You then *have* to rebuild/alter the kernel image after the hashing
procedure has completed, whether you bake in one monolithic hash table or
demand load it.
It's easier to do the signing procedure as the kernel image doesn't need
to be modified.
I don't see a compelling argument for why we'd want to do module hashing at
all, given that we have to have the signature checking mechanism around anyway
for various reasons.
Firmware hashing might be a bit simpler since then you don't need a bunch of
detached signatures installing along with the firmware.
David
next prev parent reply other threads:[~2016-08-03 10:43 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-03 2:58 Andy Lutomirski
2016-08-03 3:24 ` Kees Cook
2016-08-03 3:32 ` Matthew Garrett
2016-08-03 4:34 ` Andy Lutomirski
2016-08-03 4:42 ` Michael S. Tsirkin
2016-08-03 4:46 ` Andy Lutomirski
2016-08-03 5:15 ` Matthew Garrett
2016-08-03 8:33 ` Alexandre Belloni
2016-08-03 10:31 ` Mark Brown
2016-08-03 10:43 ` David Howells [this message]
2016-08-03 16:46 ` Andy Lutomirski
2016-08-03 17:17 ` Matthew Garrett
2016-08-03 17:23 ` Andy Lutomirski
2016-08-03 17:26 ` Matthew Garrett
2016-08-03 17:28 ` Andy Lutomirski
2016-08-03 18:00 ` Michael S. Tsirkin
2016-08-03 23:01 ` Ben Hutchings
2016-08-03 23:22 ` Andy Lutomirski
2016-08-04 5:26 ` Kees Cook
2016-08-17 11:38 ` Ben Hutchings
2016-08-17 13:03 ` Mimi Zohar
2016-08-17 16:11 ` Ben Hutchings
2016-08-18 12:28 ` Mimi Zohar
2016-08-03 12:42 ` James Bottomley
2016-08-03 17:04 ` Andy Lutomirski
2016-08-03 17:23 ` Matthew Garrett
2016-08-03 17:29 ` Andy Lutomirski
2016-08-03 22:09 ` James Bottomley
[not found] ` <CALCETrVpCnfOJ2aXkNsOXatQAF6NG-AcJpxeYfA9wG_t2ocykg@mail.gmail.com>
[not found] ` <CALCETrWgS0XObzxfQWQbyntVEn6QF81K2TVbS4bGNyN6EcYb_A@mail.gmail.com>
2016-08-03 22:39 ` Andy Lutomirski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=27174.1470221030@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=broonie@sirena.org.uk \
--cc=jason@lakedaemon.net \
--cc=jwboyer@fedoraproject.org \
--cc=ksummit-discuss@lists.linuxfoundation.org \
--cc=luto@amacapital.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox