lkml.org 
[lkml]   [2024]   [Jan]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] x86/efistub: fix the missing KASLR_FLAG bit in boot_params->hdr.loadflags
On Tue, 26 Dec 2023 at 15:03, Yuntao Wang <ytcoode@gmail.com> wrote:
>
> 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 kernel is booted via 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.
>
> Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
> ---
> drivers/firmware/efi/libstub/x86-stub.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
> index da9b7b8d0716..b0c68593ad40 100644
> --- a/drivers/firmware/efi/libstub/x86-stub.c
> +++ b/drivers/firmware/efi/libstub/x86-stub.c
> @@ -787,7 +787,10 @@ static efi_status_t efi_decompress_kernel(unsigned long *kernel_entry)
> efi_debug("AMI firmware v2.0 or older detected - disabling physical KASLR\n");
> seed[0] = 0;
> }
> - }
> +
> + boot_params_ptr->hdr.loadflags |= KASLR_FLAG;
> + } else
> + boot_params_ptr->hdr.loadflags &= ~KASLR_FLAG;
>

Thanks for the fix.

I'll queue this up right away, but I am going to drop the 'else' part,
given that the KASLR flag is never set by the EFI stub so clearing it
should never be needed.


> status = efi_random_alloc(alloc_size, CONFIG_PHYSICAL_ALIGN, &addr,
> seed[0], EFI_LOADER_CODE,
> --
> 2.43.0
>

\
 
 \ /
  Last update: 2024-01-02 16:30    [W:0.046 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site