kernel_samsung_a53x/arch/x86/mm
Baoquan He 69f47a131e x86/mm: Fix a kdump kernel failure on SME system when CONFIG_IMA_KEXEC=y
commit 8d9ffb2fe65a6c4ef114e8d4f947958a12751bbe upstream.

The kdump kernel is broken on SME systems with CONFIG_IMA_KEXEC=y enabled.
Debugging traced the issue back to

  b69a2afd5afc ("x86/kexec: Carry forward IMA measurement log on kexec").

Testing was previously not conducted on SME systems with CONFIG_IMA_KEXEC
enabled, which led to the oversight, with the following incarnation:

...
  ima: No TPM chip found, activating TPM-bypass!
  Loading compiled-in module X.509 certificates
  Loaded X.509 cert 'Build time autogenerated kernel key: 18ae0bc7e79b64700122bb1d6a904b070fef2656'
  ima: Allocated hash algorithm: sha256
  Oops: general protection fault, probably for non-canonical address 0xcfacfdfe6660003e: 0000 [#1] PREEMPT SMP NOPTI
  CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.11.0-rc2+ #14
  Hardware name: Dell Inc. PowerEdge R7425/02MJ3T, BIOS 1.20.0 05/03/2023
  RIP: 0010:ima_restore_measurement_list
  Call Trace:
   <TASK>
   ? show_trace_log_lvl
   ? show_trace_log_lvl
   ? ima_load_kexec_buffer
   ? __die_body.cold
   ? die_addr
   ? exc_general_protection
   ? asm_exc_general_protection
   ? ima_restore_measurement_list
   ? vprintk_emit
   ? ima_load_kexec_buffer
   ima_load_kexec_buffer
   ima_init
   ? __pfx_init_ima
   init_ima
   ? __pfx_init_ima
   do_one_initcall
   do_initcalls
   ? __pfx_kernel_init
   kernel_init_freeable
   kernel_init
   ret_from_fork
   ? __pfx_kernel_init
   ret_from_fork_asm
   </TASK>
  Modules linked in:
  ---[ end trace 0000000000000000 ]---
  ...
  Kernel panic - not syncing: Fatal exception
  Kernel Offset: disabled
  Rebooting in 10 seconds..

Adding debug printks showed that the stored addr and size of ima_kexec buffer
are not decrypted correctly like:

  ima: ima_load_kexec_buffer, buffer:0xcfacfdfe6660003e, size:0xe48066052d5df359

Three types of setup_data info

  — SETUP_EFI,
  - SETUP_IMA, and
  - SETUP_RNG_SEED

are passed to the kexec/kdump kernel. Only the ima_kexec buffer
experienced incorrect decryption. Debugging identified a bug in
early_memremap_is_setup_data(), where an incorrect range calculation
occurred due to the len variable in struct setup_data ended up only
representing the length of the data field, excluding the struct's size,
and thus leading to miscalculation.

Address a similar issue in memremap_is_setup_data() while at it.

  [ bp: Heavily massage. ]

Fixes: b3c72fc9a78e ("x86/boot: Introduce setup_indirect")
Signed-off-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Cc: <stable@kernel.org>
Link: https://lore.kernel.org/r/20240911081615.262202-3-bhe@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-12-17 13:20:50 +01:00
..
pat x86/mm/pat: fix VM_PAT handling in COW mappings 2024-11-19 09:23:15 +01:00
amdtopology.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cpu_entry_area.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
debug_pagetables.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dump_pagetables.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
extable.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fault.c x86/mm: Remove broken vsyscall emulation code from the page fault code 2024-11-19 12:27:13 +01:00
highmem_32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hugetlbpage.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ident_map.c Revert "x86/mm/ident_map: Use gbpages only where full GB page should be mapped." 2024-11-19 09:22:46 +01:00
init.c Revert "x86/mm: Switch to new Intel CPU model defines" 2024-11-24 00:23:18 +01:00
init_32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
init_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
iomap_32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ioremap.c x86/mm: Fix a kdump kernel failure on SME system when CONFIG_IMA_KEXEC=y 2024-12-17 13:20:50 +01:00
kasan_init_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kaslr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kmmio.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
maccess.c x86/mm: Disallow vsyscall page read for copy_from_kernel_nofault() 2024-11-19 08:44:36 +01:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mem_encrypt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mem_encrypt_boot.S Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mem_encrypt_identity.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mm_internal.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmap.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmio-mod.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
numa.c x86/mm: Drop the 4 MB restriction on minimal NUMA node memory size 2024-11-18 11:43:12 +01:00
numa_32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
numa_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
numa_emulation.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
numa_internal.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pf_in.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pf_in.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pgtable.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pgtable_32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
physaddr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
physaddr.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pkeys.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pti.c x86/mm: Fix pti_clone_pgtable() alignment assumption 2024-11-23 23:20:21 +01:00
setup_nx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
srat.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
testmmiotrace.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tlb.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00