linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Should we automatically generate a module signing key at all?
@ 2015-05-21 23:54 George Spelvin
  2015-05-22  0:03 ` Linus Torvalds
  2015-05-22  0:03 ` Andy Lutomirski
  0 siblings, 2 replies; 63+ messages in thread
From: George Spelvin @ 2015-05-21 23:54 UTC (permalink / raw)
  To: luto
  Cc: dhowells, dwmw2, linux, linux-kernel, linux-security-module,
	petkan, torvalds, tytso, zohar

> 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.

Nice system.  For an easier-to-visualize description (omitting some of
the details Andy includes here to avoid security problems), think of a
depth-k binary tree with 2^k modules (padded with zero-length dummies)
at the leaves.  Each internal node is a hash of its two child hashes,
and the root hash is baked into the kernel.

To prove a module is a member of the hash tree, you need to walk the
path to the root, combining the two child hashes at each step.

So each module includes the k sibling hashes needed to trace a path to
the root.  You hash the module, then combine it with its stored depth-k
sibling hash to compute the depth-k-1 hash.  Then combine that with the
stored depth-k-1 sibling hash, and so on.

If any of the hashes are wrong (most importantly, the module hash itself),
the root hash won't match and the kernel will refuse to load the module.

It takes n log n space for n modules, which is completely reasonable.

The annoying thing is that it's a two-pass process: the kernel has to
have the hashes of ALL of the modules to generate the sibling hashes
for ANY of them.

Or, and this is the biggest change to the kernel build process, the kernel
image itself.  No longer can you build the kernel image before building
modules.


To address other use cases, it's possible to allow multiple authentication
systems.  You can generate one big tree for in-tree modules, then either
additional trees or the existing public-key signatures for additions.


Andy, an easier indexing scheme might use, instead the depth
and index separately, the implicit heap numbering.  The root is
node 1, its children are 2 and 3, their children are 4 through 7, etc.

The modules are numbered 2^k through 2^(k+1)-1.

It's the same information, but slightly easier to keep track of.

^ permalink raw reply	[flat|nested] 63+ messages in thread
* Should we automatically generate a module signing key at all?
@ 2015-05-18 16:04 David Howells
  2015-05-18 16:19 ` David Woodhouse
  2015-05-18 16:20 ` Linus Torvalds
  0 siblings, 2 replies; 63+ messages in thread
From: David Howells @ 2015-05-18 16:04 UTC (permalink / raw)
  To: mmarek, dwmw2
  Cc: dhowells, Linus Torvalds, Abelardo Ricart III,
	Linux Kernel Mailing List, Sedat Dilek, keyrings, Rusty Russell,
	LSM List

Hi Michal, Dave,

Should we automatically generate a module signing key at all since that has
the possibility of accidentally overwriting a key that the builder has placed
in the tree?

Should we instead provide a script:

	./scripts/generate-key

That generates a key if run and make it so that the build fails if you turn on
module signing and there's no key.

The script could then be parameterised, eg:

	./scripts/generate-key -n dhowells@redhat.com -k rsa2048 -d sha256 \
		-o ./my-signing-key.priv -x ./my-signing-key.x509 \
		-p "correct horse battery staple"

Yes, this might throw randconfig into a strop but that can be dealt with by:

 (1) Requiring anyone who runs randconfig to provide a key first just in case.

 (2) Marking the CONFIG_MODULE_SIG_ALL option to be ignored by randconfig - it
     only applies during installation anyway.

 (3) Accept that module *installation* will fail due to a lack of private key
     and just handle a complete lack of X.509 certs in the source and build
     dirs when assembling system_certificates.S.

David

^ permalink raw reply	[flat|nested] 63+ messages in thread

end of thread, other threads:[~2015-06-23 20:38 UTC | newest]

Thread overview: 63+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-21 23:54 Should we automatically generate a module signing key at all? 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
  -- strict thread matches above, loose matches on Subject: below --
2015-05-18 16:04 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
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

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).