Skip to content

Commit 818c7ce

Browse files
jwrdegoedeIngo Molnar
authored andcommitted
efi/libstub/random: Initialize pointer variables to zero for mixed mode
Commit: 0d95981 ("x86: efi/random: Invoke EFI_RNG_PROTOCOL to seed the UEFI RNG table") causes the drivers/efi/libstub/random.c code to get used on x86 for the first time. But this code was not written with EFI mixed mode in mind (running a 64 bit kernel on 32 bit EFI firmware), this causes the kernel to crash during early boot when running in mixed mode. The problem is that in mixed mode pointers are 64 bit, but when running on a 32 bit firmware, EFI calls which return a pointer value by reference only fill the lower 32 bits of the passed pointer, leaving the upper 32 bits uninitialized which leads to crashes. This commit fixes this by initializing pointers which are passed by reference to EFI calls to NULL before passing them, so that the upper 32 bits are initialized to 0. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Cc: Arvind Sankar <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Fixes: 0d95981 ("x86: efi/random: Invoke EFI_RNG_PROTOCOL to seed the UEFI RNG table") Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent d92b545 commit 818c7ce

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/firmware/efi/libstub/random.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table_arg,
3333
{
3434
efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID;
3535
efi_status_t status;
36-
struct efi_rng_protocol *rng;
36+
struct efi_rng_protocol *rng = NULL;
3737

3838
status = efi_call_early(locate_protocol, &rng_proto, NULL,
3939
(void **)&rng);
@@ -162,8 +162,8 @@ efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg)
162162
efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID;
163163
efi_guid_t rng_algo_raw = EFI_RNG_ALGORITHM_RAW;
164164
efi_guid_t rng_table_guid = LINUX_EFI_RANDOM_SEED_TABLE_GUID;
165-
struct efi_rng_protocol *rng;
166-
struct linux_efi_random_seed *seed;
165+
struct efi_rng_protocol *rng = NULL;
166+
struct linux_efi_random_seed *seed = NULL;
167167
efi_status_t status;
168168

169169
status = efi_call_early(locate_protocol, &rng_proto, NULL,

0 commit comments

Comments
 (0)