Re: [PATCH] mm/memory: don't map hardware-poisoned pages in finish_fault()

From: Zi Yan

Date: Thu Nov 19 2026 - 09:26:39 EST


On 19 Nov 2026, at 8:42, Kiryl Shutsemau (Meta) wrote:

> When memory_failure() cannot split a large file folio, the folio stays in
> the page cache with the poisoned page in it. do_set_pmd() refuses to map
> such a folio with a PMD, so that the poisoned page gets its own fault and
> SIGBUS. finish_fault() then falls back to PTEs, but maps the whole folio:
>
> do_shared_fault()
> __do_fault()
> PageHWPoison(vmf->page)
> // the faulting page only
> finish_fault()
> do_set_pmd()
> // backs off on has_hwpoisoned
> set_pte_range(vmf, folio, &folio->page, folio_nr_pages(folio), ...)
> // maps the poisoned page as well
>
> A process that touches the poisoned page takes a machine check instead
> of SIGBUS from the fault.
>
> Map a folio with a poisoned page one page at a time. The poisoned page
> then takes its own fault, which __do_fault() turns into SIGBUS.
>
> Fixes: 43e027e41423 ("mm: memory: extend finish_fault() to support large folio")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
> ---
> Found while reviewing Usama's fix for the swap-in side:
> https://patch.msgid.link/20261116063624.1382944-3-usama.arif@xxxxxxxxx
>
> Reproduced on a huge=always tmpfs, with a THP that vmsplice() keeps
> memory_failure() from splitting. A write fault on a good page of the
> folio maps all 512 PTEs, the poisoned page included. With the patch it
> maps the faulting page only.
>
> mm/memory.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
LGTM. Thanks.

Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>

Best Regards,
Yan, Zi