Linux-EFI Archive mirror
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Yuntao Wang <ytcoode@gmail.com>,
	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 17:26:58 +0100	[thread overview]
Message-ID: <CAMj1kXELiSzz75EGJuYwvSURfjGmZaRLEQghvGVVc5JMN+Npow@mail.gmail.com> (raw)
In-Reply-To: <b2c4835d-0076-47f0-b0d1-792dc32cc305@amd.com>

On Tue, 2 Jan 2024 at 17:26, Tom Lendacky <thomas.lendacky@amd.com> wrote:
>
> 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?
>

Yes, I've added that.

      reply	other threads:[~2024-01-02 16:27 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
2024-01-02 16:26     ` Ard Biesheuvel [this message]

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=CAMj1kXELiSzz75EGJuYwvSURfjGmZaRLEQghvGVVc5JMN+Npow@mail.gmail.com \
    --to=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=thomas.lendacky@amd.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).