Skip to content

Commit 0163843

Browse files
ytcoodeardbiesheuvel
authored andcommitted
efi/x86: Fix the missing KASLR_FLAG bit in boot_params->hdr.loadflags
When KASLR is enabled, the KASLR_FLAG bit in boot_params->hdr.loadflags should be set to 1 to propagate KASLR status from compressed kernel to kernel, just as the choose_random_location() function does. Currently, when the kernel is booted via the EFI stub, the KASLR_FLAG bit in boot_params->hdr.loadflags is not set, even though it should be. This causes some functions, such as kernel_randomize_memory(), not to execute as expected. Fix it. Fixes: a1b87d5 ("x86/efistub: Avoid legacy decompressor when doing EFI boot") Signed-off-by: Yuntao Wang <ytcoode@gmail.com> [ardb: drop 'else' branch clearing KASLR_FLAG] Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent 50d7cdf commit 0163843

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,8 @@ static efi_status_t efi_decompress_kernel(unsigned long *kernel_entry)
787787
efi_debug("AMI firmware v2.0 or older detected - disabling physical KASLR\n");
788788
seed[0] = 0;
789789
}
790+
791+
boot_params_ptr->hdr.loadflags |= KASLR_FLAG;
790792
}
791793

792794
status = efi_random_alloc(alloc_size, CONFIG_PHYSICAL_ALIGN, &addr,

0 commit comments

Comments
 (0)