linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@amacapital.net>
To: David Howells <dhowells@redhat.com>
Cc: David Woodhouse <dwmw2@infradead.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andy Lutomirski <luto@kernel.org>, Michal Marek <mmarek@suse.cz>,
	Abelardo Ricart III <aricart@memnix.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Sedat Dilek <sedat.dilek@gmail.com>,
	keyrings@linux-nfs.org, Rusty Russell <rusty@rustcorp.com.au>,
	LSM List <linux-security-module@vger.kernel.org>,
	Borislav Petkov <bp@alien8.de>, Jiri Kosina <jkosina@suse.cz>
Subject: Re: Should we automatically generate a module signing key at all?
Date: Tue, 19 May 2015 12:01:11 -0700	[thread overview]
Message-ID: <CALCETrWjygX_SsQxD25wfG9ttY=DjuZrDRPrhcLawOpgCXYY4A@mail.gmail.com> (raw)
In-Reply-To: <5348.1432061085@warthog.procyon.org.uk>

On Tue, May 19, 2015 at 11:50 AM, David Howells <dhowells@redhat.com> wrote:
> Andy Lutomirski <luto@amacapital.net> wrote:
>
>> No, in the hash tree variant, it really is 32 bytes.  No one ever
>> needs the full list once the build is done.
>
> Yes, you do.  You have to check the hash on the hash list or you can't trust
> it.
>

No, you don't :)  See below.

On Tue, May 19, 2015 at 11:44 AM, David Howells <dhowells@redhat.com> wrote:
> Andy Lutomirski <luto@amacapital.net> wrote:
>
>> The actual runtime code needed to implement a hash tree solution is
>> maybe twenty lines.  The bzImage will be smaller,
>
> But the initramfs image will be bigger because it will have to carry the
> entire module hash list just in case any particular module needs to get loaded
> from the initramfs.  You have to carry the entire hash set so that you can
> hash it and compare against the one hash in the vmlinux file.
>

No.  Here's one way it could work:

Suppose you have a depth-k tree (i.e. up to 2^k modules).  We'll
compute a 32-byte value Tree(d, i) for each d from 0 to k and each i
from 0 to 2^d-1.  First you assign each module an index starting at
zero (with the maximum index less than 2^k).  Then you hash each
module.

To generate the leaves (i.e. nodes at depth k), you compute, for each
i, Tree(k, i) = H(k, i, H(module payload)).  For leaves that don't
correspond to modules, you use some placeholder.

For the ith node at lower depth, compute Tree(d, i) = H(k-1, i,
Tree(d+1, 2*i), Tree(d+1, 2*i+1)).

The proof associated with module i is Tree(k, i^1), Tree(k-1,
(i>>1)^1), Tree(k-2, (i>>2)^1), etc, up through depth 1.  Tree(0, 0)
is built into the kernel.

Variants of this scheme are possible.  Don't emulate Amazon or
Bittorrent here, though -- they both managed to screw up the crypto.

> And that doesn't include the issue of hashing the firmware blobs you might
> need.

As before, that's true.  To verify firmware, either you need to hash
it, use a termporary signing key, or use a long-term signing key.
Choose your poison.  I still prefer a hash over a temporary signing
key.

>
>> With your proposal, I need to trust that whoever built the actual
>> running kernel image really did throw away the key.  If they didn't,
>> then under whatever threat model requires that I enable module
>> verification, I'm screwed -- the bad guy has the private key.
>
> Each private key is used for one single kernel, so if they steal one, you can
> blacklist it if you have the capability (eg. UEFI) and change your kernel.
>

How do you know it was stolen?

--Andy

  reply	other threads:[~2015-05-19 19:01 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18 16:04 Should we automatically generate a module signing key at all? David Howells
2015-05-18 16:19 ` David Woodhouse
2015-05-18 16:22   ` Linus Torvalds
2015-05-18 16:55     ` David Woodhouse
2015-05-18 16:20 ` Linus Torvalds
2015-05-19  0:51   ` Andy Lutomirski
2015-05-19  7:42     ` David Woodhouse
2015-05-19 17:44     ` Linus Torvalds
2015-05-19 17:58       ` Andy Lutomirski
2015-05-19 18:01         ` Linus Torvalds
2015-05-19 18:08         ` David Woodhouse
2015-05-19 18:12           ` Andy Lutomirski
2015-05-19 18:38             ` David Woodhouse
2015-05-19 18:49               ` Andy Lutomirski
2015-05-19 20:00                 ` David Woodhouse
2015-05-19 20:05                   ` Andy Lutomirski
2015-05-19 20:25                     ` David Woodhouse
2015-05-19 18:44           ` David Howells
2015-05-19 19:01             ` Andy Lutomirski [this message]
2015-05-21 16:10             ` David Howells
2015-05-21 16:50               ` Andy Lutomirski
2015-06-23 20:37       ` Pavel Machek
2015-05-20  5:01     ` Rusty Russell
2015-05-19  8:53   ` David Howells
2015-05-19 12:46     ` David Woodhouse
2015-05-19 12:52     ` David Howells
2015-05-19 14:36     ` Andy Lutomirski
2015-05-19 15:37       ` Mimi Zohar
2015-05-19 15:53         ` Petko Manolov
2015-05-19 17:17         ` Andy Lutomirski
2015-05-19 15:30     ` David Howells
2015-05-19 15:55       ` Theodore Ts'o
2015-05-19 16:09         ` Petko Manolov
2015-05-19 17:32         ` Mimi Zohar
2015-05-19 17:43           ` Andy Lutomirski
2015-05-19 17:53             ` Linus Torvalds
2015-05-19 16:23       ` David Howells
2015-05-19 17:55         ` Theodore Ts'o
2015-05-19 18:10         ` David Howells
2015-05-19 21:47         ` Jiri Kosina
2015-05-20  7:45           ` Michal Marek
2015-05-20  7:47         ` Michal Marek
2015-05-19 17:17       ` Andy Lutomirski
2015-05-19 18:38       ` David Howells
2015-05-19 18:46         ` Andy Lutomirski
2015-05-19 18:50         ` David Howells
2015-05-19 18:57         ` David Howells
2015-05-19 19:06           ` Andy Lutomirski
2015-05-21 15:59           ` David Howells
2015-05-21 23:54 George Spelvin
2015-05-22  0:03 ` Linus Torvalds
2015-05-22  0:10   ` Andy Lutomirski
2015-05-22 14:13   ` George Spelvin
2015-05-22 20:40     ` Linus Torvalds
2015-05-22 20:44       ` Andy Lutomirski
2015-05-22 21:09         ` Linus Torvalds
2015-05-22 22:18         ` David Howells
2015-05-22 22:21           ` Linus Torvalds
2015-05-22 22:15     ` David Howells
2015-05-22 22:19       ` Andy Lutomirski
2015-05-22 22:21       ` David Howells
2015-05-22  0:03 ` Andy Lutomirski
2015-05-22 12:42   ` George Spelvin

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='CALCETrWjygX_SsQxD25wfG9ttY=DjuZrDRPrhcLawOpgCXYY4A@mail.gmail.com' \
    --to=luto@amacapital.net \
    --cc=aricart@memnix.com \
    --cc=bp@alien8.de \
    --cc=dhowells@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=jkosina@suse.cz \
    --cc=keyrings@linux-nfs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mmarek@suse.cz \
    --cc=rusty@rustcorp.com.au \
    --cc=sedat.dilek@gmail.com \
    --cc=torvalds@linux-foundation.org \
    /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;
as well as URLs for NNTP newsgroup(s).