From: sashiko-bot@kernel.org
To: "Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Michal Hocko" <mhocko@suse.com>,
"Naoya Horiguchi" <nao.horiguchi@gmail.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
kas@kernel.org, "Vlastimil Babka" <vbabka@kernel.org>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
"David Hildenbrand" <david@kernel.org>,
"Breno Leitao" <leitao@debian.org>,
"Liam R. Howlett" <liam@infradead.org>,
"Brendan Jackman" <brendan.jackman@linux.dev>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Borislav Petkov" <bp@alien8.de>,
"Suren Baghdasaryan" <surenb@google.com>,
"Ard Biesheuvel" <ardb@kernel.org>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Mike Rapoport" <rppt@kernel.org>,
"Miaohe Lin" <linmiaohe@huawei.com>,
"Ingo Molnar" <mingo@redhat.com>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"Zi Yan" <ziy@nvidia.com>, "Thomas Gleixner" <tglx@kernel.org>
Cc: kernel-team@meta.com, rmikey@meta.com, harry@kernel.org,
linux-efi@vger.kernel.org, riel@surriel.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
kexec@lists.infradead.org
Subject: Re: [PATCH v4 3/5] mm/memory-failure: efi: record hardware-poisoned frames into the poisoned-memory table
Date: Wed, 09 Sep 2026 13:21:28 +0000 [thread overview]
Message-ID: <20260909132128.AD4D01F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260909-hwpoison-kho-v4-3-359313564495@debian.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing overflow check when computing the end address of the EFI poisoned memory table can lead to an unbounded memblock reservation and memory corruption.
--
commit 7216d7e029930900ac5741a5f5bbfe7a2107b408
Author: Breno Leitao <leitao@debian.org>
mm/memory-failure: efi: record hardware-poisoned frames into the poisoned-memory table
This commit hooks action_result() to efi_hwpoison_record_pfn() to record hard
offlined frames in the LINUX_EFI_POISONED_MEMORY table, ensuring they are
passed down to the next kernel via kexec. It also adds early initialization
code to vet the table inherited from previous boots.
> diff --git a/drivers/firmware/efi/poison.c b/drivers/firmware/efi/poison.c
> new file mode 100644
> index 0000000000000..c18edf111c710
> --- /dev/null
> +++ b/drivers/firmware/efi/poison.c
[ ... ]
> +static bool __init
> +efi_poison_geometry_valid(const struct linux_efi_poisoned_memory *pm)
> +{
> + u64 nbits;
> +
> + /* Whole words, and a bit count that can be taken without wrapping. */
> + if (!pm->size || !IS_ALIGNED(pm->size, sizeof(unsigned long)) ||
> + check_mul_overflow(pm->size, (u64)BITS_PER_BYTE, &nbits))
> + return false;
[Severity: High]
Does this validation fully protect against an excessively large pm->size?
While check_mul_overflow() validates the size for bit conversion, it appears
it does not verify that the table's footprint fits within the physical address
space without overflowing when combined with efi.poisoned_memory.
> +
> + if (pm->unit_size < PAGE_SIZE || !is_power_of_2(pm->unit_size))
> + return false;
> +
> + return IS_ALIGNED(pm->phys_base, pm->unit_size);
> +}
[ ... ]
> +void __init efi_poisoned_memory_reserve(void)
> +{
> + struct linux_efi_poisoned_memory *pm;
> + phys_addr_t start, end;
> +
> + if (efi.poisoned_memory == EFI_INVALID_TABLE_ADDR)
> + return;
> +
> + pm = early_memremap(efi.poisoned_memory, sizeof(*pm));
> + if (!pm) {
> + pr_warn("Could not map poisoned-memory table\n");
> + efi.poisoned_memory = EFI_INVALID_TABLE_ADDR;
> + return;
> + }
> +
> + if (!efi_poison_table_valid(pm)) {
> + efi.poisoned_memory = EFI_INVALID_TABLE_ADDR;
> + early_memunmap(pm, sizeof(*pm));
> + return;
> + }
> +
> + start = PAGE_ALIGN_DOWN(efi.poisoned_memory);
> + end = PAGE_ALIGN(efi.poisoned_memory + sizeof(*pm) + pm->size);
[Severity: High]
Can this computation wrap around if pm->size is maliciously large?
Because pm->size is only constrained to be less than U64_MAX / 8 in
efi_poison_geometry_valid(), an unvalidated addition here could overflow,
resulting in end < start. If that happens, an enormous end - start would
be passed to memblock_add() and memblock_reserve().
This could result in memblock capping the size to PHYS_ADDR_MAX - start,
blindly marking the rest of the physical address space (including MMIO) as
RAM. This forces direct-map cacheable page table entries for MMIO regions,
leading to system crashes or memory layout corruption.
> + early_memunmap(pm, sizeof(*pm));
> +
> + memblock_add(start, end - start);
> + memblock_reserve(start, end - start);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909-hwpoison-kho-v4-0-359313564495@debian.org?part=3
next prev parent reply other threads:[~2026-09-09 13:21 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 [this message]
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
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=20260909132128.AD4D01F00A3A@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.