efi_loader: Get rid of kaslr-seed if EFI_RNG_PROTOCOL is installed
authorIlias Apalodimas <ilias.apalodimas@linaro.org>
Mon, 3 Jan 2022 12:07:37 +0000 (14:07 +0200)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sat, 15 Jan 2022 09:57:22 +0000 (10:57 +0100)
commita2f1482fc0e6c5dbdbafecd360d168f9c12fc529
treebf78235b627bc129aa589287daa5f4a7e85e9f93
parentbc314f8e5f9b646e5ed09ccee2a2ddb012519305
efi_loader: Get rid of kaslr-seed if EFI_RNG_PROTOCOL is installed

U-Boot, in some occasions, injects a 'kaslr-seed' property on the /chosen
node. That would be problematic in case we want to measure the DTB we
install in the configuration table, since it would change across reboots.

The Linux kernel EFI-stub completely ignores it and only relies on
EFI_RNG_PROTOCOL for it's own randomness needs (i.e the randomization
of the physical placement of the kernel). In fact it (blindly) overwrites
the existing seed if the protocol is installed. However it still uses it
for randomizing it's virtual placement.
So let's get rid of it in the presence of the RNG protocol.

It's worth noting that TPMs also provide an RNG.  So if we tweak our
EFI_RNG_PROTOCOL slightly and install the protocol when a TPM device
is present the 'kaslr-seed' property will always be removed, allowing
us to reliably measure our DTB.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
cmd/bootefi.c
include/efi_loader.h
lib/efi_loader/efi_dt_fixup.c