From: Oscar Salvador <osalvador@suse.de>
To: Miaohe Lin <linmiaohe@huawei.com>
Cc: akpm@linux-foundation.org, muchun.song@linux.dev,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/hugetlb: fix potential race in __update_and_free_hugetlb_folio()
Date: Mon, 8 Jul 2024 10:24:11 +0200 [thread overview]
Message-ID: <ZouiK8Fm5RGNpwSb@localhost.localdomain> (raw)
In-Reply-To: <20240708025127.107713-1-linmiaohe@huawei.com>
On Mon, Jul 08, 2024 at 10:51:27AM +0800, Miaohe Lin wrote:
> There is a potential race between __update_and_free_hugetlb_folio() and
> try_memory_failure_hugetlb():
>
> CPU1 CPU2
> __update_and_free_hugetlb_folio try_memory_failure_hugetlb
> folio_test_hugetlb
> -- It's still hugetlb folio.
> folio_clear_hugetlb_hwpoison
> spin_lock_irq(&hugetlb_lock);
> __get_huge_page_for_hwpoison
> folio_set_hugetlb_hwpoison
> spin_unlock_irq(&hugetlb_lock);
> spin_lock_irq(&hugetlb_lock);
> __folio_clear_hugetlb(folio);
> -- Hugetlb flag is cleared but too late.
> spin_unlock_irq(&hugetlb_lock);
>
> When above race occurs, raw error page info will be leaked. Even worse,
> raw error pages won't have hwpoisoned flag set and hit pcplists/buddy.
> Fix this issue by deferring folio_clear_hugetlb_hwpoison() until
> __folio_clear_hugetlb() is done. So all raw error pages will have
> hwpoisoned flag set.
>
> Fixes: 32c877191e02 ("hugetlb: do not clear hugetlb dtor until allocating vmemmap")
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> Cc: <stable@vger.kernel.org>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
--
Oscar Salvador
SUSE Labs
prev parent reply other threads:[~2024-07-08 8:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-08 2:51 Miaohe Lin
2024-07-08 7:08 ` Muchun Song
2024-07-08 8:24 ` Oscar Salvador [this message]
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=ZouiK8Fm5RGNpwSb@localhost.localdomain \
--to=osalvador@suse.de \
--cc=akpm@linux-foundation.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
/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