Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: stable@vger.kernel.org, Ard Biesheuvel <ardb@kernel.org>
Subject: Re: [PATCH stable] efi: random: combine bootloader provided RNG seed with RNG protocol output
Date: Tue, 10 Jan 2023 17:56:41 +0100	[thread overview]
Message-ID: <Y72YyXw5HcsbDac1@kroah.com> (raw)
In-Reply-To: <20230110160416.2590-1-Jason@zx2c4.com>

On Tue, Jan 10, 2023 at 05:04:16PM +0100, Jason A. Donenfeld wrote:
> From: Ard Biesheuvel <ardb@kernel.org>
> 
> commit 196dff2712ca5a2e651977bb2fe6b05474111a83 upstream.
> 
> Instead of blindly creating the EFI random seed configuration table if
> the RNG protocol is implemented and works, check whether such a EFI
> configuration table was provided by an earlier boot stage and if so,
> concatenate the existing and the new seeds, leaving it up to the core
> code to mix it in and credit it the way it sees fit.
> 
> This can be used for, e.g., systemd-boot, to pass an additional seed to
> Linux in a way that can be consumed by the kernel very early. In that
> case, the following definitions should be used to pass the seed to the
> EFI stub:
> 
> struct linux_efi_random_seed {
>       u32     size; // of the 'seed' array in bytes
>       u8      seed[];
> };
> 
> The memory for the struct must be allocated as EFI_ACPI_RECLAIM_MEMORY
> pool memory, and the address of the struct in memory should be installed
> as a EFI configuration table using the following GUID:
> 
> LINUX_EFI_RANDOM_SEED_TABLE_GUID        1ce1e5bc-7ceb-42f2-81e5-8aadf180f57b
> 
> Note that doing so is safe even on kernels that were built without this
> patch applied, but the seed will simply be overwritten with a seed
> derived from the EFI RNG protocol, if available. The recommended seed
> size is 32 bytes, and seeds larger than 512 bytes are considered
> corrupted and ignored entirely.
> 
> In order to preserve forward secrecy, seeds from previous bootloaders
> are memzero'd out, and in order to preserve memory, those older seeds
> are also freed from memory. Freeing from memory without first memzeroing
> is not safe to do, as it's possible that nothing else will ever
> overwrite those pages used by EFI.
> 
> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
> [ardb: incorporate Jason's followup changes to extend the maximum seed
>        size on the consumer end, memzero() it and drop a needless printk]
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
> ---
>  drivers/firmware/efi/efi.c             |  4 +--
>  drivers/firmware/efi/libstub/efistub.h |  2 ++
>  drivers/firmware/efi/libstub/random.c  | 42 ++++++++++++++++++++++----
>  include/linux/efi.h                    |  2 --
>  4 files changed, 40 insertions(+), 10 deletions(-)

Now queued up, thanks.

greg k-h

  reply	other threads:[~2023-01-10 16:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 16:04 [PATCH stable] efi: random: combine bootloader provided RNG seed with RNG protocol output Jason A. Donenfeld
2023-01-10 16:56 ` Greg KH [this message]
2023-01-10 16:57   ` Jason A. Donenfeld
2023-01-10 17:09     ` Greg KH
2023-01-10 17:10       ` Jason A. Donenfeld
2023-01-10 17:20         ` Ard Biesheuvel
2023-01-10 17:32           ` Jason A. Donenfeld
2023-01-10 17:37             ` Ard Biesheuvel
2023-01-10 19:44       ` Jason A. Donenfeld
2023-01-10 19:45         ` [PATCH stable 5.4.y] " Jason A. Donenfeld
2023-01-12 12:29           ` Greg KH
2023-01-12 12:31             ` Ard Biesheuvel
2023-01-12 13:02               ` Greg KH
2023-01-11  8:44         ` [PATCH stable] " Ard Biesheuvel
2023-01-11  9:01           ` Greg KH
2023-01-11 12:25           ` 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=Y72YyXw5HcsbDac1@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=Jason@zx2c4.com \
    --cc=ardb@kernel.org \
    --cc=stable@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