From: Wenshan Lan <jetlan9@163.com>
To: gregkh@linuxfoundation.org, sashal@kernel.org, stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>,
Paul Webb <paul.x.webb@oracle.com>,
Mimi Zohar <zohar@linux.ibm.com>,
Alexander Graf <graf@amazon.com>,
Ard Biesheuvel <ardb@kernel.org>, Baoquan He <bhe@redhat.com>,
Borislav Betkov <bp@alien8.de>,
guoweikang <guoweikang.kernel@gmail.com>,
Henry Willard <henry.willard@oracle.com>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
Jiri Bohac <jbohac@suse.cz>,
Joel Granados <joel.granados@kernel.org>,
Jonathan McDowell <noodles@fb.com>,
Mike Rapoport <rppt@kernel.org>,
Sohil Mehta <sohil.mehta@intel.com>,
Sourabh Jain <sourabhjain@linux.ibm.com>,
Thomas Gleinxer <tglx@linutronix.de>,
Yifei Liu <yifei.l.liu@oracle.com>,
Andrew Morton <akpm@linux-foundation.org>,
Wenshan Lan <jetlan9@163.com>
Subject: [PATCH 6.6.y 3/3] x86/kexec: add a sanity check on previous kernel's ima kexec buffer
Date: Wed, 3 Jun 2026 21:02:39 +0800 [thread overview]
Message-ID: <20260603130239.81400-3-jetlan9@163.com> (raw)
In-Reply-To: <20260603130239.81400-1-jetlan9@163.com>
From: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
[ Upstream commit c5489d04337b47e93c0623e8145fcba3f5739efd ]
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.
Link: https://lkml.kernel.org/r/20251231061609.907170-4-harshit.m.mogalapalli@oracle.com
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Fixes: b69a2afd5afc ("x86/kexec: Carry forward IMA measurement log on kexec")
Reported-by: Paul Webb <paul.x.webb@oracle.com>
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
Cc: Alexander Graf <graf@amazon.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Borislav Betkov <bp@alien8.de>
Cc: guoweikang <guoweikang.kernel@gmail.com>
Cc: Henry Willard <henry.willard@oracle.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Bohac <jbohac@suse.cz>
Cc: Joel Granados <joel.granados@kernel.org>
Cc: Jonathan McDowell <noodles@fb.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Sohil Mehta <sohil.mehta@intel.com>
Cc: Sourabh Jain <sourabhjain@linux.ibm.com>
Cc: Thomas Gleinxer <tglx@linutronix.de>
Cc: Yifei Liu <yifei.l.liu@oracle.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Wenshan Lan <jetlan9@163.com>
---
arch/x86/kernel/setup.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index eb129277dcdd..df74f865c9f1 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -372,9 +372,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;
--
2.43.0
next prev parent reply other threads:[~2026-06-03 13:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 13:02 [PATCH 6.6.y 1/3] ima: verify the previous kernel's IMA buffer lies in addressable RAM Wenshan Lan
2026-06-03 13:02 ` [PATCH 6.6.y 2/3] of/kexec: refactor ima_get_kexec_buffer() to use ima_validate_range() Wenshan Lan
2026-06-03 13:02 ` Wenshan Lan [this message]
2026-06-04 0:05 ` [PATCH 6.6.y 1/3] ima: verify the previous kernel's IMA buffer lies in addressable RAM Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260603130239.81400-3-jetlan9@163.com \
--to=jetlan9@163.com \
--cc=akpm@linux-foundation.org \
--cc=ardb@kernel.org \
--cc=bhe@redhat.com \
--cc=bp@alien8.de \
--cc=graf@amazon.com \
--cc=gregkh@linuxfoundation.org \
--cc=guoweikang.kernel@gmail.com \
--cc=harshit.m.mogalapalli@oracle.com \
--cc=henry.willard@oracle.com \
--cc=hpa@zytor.com \
--cc=jbohac@suse.cz \
--cc=joel.granados@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=noodles@fb.com \
--cc=paul.x.webb@oracle.com \
--cc=rppt@kernel.org \
--cc=sashal@kernel.org \
--cc=sohil.mehta@intel.com \
--cc=sourabhjain@linux.ibm.com \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=yifei.l.liu@oracle.com \
--cc=zohar@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®