[PATCH v2 03/10] efi/libstub: Avoid _end section marker in library code
Ard Biesheuvel
ardb+git at google.com
Tue Nov 10 04:17:35 PST 2026
From: Ard Biesheuvel <ardb at kernel.org>
The _end marker could point to the end of the kernel image being loaded,
or to the _end of the zboot decompressor image, and so it should only be
used in code that is obviously only intended for the former case.
So instead, use kernel_memsize and the image address to obtain the same
quantity.
Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
---
drivers/firmware/efi/libstub/kaslr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firmware/efi/libstub/kaslr.c b/drivers/firmware/efi/libstub/kaslr.c
index 8f8dc335b3b3..b34e4599f0f6 100644
--- a/drivers/firmware/efi/libstub/kaslr.c
+++ b/drivers/firmware/efi/libstub/kaslr.c
@@ -125,7 +125,7 @@ efi_status_t efi_kaslr_relocate_kernel(unsigned long *image_addr,
if (!check_image_region(*image_addr, kernel_memsize)) {
efi_err("FIRMWARE BUG: Image BSS overlaps adjacent EFI memory region\n");
} else if (IS_ALIGNED(*image_addr, min_kimg_align) &&
- (unsigned long)_end < EFI_ALLOC_LIMIT) {
+ (*image_addr + kernel_memsize) < EFI_ALLOC_LIMIT) {
/*
* Just execute from wherever we were loaded by the
* UEFI PE/COFF loader if the placement is suitable.
--
2.56.0.542.g3ef89b7020-goog
More information about the linux-riscv
mailing list