From: Ard Biesheuvel <ardb@kernel.org>
To: linux-efi@vger.kernel.org
Cc: Ard Biesheuvel <ardb@kernel.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
"Jason A . Donenfeld" <Jason@zx2c4.com>,
Lennart Poettering <lennart@poettering.net>
Subject: [PATCH v3 0/3] efi: consume random seed provided by loader
Date: Thu, 20 Oct 2022 10:39:07 +0200 [thread overview]
Message-ID: <20221020083910.1902009-1-ardb@kernel.org> (raw)
Getting a random seed into the kernel very early is important for data
structures that rely on the random number generator at initialization
time, but hardware based RNGs may not become available until much later
in the boot.
For this reason, the EFI stub will currently invoke the EFI RNG protocol
to get a random seed from the hardware before tearing down the EFI boot
services and performing the low level boot of the kernel proper. The
generated seed is passed via a EFI configuration table, which is
available very early, and so the random number generator comes up much
earlier as well.
Any boot stage preceding the EFI stub can install configuration tables,
so we can decide to expose the same mechanism to other loaders. This
allows, e.g., systemd-boot to pass the seed it keeps in a file on the
ESP without having to rely on PID #1 dd'ing it into /dev/random, which
is much too late to be useful.
For maximum simplicity, just concatenate the existing seed with the one
obtained from EFI_RNG_PROTOCOL if both are available, and leave it to
the core kernel code to mix it in and credit it appropriately. This way,
we have no need for copies of the Blake2s library in the EFI stub and in
the zboot decompressor.
Older kernels will simply supersede the bootloader provided seed, unless
the RNG protocol is not available, in which case the bootloader seed
will be forwarded untouched if one is present. This should not be an
issue, but let's reduce the seed size to blake2's output size, and
switch to the correct memory type in separate changes so they can be
backported.
Changes since v2:
- rebase onto v6.1-rc1
- drop blake2s library from the stub - we'd need it in two places with
the zboot changes landed, and concatenation is fine for our needs
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: Lennart Poettering <lennart@poettering.net>
Ard Biesheuvel (3):
efi: random: reduce seed size to 32 bytes
efi: random: Use 'ACPI reclaim' memory for random seed
efi: random: combine bootloader provided RNG seed with RNG protocol
output
drivers/firmware/efi/efi.c | 2 +-
drivers/firmware/efi/libstub/efistub.h | 2 ++
drivers/firmware/efi/libstub/random.c | 31 +++++++++++++++++---
include/linux/efi.h | 4 +--
4 files changed, 31 insertions(+), 8 deletions(-)
--
2.35.1
next reply other threads:[~2022-10-20 8:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-20 8:39 Ard Biesheuvel [this message]
2022-10-20 8:39 ` [PATCH v3 1/3] efi: random: reduce seed size to 32 bytes Ard Biesheuvel
2022-10-21 8:38 ` Ilias Apalodimas
2022-10-20 8:39 ` [PATCH v3 2/3] efi: random: Use 'ACPI reclaim' memory for random seed Ard Biesheuvel
2022-10-21 8:37 ` Ilias Apalodimas
2022-10-20 8:39 ` [PATCH v3 3/3] efi: random: combine bootloader provided RNG seed with RNG protocol output Ard Biesheuvel
2022-10-20 16:56 ` Jason A. Donenfeld
2022-10-20 17:11 ` Ard Biesheuvel
2022-10-20 17:22 ` Jason A. Donenfeld
2022-10-20 16:37 ` [PATCH v3 0/3] efi: consume random seed provided by loader Jason A. Donenfeld
2022-10-20 17:06 ` Ard Biesheuvel
2022-10-20 17:16 ` Jason A. Donenfeld
2022-10-20 17:27 ` Ard Biesheuvel
2022-10-20 17:35 ` Jason A. Donenfeld
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=20221020083910.1902009-1-ardb@kernel.org \
--to=ardb@kernel.org \
--cc=Jason@zx2c4.com \
--cc=ilias.apalodimas@linaro.org \
--cc=lennart@poettering.net \
--cc=linux-efi@vger.kernel.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