linux-stable/drivers/firmware
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
..
arm_ffa
arm_scmi firmware: arm_scmi: Make tx_prepare time out eventually 2022-11-26 09:27:19 +01:00
broadcom
cirrus firmware: cs_dsp: Add memory chunk helpers 2022-07-22 13:40:00 +01:00
efi efi: random: combine bootloader provided RNG seed with RNG protocol output 2023-01-12 12:00:48 +01:00
google firmware: coreboot: Register bus in module init 2022-11-26 09:27:50 +01:00
imx
meson
psci
smccc
tegra firmware: tegra: Fix error check return value of debugfs_create_file() 2022-07-08 17:56:03 +02:00
xilinx firmware: xilinx: Add TF_A_PM_REGISTER_SGI SMC call 2022-06-29 14:46:22 +02:00
Kconfig
Makefile Follow-up tweaks for the EFI changes in v5.19 2022-06-03 13:39:30 -07:00
arm_scpi.c firmware: arm_scpi: Ensure scpi_info is not assigned if the probe fails 2022-07-04 14:28:42 +01:00
arm_sdei.c
dmi-id.c
dmi-sysfs.c
dmi_scan.c firmware: dmi: Use the proper accessor for the version field 2022-07-30 18:28:46 +02:00
edd.c
iscsi_ibft.c
iscsi_ibft_find.c
memmap.c
mtk-adsp-ipc.c firmware: mediatek: Use meaningful names for mbox 2022-06-22 13:39:30 +01:00
pcdp.c
pcdp.h
qcom_scm-legacy.c firmware: qcom_scm-legacy: correct kerneldoc 2022-06-25 22:04:31 -05:00
qcom_scm-smc.c
qcom_scm.c firmware: qcom_scm: Add bw voting support to the SCM interface 2022-06-29 21:48:32 -05:00
qcom_scm.h
qemu_fw_cfg.c
raspberrypi.c firmware: raspberrypi: fix possible memory leak in rpi_firmware_probe() 2022-12-31 13:26:26 +01:00
scpi_pm_domain.c
stratix10-rsu.c firmware: stratix10-rsu: extend RSU driver to get DCMF status 2022-07-14 16:55:09 +02:00
stratix10-svc.c firmware: stratix10-svc: To support a command ATF Get Version 2022-07-14 16:55:09 +02:00
sysfb.c firmware: sysfb: Add sysfb_disable() helper function 2022-06-29 09:51:41 +02:00
sysfb_simplefb.c firmware: sysfb: Make sysfb_create_simplefb() return a pdev pointer 2022-06-29 09:51:31 +02:00
ti_sci.c firmware: ti_sci: Fix polled mode during system suspend 2022-12-31 13:25:36 +01:00
ti_sci.h
trusted_foundations.c
turris-mox-rwtm.c