mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com>
To: <mt4022@columbia.edu>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>,
	Matthew Wilcox <willy@infradead.org>,
	Jane Chu <jane.chu@oracle.com>, Zi Yan <ziy@nvidia.com>,
	Kaitao Cheng <kaitao.cheng@linux.dev>,
	Mike Rapoport <rppt@kernel.org>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	Yu Zhao <yuzhao@google.com>, <linux-mm@kvack.org>,
	<linux-kernel@vger.kernel.org>, <tz2294@columbia.edu>,
	<stable@vger.kernel.org>, Muchun Song <muchun.song@linux.dev>,
	Oscar Salvador <osalvador@suse.de>,
	David Hildenbrand <david@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v2 1/2] mm/memory-failure: don't unpoison a leaked raw_hwp_unreliable folio
Date: Thu, 19 Nov 2026 14:39:24 +0800	[thread overview]
Message-ID: <11f434ce-58c4-ff16-9c93-946a1e83eb10@huawei.com> (raw)
In-Reply-To: <20261103-hugetlb-hwpoison-leak-v2-1-98085750c145@columbia.edu>

On 2026/11/4 5:00, Mani Tofigh via B4 Relay wrote:
> From: Mani Tofigh <mt4022@columbia.edu>
> 
> 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.
> 
> Fixes: ac5fcde0a96a ("mm, hwpoison: make unpoison aware of raw error info in hwpoisoned hugepage")
> Reported-by: Miaohe Lin <linmiaohe@huawei.com>
> Closes: https://lore.kernel.org/all/ae6058ae-3703-a1d5-d82f-4102b46f227b@huawei.com/
> Cc: stable@vger.kernel.org
> Signed-off-by: Mani Tofigh <mt4022@columbia.edu>
> ---
>  mm/memory-failure.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index b215312f261b..496eacbefdf2 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -2809,6 +2809,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))

It might be better to add a unpoison_pr_info here?

> +		goto unlock_mutex;

Anyway, this patch LGTM:

Acked-by: Miaohe Lin <linmiaohe@huawei.com>

Thanks.
.

  reply	other threads:[~2026-11-19  6:39 UTC|newest]

Thread overview: 8+ 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 [this message]
2026-11-19  7:11     ` Andrew Morton
2026-11-19  7:30       ` Miaohe Lin
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:06 ` [PATCH v2 0/2] " 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=11f434ce-58c4-ff16-9c93-946a1e83eb10@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=jane.chu@oracle.com \
    --cc=kaitao.cheng@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --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

all inboxes | Powered by JetHome®