From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,ziy@nvidia.com,yuzhao@google.com,
willy@infradead.org,tz2294@columbia.edu,stable@vger.kernel.org,
rppt@kernel.org,osalvador@suse.de,nao.horiguchi@gmail.com,
muchun.song@linux.dev,mike.kravetz@oracle.com,linmiaohe@huawei.com,
kaitao.cheng@linux.dev,jane.chu@oracle.com,david@kernel.org,
mt4022@columbia.edu,akpm@linux-foundation.org
Subject: + mm-memory-failure-dont-unpoison-a-leaked-raw_hwp_unreliable-folio.patch added to mm-new branch
Date: Wed, 18 Nov 2026 23:07:04 -0800 [thread overview]
Message-ID: <20261119070705.260EF1F000C4@smtp.kernel.org> (raw)
In-Reply-To: <20261103-hugetlb-hwpoison-leak-v2-1-98085750c145@columbia.edu>
The patch titled
Subject: mm/memory-failure: don't unpoison a leaked raw_hwp_unreliable folio
has been added to the -mm mm-new branch. Its filename is
mm-memory-failure-dont-unpoison-a-leaked-raw_hwp_unreliable-folio.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-memory-failure-dont-unpoison-a-leaked-raw_hwp_unreliable-folio.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Mani Tofigh <mt4022@columbia.edu>
Subject: mm/memory-failure: don't unpoison a leaked raw_hwp_unreliable folio
Date: Tue, 03 Nov 2026 16:00:49 -0500
Patch series "mm/hugetlb: clear the hugetlb flag before leaking a
hwpoisoned folio", v2.
If memory_failure() can't save the raw error page of a hugetlb folio,
the folio is marked raw_hwp_unreliable and leaked once it's freed. With
hugetlb_free_vmemmap=on it's leaked while it's still a hugetlb folio,
and dissolving it then loops forever, e.g., when offlining its memory
block. Patch 2 leaks it only after the hugetlb flag is cleared, as
without vmemmap optimization.
Miaohe pointed out that unpoison_memory() then doesn't see a hugetlb
folio anymore and unpoisons it. That already happens without vmemmap
optimization, so patch 1 fixes it on its own and goes first.
Patch 2 lets a raw_hwp_unreliable folio reach the add_hugetlb_folio()
rollback when restoring its vmemmap fails, as
dissolve_free_hugetlb_folio() already does. It relies on Kaitao's
"mm/hugetlb: preserve persistent flags when returning folios to the
pool" [1] to keep the flag there.
Reproducer:
https://github.com/manitofigh/files/blob/main/linux-repros/hugeoffline.c
This patch (of 2):
If memory_failure() can't save the raw error page of a hugetlb folio,
it marks the folio raw_hwp_unreliable and unpoison_memory() refuses to
unpoison it, since we don't know which subpages are poisoned. Once the
folio is freed, __update_and_free_hugetlb_folio() leaks it on purpose.
If its hugetlb flag is cleared by then, e.g., without vmemmap
optimization, unpoison_memory() doesn't see a hugetlb folio anymore.
It treats the leaked folio as a normal page and clears PG_hwpoison on
its head, while the poisoned subpages are still unknown.
The leaked folio is still a large folio and raw_hwp_unreliable stays set
in folio->private. We now check it on any large folio before taking the
page, so unpoison_memory() refuses the folio whether it's still hugetlb
or not. With the fix, it returns -EBUSY for the leaked folio as it did
before the folio was freed.
Link: https://lore.kernel.org/20261103-hugetlb-hwpoison-leak-v2-0-98085750c145@columbia.edu
Link: https://patch.msgid.link/20261103-hugetlb-hwpoison-leak-v2-1-98085750c145@columbia.edu
Link: https://lore.kernel.org/all/20261102024910.31486-3-kaitao.cheng@linux.dev/ [1]
Fixes: ac5fcde0a96a ("mm, hwpoison: make unpoison aware of raw error info in hwpoisoned hugepage")
Signed-off-by: Mani Tofigh <mt4022@columbia.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Miaohe Lin <linmiaohe@huawei.com>
Closes: https://lore.kernel.org/all/ae6058ae-3703-a1d5-d82f-4102b46f227b@huawei.com/
Acked-by: Miaohe Lin <linmiaohe@huawei.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: David Hildenbrand <david@kernel.org>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Jane Chu <jane.chu@oracle.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Kaitao Cheng <kaitao.cheng@linux.dev>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Yu Zhao <yuzhao@google.com>
Cc: Tal Zussman <tz2294@columbia.edu>
Cc: <stable@vger.kernel.org>
mm/memory-failure.c | 9 +++++++++
1 file changed, 9 insertions(+)
--- a/mm/memory-failure.c~mm-memory-failure-dont-unpoison-a-leaked-raw_hwp_unreliable-folio
+++ a/mm/memory-failure.c
@@ -2812,6 +2812,15 @@ int unpoison_memory(unsigned long pfn)
goto unlock_mutex;
}
+ /*
+ * A hugetlb folio without reliable raw error info is leaked once it
+ * is freed, and its hugetlb flag may be cleared by then. Check the
+ * flag in folio->private, which stays set on the leaked folio.
+ */
+ if (folio_test_large(folio) &&
+ folio_test_hugetlb_raw_hwp_unreliable(folio))
+ goto unlock_mutex;
+
ghp = get_hwpoison_page(p, MF_UNPOISON);
if (!ghp) {
guard(vmemmap_remap)();
_
Patches currently in -mm which might be from mt4022@columbia.edu are
mm-swapfile-drop-a-large-unmapped-swap-in-folio-in-unuse_pte.patch
mm-memory-failure-dont-unpoison-a-leaked-raw_hwp_unreliable-folio.patch
mm-hugetlb-clear-the-hugetlb-flag-before-leaking-a-hwpoisoned-folio.patch
next prev parent reply other threads:[~2026-11-19 7:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 21:00 [PATCH v2 0/2] mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio Mani Tofigh via B4 Relay
2026-11-03 21:00 ` [PATCH v2 1/2] mm/memory-failure: don't unpoison a leaked raw_hwp_unreliable folio Mani Tofigh via B4 Relay
2026-11-19 6:39 ` Miaohe Lin
2026-11-19 7:11 ` Andrew Morton
2026-11-19 7:30 ` Miaohe Lin
2026-11-19 7:07 ` Andrew Morton [this message]
2026-11-03 21:00 ` [PATCH v2 2/2] mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio Mani Tofigh via B4 Relay
2026-11-19 6:40 ` Miaohe Lin
2026-11-19 7:07 ` + mm-hugetlb-clear-the-hugetlb-flag-before-leaking-a-hwpoisoned-folio.patch added to mm-new branch Andrew Morton
2026-11-19 7:06 ` [PATCH v2 0/2] mm/hugetlb: clear the hugetlb flag before leaking a hwpoisoned folio Andrew Morton
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=20261119070705.260EF1F000C4@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=jane.chu@oracle.com \
--cc=kaitao.cheng@linux.dev \
--cc=linmiaohe@huawei.com \
--cc=mike.kravetz@oracle.com \
--cc=mm-commits@vger.kernel.org \
--cc=mt4022@columbia.edu \
--cc=muchun.song@linux.dev \
--cc=nao.horiguchi@gmail.com \
--cc=osalvador@suse.de \
--cc=rppt@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tz2294@columbia.edu \
--cc=willy@infradead.org \
--cc=yuzhao@google.com \
--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