Skip to content

Commit 0d95981

Browse files
Dominik Brodowskiardbiesheuvel
authored andcommitted
x86: efi/random: Invoke EFI_RNG_PROTOCOL to seed the UEFI RNG table
Invoke the EFI_RNG_PROTOCOL protocol in the context of the x86 EFI stub, same as is done on arm/arm64 since commit 568bc4e ("efi/arm*/libstub: Invoke EFI_RNG_PROTOCOL to seed the UEFI RNG table"). Within the stub, a Linux-specific RNG seed UEFI config table will be seeded. The EFI routines in the core kernel will pick that up later, yet still early during boot, to seed the kernel entropy pool. If CONFIG_RANDOM_TRUST_BOOTLOADER, entropy is credited for this seed. Signed-off-by: Dominik Brodowski <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent 41e8a7c commit 0d95981

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

arch/x86/boot/compressed/eboot.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,9 @@ efi_main(struct efi_config *c, struct boot_params *boot_params)
782782

783783
/* Ask the firmware to clear memory on unclean shutdown */
784784
efi_enable_reset_attack_mitigation(sys_table);
785+
786+
efi_random_get_seed(sys_table);
787+
785788
efi_retrieve_tpm2_eventlog(sys_table);
786789

787790
setup_graphics(boot_params);

drivers/firmware/efi/libstub/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ OBJECT_FILES_NON_STANDARD := y
3838
# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
3939
KCOV_INSTRUMENT := n
4040

41-
lib-y := efi-stub-helper.o gop.o secureboot.o tpm.o
41+
lib-y := efi-stub-helper.o gop.o secureboot.o tpm.o \
42+
random.o
4243

4344
# include the stub's generic dependencies from lib/ when building for ARM/arm64
4445
arm-deps-y := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c fdt_empty_tree.c fdt_sw.c
@@ -47,7 +48,7 @@ arm-deps-$(CONFIG_ARM64) += sort.c
4748
$(obj)/lib-%.o: $(srctree)/lib/%.c FORCE
4849
$(call if_changed_rule,cc_o_c)
4950

50-
lib-$(CONFIG_EFI_ARMSTUB) += arm-stub.o fdt.o string.o random.o \
51+
lib-$(CONFIG_EFI_ARMSTUB) += arm-stub.o fdt.o string.o \
5152
$(patsubst %.c,lib-%.o,$(arm-deps-y))
5253

5354
lib-$(CONFIG_ARM) += arm32-stub.o

drivers/firmware/efi/libstub/efistub.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ efi_status_t efi_random_alloc(efi_system_table_t *sys_table_arg,
6363

6464
efi_status_t check_platform_features(efi_system_table_t *sys_table_arg);
6565

66-
efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg);
67-
6866
void *get_efi_config_table(efi_system_table_t *sys_table, efi_guid_t guid);
6967

7068
/* Helper macros for the usual case of using simple C variables: */

include/linux/efi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,8 @@ static inline void
16451645
efi_enable_reset_attack_mitigation(efi_system_table_t *sys_table_arg) { }
16461646
#endif
16471647

1648+
efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg);
1649+
16481650
void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table);
16491651

16501652
/*

0 commit comments

Comments
 (0)