Linux EFI development
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: Ard Biesheuvel <ardb@kernel.org>, Yuntao Wang <ytcoode@gmail.com>
Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Borislav Petkov (AMD)" <bp@alien8.de>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Ingo Molnar <mingo@kernel.org>,
	Dionna Glaze <dionnaglaze@google.com>,
	Nikolay Borisov <nik.borisov@suse.com>
Subject: Re: [PATCH] x86/efistub: fix the missing KASLR_FLAG bit in boot_params->hdr.loadflags
Date: Tue, 2 Jan 2024 10:26:05 -0600	[thread overview]
Message-ID: <b2c4835d-0076-47f0-b0d1-792dc32cc305@amd.com> (raw)
In-Reply-To: <CAMj1kXGE9JUoPUqBMJkwVUco67dEa8N95=gMJwE+Sj1ux1+5tQ@mail.gmail.com>

On 1/2/24 09:29, Ard Biesheuvel wrote:
> 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.

Does it need a Fixes: tag?

Thanks,
Tom

> 
> 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
>>

  reply	other threads:[~2024-01-02 16:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-26 14:02 [PATCH] x86/efistub: fix the missing KASLR_FLAG bit in boot_params->hdr.loadflags Yuntao Wang
2024-01-02 15:29 ` Ard Biesheuvel
2024-01-02 16:26   ` Tom Lendacky [this message]
2024-01-02 16:26     ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2c4835d-0076-47f0-b0d1-792dc32cc305@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=ardb@kernel.org \
    --cc=bp@alien8.de \
    --cc=dionnaglaze@google.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=nik.borisov@suse.com \
    --cc=ytcoode@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox