Skip to content

Commit d32de91

Browse files
committed
efi/arm64: libstub: Deal gracefully with EFI_RNG_PROTOCOL failure
Currently, on arm64, we abort on any failure from efi_get_random_bytes() other than EFI_NOT_FOUND when it comes to setting the physical seed for KASLR, but ignore such failures when obtaining the seed for virtual KASLR or for early seeding of the kernel's entropy pool via the config table. This is inconsistent, and may lead to unexpected boot failures. So let's permit any failure for the physical seed, and simply report the error code if it does not equal EFI_NOT_FOUND. Cc: <stable@vger.kernel.org> # v5.8+ Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent 336af6a commit d32de91

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

drivers/firmware/efi/libstub/arm64-stub.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,12 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
6262
status = efi_get_random_bytes(sizeof(phys_seed),
6363
(u8 *)&phys_seed);
6464
if (status == EFI_NOT_FOUND) {
65-
efi_info("EFI_RNG_PROTOCOL unavailable, no randomness supplied\n");
65+
efi_info("EFI_RNG_PROTOCOL unavailable, KASLR will be disabled\n");
66+
efi_nokaslr = true;
6667
} else if (status != EFI_SUCCESS) {
67-
efi_err("efi_get_random_bytes() failed\n");
68-
return status;
68+
efi_err("efi_get_random_bytes() failed (0x%lx), KASLR will be disabled\n",
69+
status);
70+
efi_nokaslr = true;
6971
}
7072
} else {
7173
efi_info("KASLR disabled on kernel command line\n");

drivers/firmware/efi/libstub/fdt.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static efi_status_t update_fdt(void *orig_fdt, unsigned long orig_fdt_size,
136136
if (status)
137137
goto fdt_set_fail;
138138

139-
if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) {
139+
if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && !efi_nokaslr) {
140140
efi_status_t efi_status;
141141

142142
efi_status = efi_get_random_bytes(sizeof(fdt_val64),
@@ -145,8 +145,6 @@ static efi_status_t update_fdt(void *orig_fdt, unsigned long orig_fdt_size,
145145
status = fdt_setprop_var(fdt, node, "kaslr-seed", fdt_val64);
146146
if (status)
147147
goto fdt_set_fail;
148-
} else if (efi_status != EFI_NOT_FOUND) {
149-
return efi_status;
150148
}
151149
}
152150

0 commit comments

Comments
 (0)