From: sashiko-bot@kernel.org
To: "Roberto Sassu" <roberto.sassu@huaweicloud.com>
Cc: devicetree@vger.kernel.org,
linux-security-module@vger.kernel.org, robh@kernel.org,
conor+dt@kernel.org
Subject: Re: [PATCH] kexec: Select ima_get/free_kexec_buffer() with CONFIG_HAVE_IMA_KEXEC(_OF)
Date: Wed, 14 Oct 2026 15:12:11 +0000 [thread overview]
Message-ID: <sashiko-outbox-171460@kernel.org> (raw)
In-Reply-To: <20261014150005.138309-1-roberto.sassu@huaweicloud.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] ima: off-by-one in ima_validate_range bypasses memory boundary check
--
commit 7ddca2cd41824acc187deeda05f385f27ac90508
Author: Roberto Sassu <roberto.sassu@huawei.com>
kexec: Select ima_get/free_kexec_buffer() with CONFIG_HAVE_IMA_KEXEC(_OF)
This commit introduces CONFIG_HAVE_IMA_KEXEC_OF and selects it for
architectures using the device tree implementation for IMA kexec buffers.
It also modifies x86 to use its own setup_data-based implementation
regardless of CONFIG_OF_FLATTREE.
> diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
> index cda6adb9f69c4..bc17e353c0992 100644
> --- a/arch/x86/kernel/setup.c
> +++ b/arch/x86/kernel/setup.c
[ ... ]
> @@ -421,7 +421,7 @@ static void __init add_early_ima_buffer(u64 phys_addr)
> #endif
> }
>
> -#if defined(CONFIG_HAVE_IMA_KEXEC) && !defined(CONFIG_OF_FLATTREE)
> +#ifdef CONFIG_HAVE_IMA_KEXEC
> int __init ima_free_kexec_buffer(void)
> {
[Severity: High]
Does enabling this on x86 expose an off-by-one regression in how IMA validates
the memory range?
In security/integrity/ima/ima_kexec.c:ima_validate_range(), the end_pfn is
calculated inclusively:
end_phys = phys + size - 1;
end_pfn = PHYS_PFN(end_phys);
However, on x86, this inclusive end_pfn is passed to pfn_range_is_mapped():
if (!pfn_range_is_mapped(start_pfn, end_pfn))
Looking at arch/x86/mm/init.c:pfn_range_is_mapped(), it expects an exclusive
end_pfn boundary, checking if the region is within pfn_mapped[i]:
if ((start_pfn >= pfn_mapped[i].start) &&
(end_pfn <= pfn_mapped[i].end))
Because ima_validate_range() passes an inclusive PFN, the validated range is
effectively one page smaller than the actual buffer. If the actual buffer
extends exactly one page beyond the valid mapped memory, could
pfn_range_is_mapped() incorrectly return true?
Would the subsequent direct map access via __va(ima_kexec_buffer_phys) up
to size hit the unmapped page, resulting in an out-of-bounds access
during boot?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261014150005.138309-1-roberto.sassu@huaweicloud.com?part=1
prev parent reply other threads:[~2026-10-14 15:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 15:00 [PATCH] kexec: Select ima_get/free_kexec_buffer() with CONFIG_HAVE_IMA_KEXEC(_OF) Roberto Sassu
2026-10-14 15:12 ` sashiko-bot [this message]
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=sashiko-outbox-171460@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=roberto.sassu@huaweicloud.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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