[PATCH v2 2/4] mm: don't PTE-batch a swap-in of a folio with a hardware-poisoned page
From: Usama Arif
Date: Mon Nov 16 2026 - 01:37:10 EST
do_swap_page() checks PageHWPoison() on the faulting page, but the
large-folio batching path then maps the rest of the folio without
looking at its other pages. A poisoned page that is not the one being
faulted gets mapped anyway, and the fault that would have reported it
never happens.
Skip batching for such an anon folio and let each page take its own
fault, where the existing check catches it. do_set_pmd() already backs
off the same way.
Leave a freshly read folio alone: it is not anon yet and can only be
mapped as a whole, and falling back would free it with the poisoned
page still in it, which the retried fault can then get back from the
page allocator.
Fixes: 508758960b8d ("mm: swap: entirely map large folios found in swapcache")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Usama Arif <usama.arif@xxxxxxxxx>
---
mm/memory.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/mm/memory.c b/mm/memory.c
index d477a4f986bc8..51e72fb40655f 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -5158,6 +5158,11 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
swap_pte_batch(folio_ptep, nr, folio_pte) != nr)
goto check_folio;
+ /* A poisoned page in the folio must take its own fault. */
+ if (folio_test_anon(folio) &&
+ folio_contain_hwpoisoned_page(folio))
+ goto check_folio;
+
page_idx = idx;
address = folio_start;
ptep = folio_ptep;
--
2.53.1-Meta