public inbox for linux-efi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] LoongArch: Move KASLR to EFI stub to avoid initrd overlap
@ 2026-04-27 10:47 WANG Rui
  2026-04-27 10:47 ` [PATCH 1/3] LoongArch: Allow rdtime_h() and rdtime_l() in 64-bit builds WANG Rui
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: WANG Rui @ 2026-04-27 10:47 UTC (permalink / raw)
  To: Huacai Chen, Ard Biesheuvel
  Cc: WANG Xuerui, Ilias Apalodimas, loongarch, linux-efi, linux-kernel,
	WANG Rui

This series addresses a potential overlap issue between the kernel
image and the initrd when KASLR is enabled.

In the normal boot flow, the bootloader is responsible for loading
both vmlinux and the initrd, and it can guarantee that the two do
not overlap in memory. However, this assumption only holds as long
as neither image changes its location afterwards.

The in-kernel KASLR implementation breaks that assumption. When the
initrd is placed close to the kernel image, randomizing the kernel
location at runtime may move it into the initrd region, leading to
memory corruption early during boot.

To fix this, this series moves the KASLR logic out of the kernel
proper and into the EFI stub. With this change, the final placement
of both the kernel image and the initrd is determined by the EFI
memory allocator. This ensures that the two allocations are
coordinated and cannot overlap.

Functionally, the kernel still supports KASLR as before, but the
randomization now happens before the kernel is entered, rather than
during early kernel relocation.

WANG Rui (3):
  LoongArch: Allow rdtime_h() and rdtime_l() in 64-bit builds
  efi/loongarch: Randomize kernel preferred address for KASLR
  LoongArch: Skip relocation-time KASLR if it has already been applied

 arch/loongarch/Kconfig                   |  2 +-
 arch/loongarch/include/asm/efi.h         |  4 +++-
 arch/loongarch/include/asm/loongarch.h   |  6 ------
 arch/loongarch/kernel/relocate.c         |  4 ++++
 drivers/firmware/efi/libstub/loongarch.c | 16 ++++++++++++++++
 5 files changed, 24 insertions(+), 8 deletions(-)

-- 
2.54.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-04-27 15:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox