linux/drivers/firmware/efi
Ard Biesheuvel decd347c2a x86/efistub: Reinstate soft limit for initrd loading
Commit

  8117961d98 ("x86/efi: Disregard setup header of loaded image")

dropped the memcopy of the image's setup header into the boot_params
struct provided to the core kernel, on the basis that EFI boot does not
need it and should rely only on a single protocol to interface with the
boot chain. It is also a prerequisite for being able to increase the
section alignment to 4k, which is needed to enable memory protections
when running in the boot services.

So only the setup_header fields that matter to the core kernel are
populated explicitly, and everything else is ignored. One thing was
overlooked, though: the initrd_addr_max field in the setup_header is not
used by the core kernel, but it is used by the EFI stub itself when it
loads the initrd, where its default value of INT_MAX is used as the soft
limit for memory allocation.

This means that, in the old situation, the initrd was virtually always
loaded in the lower 2G of memory, but now, due to initrd_addr_max being
0x0, the initrd may end up anywhere in memory. This should not be an
issue principle, as most systems can deal with this fine. However, it
does appear to tickle some problems in older UEFI implementations, where
the memory ends up being corrupted, resulting in errors when unpacking
the initramfs.

So set the initrd_addr_max field to INT_MAX like it was before.

Fixes: 8117961d98 ("x86/efi: Disregard setup header of loaded image")
Reported-by: Radek Podgorny <radek@podgorny.cz>
Closes: https://lore.kernel.org/all/a99a831a-8ad5-4cb0-bff9-be637311f771@podgorny.cz
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-03-28 16:19:46 +01:00
..
libstub x86/efistub: Reinstate soft limit for initrd loading 2024-03-28 16:19:46 +01:00
stmm efi: Add tee-based EFI variable driver 2023-12-11 11:19:18 +01:00
test efi/efi_test: read RuntimeServicesSupported 2020-12-09 08:37:27 +01:00
apple-properties.c efi: fix return value of __setup handlers 2022-03-01 09:02:21 +01:00
arm-runtime.c efi: runtime: Fix potential overflow of soft-reserved region size 2024-02-02 19:31:24 +01:00
capsule-loader.c efi/capsule-loader: fix incorrect allocation size 2024-02-13 16:30:07 +01:00
capsule.c efi: capsule: clean scatter-gather entries from the D-cache 2020-12-09 08:37:27 +01:00
cper_cxl.c efi/cper, cxl: Remove cxl_err.h 2023-02-03 23:59:58 +01:00
cper_cxl.h efi/cper, cxl: Decode CXL Protocol Error Section 2022-11-18 09:14:10 +01:00
cper-arm.c efi/cper: Remove unnecessary aer.h include 2023-04-07 16:42:31 -05:00
cper-x86.c x86/mce, cper: Pass x86 CPER through the MCA handling chain 2020-11-21 12:05:41 +01:00
cper.c pci-v6.9-changes 2024-03-14 10:58:27 -07:00
dev-path-parser.c efi: dev-path-parser: use acpi_dev_uid_match() for matching _UID 2023-12-06 18:02:37 +01:00
earlycon.c fbcon: Increase maximum font width x height to 64 x 128 2024-03-16 08:29:48 +01:00
efi-bgrt.c efi/bgrt: Accept BGRT tables with a version of 0 2020-02-22 23:37:37 +01:00
efi-init.c efi: Don't add memblocks for soft-reserved memory 2024-02-02 19:31:24 +01:00
efi-pstore.c efi: pstore: Allow dynamic initialization based on module parameter 2024-02-22 10:37:21 -08:00
efi.c efi: fix panic in kdump kernel 2024-03-24 09:28:33 +01:00
efibc.c efi: efibc: Guard against allocation failure 2022-09-20 18:42:55 +02:00
embedded-firmware.c crypto: sha - split sha.h into sha1.h and sha2.h 2020-11-20 14:45:33 +11:00
esrt.c efi/esrt: Allow ESRT access without CAP_SYS_ADMIN 2023-06-06 15:33:59 +02:00
fdtparams.c efi: xen: Set EFI_PARAVIRT for Xen dom0 boot on all architectures 2022-11-18 09:14:09 +01:00
Kconfig efi: Add tee-based EFI variable driver 2023-12-11 11:19:18 +01:00
Makefile efi: Add tee-based EFI variable driver 2023-12-11 11:19:18 +01:00
memattr.c A healthy mix of EFI contributions this time: 2023-02-23 14:41:48 -08:00
memmap.c efi: memmap: fix kernel-doc warnings 2023-12-22 10:42:06 +01:00
mokvar-table.c efi/mokvar: move up init order 2022-03-08 13:55:52 +02:00
rci2-table.c efi: Don't attempt to map RCI2 config table if it doesn't exist 2019-12-10 12:13:02 +01:00
reboot.c efi: Fix efi_power_off() not being run before acpi_power_off() when necessary 2022-07-10 17:41:06 +02:00
riscv-runtime.c efi: runtime: Fix potential overflow of soft-reserved region size 2024-02-02 19:31:24 +01:00
runtime-wrappers.c efi/runtime-wrappers: Clean up white space and add __init annotation 2023-08-22 10:39:26 +02:00
sysfb_efi.c driver core: Adds flags param to fwnode_link_add() 2024-03-07 22:10:01 +00:00
tpm.c efi/tpm: Pass correct address to memblock_reserve 2022-10-24 08:04:25 +02:00
unaccepted_memory.c efi/unaccepted: Fix off-by-one when checking for overlapping ranges 2023-11-28 12:49:21 +01:00
vars.c efivarfs: automatically update super block flag 2023-12-11 11:19:18 +01:00