Re: [kernel-hardening] [PATCH v7 0/9] x86/mm: memory area address KASLR

From: Jason Cooper
Date: Thu Jun 23 2016 - 16:16:17 EST


Hey Sandy,

On Thu, Jun 23, 2016 at 03:45:54PM -0400, Sandy Harris wrote:
> Jason Cooper <jason@xxxxxxxxxxxxxx> wrote:
>
> > Modern systems that receive a seed from the bootloader via the
> > random-seed property (typically from the hw-rng) can mix both sources
> > for increased resilience.
> >
> > Unfortunately, I'm not very familiar with the internals of x86
> > bootstrapping. Could GRUB be scripted to do a similar task? How would
> > the address and size of the seed be passed to the kernel? command line?
>
> One suggestion is at:
> http://www.av8n.com/computer/htm/secure-random.htm#sec-boot-image

Yes, this is very similar to the latent_entropy series that I think Kees
just merged. Well, at a high level, it is. 'store a seed in the
kernel, use it at reboot'.

These approaches are good in that they provide yet another source of
entropy to the kernel. However, both suffer from the kernel binary
being very static in time and across distro installs. Particularly with
embedded systems. It almost becomes a long term secret. Which, the
longer it lives, the less chance there is of it being secret.

I'm not really comfortable with what John suggests, here:

"""
Next step: It should be straightforward to write a tool that efficiently
updates the stored seed within the boot image. Updating MUST occur
during provisioning, before the device gets booted for the first time
... and also from time to time thereafter. Updating the boot image isnât
be quite as simple as dd of=/var/lib/urandom/random-seed but neither is
it rocket surgery. The cost is utterly negligible compared to the cost
of a security breach, which is the relevant comparison.
"""

Editing the installed kernel binary to add the seed is exposing the
system to unnecessary risk of bricking the system (e.g. powerfail
halfway through) [0]. Yes, this can be mitigated by following a similar
process to kernel updates, but why? The bootloader already knows how to
read a file into RAM. We just need to put it in the right place and
tell it to do so. And userspace already writes a new random-seed during
system init and clean shutdown.

We just need to connect the dots so deployed systems can use the seed
earlier without having to hack the kernel or update the bootloader.
Which, while possible, a lot of folks are skittish to do.

thx,

Jason.

[0] I imagine it also borks code-signing...