From: hev <r@hev.cc>
To: Huacai Chen <chenhuacai@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>, WANG Xuerui <kernel@xen0n.name>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
loongarch@lists.linux.dev, linux-efi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] LoongArch: Skip relocation-time KASLR if it has already been applied
Date: Mon, 27 Apr 2026 23:30:47 +0800 [thread overview]
Message-ID: <CAHirt9j-PMwKaLUYqR9qCOemBXCw3PfpuB5Ff1EbZozLn8tFqw@mail.gmail.com> (raw)
In-Reply-To: <CAAhV-H7+B6=Uf1ZDy9SLvWkR-ggTi3k9kFU8+B+JefWqPu4Uvw@mail.gmail.com>
Hi Huacai,
On Mon, Apr 27, 2026 at 9:29 PM Huacai Chen <chenhuacai@kernel.org> wrote:
>
> Hi, Rui,
>
> On Mon, Apr 27, 2026 at 6:47 PM WANG Rui <r@hev.cc> wrote:
> >
> > When the kernel is relocated during early boot, a randomized load
> > address may already have been selected and applied. In this case,
> > performing KASLR again in relocate.c is unnecessary.
> >
> > Signed-off-by: WANG Rui <r@hev.cc>
> > ---
> > arch/loongarch/kernel/relocate.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/arch/loongarch/kernel/relocate.c b/arch/loongarch/kernel/relocate.c
> > index 16f6a9b39659..c36604a81d08 100644
> > --- a/arch/loongarch/kernel/relocate.c
> > +++ b/arch/loongarch/kernel/relocate.c
> > @@ -139,6 +139,10 @@ static inline __init bool kaslr_disabled(void)
> > char *str;
> > const char *builtin_cmdline = CONFIG_CMDLINE;
> >
> > + /* KASLR is performed during early boot. */
> > + if (kaslr_offset())
> > + return true;
> Maybe the "kexec_file" case is also handled by this?
Yeah, it looks like kexec_file doesn't load the kernel image to
VMLINUX_LOAD_ADDRESS, so it will disable KASLR here. This aligns with
our expectation of disabling KASLR for this case.
Thanks,
Rui
>
> Huacai
>
> > +
> > str = strstr(builtin_cmdline, "nokaslr");
> > if (str == builtin_cmdline || (str > builtin_cmdline && *(str - 1) == ' ')) {
> > pr_info(KASLR_DISABLED_MESSAGE, "\'nokaslr\'", "built-in");
> > --
> > 2.54.0
> >
prev parent reply other threads:[~2026-04-27 15:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 10:47 [PATCH 0/3] LoongArch: Move KASLR to EFI stub to avoid initrd overlap WANG Rui
2026-04-27 10:47 ` [PATCH 1/3] LoongArch: Allow rdtime_h() and rdtime_l() in 64-bit builds WANG Rui
2026-04-27 10:47 ` [PATCH 2/3] efi/loongarch: Randomize kernel preferred address for KASLR WANG Rui
2026-04-27 13:27 ` Huacai Chen
2026-04-27 15:29 ` hev
2026-04-27 10:47 ` [PATCH 3/3] LoongArch: Skip relocation-time KASLR if it has already been applied WANG Rui
2026-04-27 13:29 ` Huacai Chen
2026-04-27 15:30 ` hev [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=CAHirt9j-PMwKaLUYqR9qCOemBXCw3PfpuB5Ff1EbZozLn8tFqw@mail.gmail.com \
--to=r@hev.cc \
--cc=ardb@kernel.org \
--cc=chenhuacai@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=kernel@xen0n.name \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
/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).