Skip to contentSkip to conversation

FAILED: Patch "x86/kexec: add a sanity check on previous kernel's ima kexec buffer" failed to apply to 6.6-stable tree

PATCH Sasha Levin 1 participant 1 message Mar 1

Subsystems (2)
lore
Share & tools
lore

Sasha Levin

author maintainer
#0 lore raw

The patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

Thanks,
Sasha

------------------ original commit in Linus's tree ------------------

From c5489d04337b47e93c0623e8145fcba3f5739efd Mon Sep 17 00:00:00 2001
From: Harshit Mogalapalli <[email protected]>
Date: Tue, 30 Dec 2025 22:16:09 -0800
Subject: [PATCH] x86/kexec: add a sanity check on previous kernel's ima kexec
buffer
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When the second-stage kernel is booted via kexec with a limiting command line such as "mem=<size>", the physical range that contains the carried over IMA measurement list may fall outside the truncated RAM leading to a kernel panic.

    BUG: unable to handle page fault for address: ffff97793ff47000
    RIP: ima_restore_measurement_list+0xdc/0x45a
    #PF: error_code(0x0000) – not-present page

Other architectures already validate the range with page_is_ram(), as done in commit cbf9c4b9617b ("of: check previous kernel's ima-kexec-buffer against memory bounds") do a similar check on x86.

Without carrying the measurement list across kexec, the attestation would fail.

Fixes b69a2afd5afc ("x86/kexec: Carry forward IMA measurement log on kexec")
Cc Alexander Graf <[email protected]>
Cc Ard Biesheuvel <[email protected]>
Cc Baoquan He <[email protected]>
Cc Borislav Betkov <[email protected]>
Cc guoweikang <[email protected]>
Cc Henry Willard <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jiri Bohac <[email protected]>
Cc Joel Granados <[email protected]>
Cc Jonathan McDowell <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Sohil Mehta <[email protected]>
Cc Sourabh Jain <[email protected]>
Cc Thomas Gleinxer <[email protected]>
Cc Yifei Liu <[email protected]>
---
 arch/x86/kernel/setup.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/x86/kernel/setup.c +6 -0
index 1b2edd07a3e17..383d4a4784f5b 100644
@@ -439,9 +439,15 @@ int __init ima_free_kexec_buffer(void)
 
 int __init ima_get_kexec_buffer(void **addr, size_t *size)
 {
+	int ret;
+
 	if (!ima_kexec_buffer_size)
 		return -ENOENT;
 
+	ret = ima_validate_range(ima_kexec_buffer_phys, ima_kexec_buffer_size);
+	if (ret)
+		return ret;
+
 	*addr = __va(ima_kexec_buffer_phys);
 	*size = ima_kexec_buffer_size;
 
Signature · 1 line
2.51.0