linux/arch/x86/boot/compressed
Ard Biesheuvel aa6ef9ceab x86/boot: Sanitize boot params before parsing command line
commit c00b413a96 upstream.

The 5-level paging code parses the command line to look for the 'no5lvl'
string, and does so very early, before sanitize_boot_params() has been
called and has been given the opportunity to wipe bogus data from the
fields in boot_params that are not covered by struct setup_header, and
are therefore supposed to be initialized to zero by the bootloader.

This triggers an early boot crash when using syslinux-efi to boot a
recent kernel built with CONFIG_X86_5LEVEL=y and CONFIG_EFI_STUB=n, as
the 0xff padding that now fills the unused PE/COFF header is copied into
boot_params by the bootloader, and interpreted as the top half of the
command line pointer.

Fix this by sanitizing the boot_params before use. Note that there is no
harm in calling this more than once; subsequent invocations are able to
spot that the boot_params have already been cleaned up.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: <stable@vger.kernel.org> # v6.1+
Link: https://lore.kernel.org/r/20250306155915.342465-2-ardb+git@google.com
Closes: https://lore.kernel.org/all/202503041549.35913.ulrich.gemkow@ikr.uni-stuttgart.de
[ardb: resolve conflict]
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2025-03-13 12:58:40 +01:00
..
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
acpi.c x86/boot: Rename conflicting 'boot_params' pointer to 'boot_params_ptr' 2025-03-13 12:58:40 +01:00
cmdline.c x86/boot: Rename conflicting 'boot_params' pointer to 'boot_params_ptr' 2025-03-13 12:58:40 +01:00
cpuflags.c x86/sev-es: Check required CPU features for SEV-ES 2020-09-10 21:49:25 +02:00
early_serial_console.c x86/boot: Put globals that are accessed early into the .data section 2022-04-20 20:10:54 +02:00
efi.c x86/boot: Add an efi.h header for the decompressor 2022-04-17 21:15:49 +02:00
efi.h x86/boot/compressed: Handle unaccepted memory 2023-06-06 17:17:24 +02:00
efi_mixed.S x86/efistub: Add missing boot_params for mixed mode compat entry 2024-04-03 15:28:53 +02:00
error.c x86/purgatory: Include header for warn() declaration 2023-08-03 16:37:18 +02:00
error.h x86/purgatory: Include header for warn() declaration 2023-08-03 16:37:18 +02:00
head_32.S x86/efistub: Avoid legacy decompressor when doing EFI boot 2023-08-07 21:07:43 +02:00
head_64.S x86/boot/64: Clear most of CR4 in startup_64(), except PAE, MCE and LA57 2024-06-12 11:11:41 +02:00
ident_map_64.c x86/boot: Rename conflicting 'boot_params' pointer to 'boot_params_ptr' 2025-03-13 12:58:40 +01:00
idt_64.c x86/boot: Ignore NMIs during very early boot 2024-02-05 20:14:14 +00:00
idt_handlers_64.S x86/boot: Ignore NMIs during very early boot 2024-02-05 20:14:14 +00:00
kaslr.c x86/boot: Rename conflicting 'boot_params' pointer to 'boot_params_ptr' 2025-03-13 12:58:40 +01:00
kernel_info.S x86/boot: Introduce setup_indirect 2019-11-12 16:21:15 +01:00
Makefile x86/boot: Use '-std=gnu11' to fix build with GCC 15 2025-02-17 09:40:27 +01:00
mem.c x86/boot: Rename conflicting 'boot_params' pointer to 'boot_params_ptr' 2025-03-13 12:58:40 +01:00
mem_encrypt.S x86/boot/compressed: Only build mem_encrypt.S if AMD_MEM_ENCRYPT=y 2022-11-24 08:57:41 +01:00
misc.c x86/boot: Rename conflicting 'boot_params' pointer to 'boot_params_ptr' 2025-03-13 12:58:40 +01:00
misc.h x86/boot: Rename conflicting 'boot_params' pointer to 'boot_params_ptr' 2025-03-13 12:58:40 +01:00
mkpiggy.c x86/boot: Remove run-time relocations from head_{32,64}.S 2020-08-14 12:52:35 +02:00
pgtable.h x86/decompressor: Pass pgtable address to trampoline directly 2023-08-07 20:49:26 +02:00
pgtable_64.c x86/boot: Sanitize boot params before parsing command line 2025-03-13 12:58:40 +01:00
sev.c x86/boot: Rename conflicting 'boot_params' pointer to 'boot_params_ptr' 2025-03-13 12:58:40 +01:00
sev.h x86/sev: Add SNP-specific unaccepted memory support 2023-06-06 18:31:37 +02:00
string.c x86/boot: Provide KASAN compatible aliases for string routines 2019-05-24 08:44:16 +02:00
tdcall.S x86/boot: Port I/O: Add decompression-time support for TDX 2022-04-07 08:27:52 -07:00
tdx-shared.c x86/tdx: Add unaccepted memory support 2023-06-06 18:25:57 +02:00
tdx.c x86/tdx: Wrap exit reason with hcall_func() 2023-05-23 07:01:45 -07:00
tdx.h x86/tdx: Detect TDX at early kernel decompression time 2022-04-07 08:27:51 -07:00
vmlinux.lds.S x86/boot: Increase section and file alignment to 4k/512 2024-02-23 09:25:27 +01:00