linux-stable/include
Ard Biesheuvel df201eb96a efi: random: combine bootloader provided RNG seed with RNG protocol output
commit 196dff2712 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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-01-12 12:00:48 +01:00
..
acpi ACPI: APEI: Fix integer overflow in ghes_estatus_pool_init() 2022-11-10 18:17:24 +01:00
asm-generic mm/khugepaged: fix GUP-fast interaction by sending IPI 2022-12-14 11:40:50 +01:00
clocksource - Add the missing DT bindings for the MTU nomadik timer (Linus 2022-07-28 12:33:34 +02:00
crypto for-5.20/block-2022-08-04 2022-08-04 20:00:14 -07:00
drm drm/edid: add a quirk for two LG monitors to get them to work on 10bpc 2022-12-31 13:26:42 +01:00
dt-bindings dt-bindings: clocks: imx8mp: Add ID for usb suspend clock 2022-12-31 13:26:51 +01:00
keys
kunit kunit: fix assert_type for comparison macros 2022-09-01 13:00:32 -06:00
kvm KVM: arm64: vgic: Consolidate userspace access for base address setting 2022-07-17 11:55:33 +01:00
linux efi: random: combine bootloader provided RNG seed with RNG protocol output 2023-01-12 12:00:48 +01:00
math-emu
media media: dvbdev: fix build warning due to comments 2022-12-31 13:26:53 +01:00
memory
misc
net netfilter: nf_tables: honor set timeout and garbage collection updates 2023-01-12 12:00:31 +01:00
pcmcia
ras mm, hwpoison: enable memory error handling on 1GB hugepage 2022-08-08 18:06:44 -07:00
rdma dma-mapping updates 2022-08-06 10:56:45 -07:00
rv Documentation/rv: Add deterministic automata monitor synthesis documentation 2022-07-30 14:01:29 -04:00
scsi scsi: libsas: Add smp_ata_check_ready_type() 2022-12-31 13:26:21 +01:00
soc ARM: at91: pm: avoid soft resetting AC DLL 2022-11-26 09:27:26 +01:00
sound ALSA: hda/hdmi: fix stream-id config keep-alive for rt suspend 2022-12-31 13:26:49 +01:00
target scsi: target: core: De-RCU of se_lun and se_lun acl 2022-08-01 19:36:02 -04:00
trace ext4: disable fast-commit of encrypted dir operations 2023-01-07 11:16:02 +01:00
uapi btrfs: separate BLOCK_GROUP_TREE compat RO flag from EXTENT_TREE_V2 2023-01-12 12:00:44 +01:00
ufs scsi: ufs: core: Enable link lost interrupt 2022-08-11 22:04:32 -04:00
vdso
video
xen x86/xen: Add support for HVMOP_set_evtchn_upcall_vector 2022-08-12 11:28:21 +02:00