From: Felix Fu fuzhen5@huawei.com
Signed-off-by: Felix Fu fuzhen5@huawei.com --- drivers/firmware/efi/libstub/kaslr.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/drivers/firmware/efi/libstub/kaslr.c b/drivers/firmware/efi/libstub/kaslr.c index 1a9808012abd..a29ae4c99ffb 100644 --- a/drivers/firmware/efi/libstub/kaslr.c +++ b/drivers/firmware/efi/libstub/kaslr.c @@ -37,6 +37,7 @@ u32 efi_kaslr_get_phys_seed(efi_handle_t image_handle) if (status == EFI_SUCCESS) { return phys_seed; } else if (status == EFI_NOT_FOUND) { + return phys_seed; efi_info("EFI_RNG_PROTOCOL unavailable\n"); efi_nokaslr = true; } else if (status != EFI_SUCCESS) { @@ -112,11 +113,13 @@ efi_status_t efi_kaslr_relocate_kernel(unsigned long *image_addr, efi_status_t status; u64 min_kimg_align = efi_get_kimg_min_align();
+ phys_seed = 1; if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && phys_seed != 0) { /* * If KASLR is enabled, and we have some randomness available, * locate the kernel at a randomized offset in physical memory. */ + phys_seed = 0; status = efi_random_alloc(*reserve_size, min_kimg_align, reserve_addr, phys_seed, EFI_LOADER_CODE, 0, EFI_ALLOC_LIMIT);