From: sashiko-bot@kernel.org
To: "H. Peter Anvin" <hpa@zytor.com>,
"Borislav Petkov" <bp@alien8.de>,
"Michal Hocko" <mhocko@suse.com>, "Zi Yan" <ziy@nvidia.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Breno Leitao" <leitao@debian.org>,
"David Hildenbrand" <david@kernel.org>,
"Naoya Horiguchi" <nao.horiguchi@gmail.com>,
"Liam R. Howlett" <liam@infradead.org>,
"Miaohe Lin" <linmiaohe@huawei.com>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Ard Biesheuvel" <ardb@kernel.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Thomas Gleixner" <tglx@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Brendan Jackman" <brendan.jackman@linux.dev>,
"Suren Baghdasaryan" <surenb@google.com>,
"Mike Rapoport" <rppt@kernel.org>,
x86@kernel.org, "Dave Hansen" <dave.hansen@linux.intel.com>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
kas@kernel.org
Cc: linux-kernel@vger.kernel.org, rmikey@meta.com, harry@kernel.org,
linux-mm@kvack.org, kernel-team@meta.com, riel@surriel.com,
kexec@lists.infradead.org, linux-efi@vger.kernel.org
Subject: Re: [PATCH v4 4/5] mm/memory-failure: efi: answer whether a range is poisoned
Date: Wed, 09 Sep 2026 13:17:18 +0000 [thread overview]
Message-ID: <20260909131719.5E1F01F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260909-hwpoison-kho-v4-4-359313564495@debian.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Adjusting `start` without proportionally shrinking `size` shifts the checked memory range out of bounds, causing false positive poison detection.
--
commit b492314fda14ef47eff8ff738b90a4749a490163
Author: Breno Leitao <leitao@debian.org>
mm/memory-failure: efi: answer whether a range is poisoned
This commit introduces range_contains_poisoned_memory() which allows the
page allocator to query whether a memory block overlaps with regions
recorded as poisoned by an earlier kernel via EFI.
> diff --git a/drivers/firmware/efi/poison.c b/drivers/firmware/efi/poison.c
> index c18edf111c710..e16d43f4438ee 100644
> --- a/drivers/firmware/efi/poison.c
> +++ b/drivers/firmware/efi/poison.c
[ ... ]
> +/* Does the range cover a unit an earlier kernel recorded as bad? */
> +bool range_contains_poisoned_memory(phys_addr_t start, unsigned long size)
> +{
> + struct linux_efi_poisoned_memory *pm = efi_poisoned_memory();
> + u64 first, last, nbits;
> +
> + if (!pm)
> + return false;
> +
> + nbits = pm->size * BITS_PER_BYTE;
> +
> + if (start + size <= pm->phys_base)
> + return false;
> + if (start < pm->phys_base)
> + start = pm->phys_base;
> +
> + first = (start - pm->phys_base) / pm->unit_size;
> + if (first >= nbits)
> + return false;
> +
> + last = (start + size - 1 - pm->phys_base) / pm->unit_size;
[Severity: High]
When start is clamped to pm->phys_base earlier in this function, size is
not proportionally decreased. Does this result in an end boundary calculation
that exceeds the originally requested range?
If the allocator queries a block that starts before the EFI poisoned memory
table (start < pm->phys_base) but extends into it, the unadjusted size added
to the newly shifted start will push the last bit beyond the intended region.
Could this out-of-bounds query cause false positive poison detections for
healthy memory that resides just after the requested block?
> + last = min(last, nbits - 1);
> +
> + return find_next_bit(pm->bitmap, last + 1, first) <= last;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909-hwpoison-kho-v4-0-359313564495@debian.org?part=4
next prev parent reply other threads:[~2026-09-09 13:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 13:05 [PATCH v4 0/5] mm/memory-failure: keep hardware-poisoned pages out of the next kexec Breno Leitao
2026-09-09 13:05 ` [PATCH v4 1/5] mm/memory-failure: efi: add the LINUX_EFI_POISONED_MEMORY configuration table Breno Leitao
2026-09-09 13:13 ` sashiko-bot
2026-09-09 13:05 ` [PATCH v4 2/5] mm/memory-failure: libstub: install the poisoned-memory EFI table Breno Leitao
2026-09-09 13:19 ` sashiko-bot
2026-09-09 14:00 ` Breno Leitao
2026-09-09 14:47 ` Ard Biesheuvel
2026-09-10 13:11 ` Breno Leitao
2026-09-09 13:05 ` [PATCH v4 3/5] mm/memory-failure: efi: record hardware-poisoned frames into the poisoned-memory table Breno Leitao
2026-09-09 13:21 ` sashiko-bot
2026-09-09 14:05 ` Breno Leitao
2026-09-09 13:05 ` [PATCH v4 4/5] mm/memory-failure: efi: answer whether a range is poisoned Breno Leitao
2026-09-09 13:17 ` sashiko-bot [this message]
2026-09-09 13:05 ` [PATCH v4 5/5] mm/memory-failure: keep inherited poisoned frames out of the buddy allocator Breno Leitao
2026-09-09 13:24 ` sashiko-bot
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=20260909131719.5E1F01F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=brendan.jackman@linux.dev \
--cc=dave.hansen@linux.intel.com \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=harry@kernel.org \
--cc=hpa@zytor.com \
--cc=ilias.apalodimas@linaro.org \
--cc=kas@kernel.org \
--cc=kernel-team@meta.com \
--cc=kexec@lists.infradead.org \
--cc=leitao@debian.org \
--cc=liam@infradead.org \
--cc=linmiaohe@huawei.com \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=nao.horiguchi@gmail.com \
--cc=riel@surriel.com \
--cc=rmikey@meta.com \
--cc=rppt@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=surenb@google.com \
--cc=tglx@kernel.org \
--cc=vbabka@kernel.org \
--cc=x86@kernel.org \
--cc=ziy@nvidia.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®