lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <95bd5396-256c-58c6-62ab-ae95e0cf371c@huawei.com>
Date: Thu, 5 Feb 2026 11:25:53 +0800
From: Miaohe Lin <linmiaohe@...wei.com>
To: Zi Yan <ziy@...dia.com>, David Hildenbrand <david@...nel.org>
CC: Andrew Morton <akpm@...ux-foundation.org>, Lorenzo Stoakes
	<lorenzo.stoakes@...cle.com>, "Liam R. Howlett" <Liam.Howlett@...cle.com>,
	Vlastimil Babka <vbabka@...e.cz>, Mike Rapoport <rppt@...nel.org>, "Suren
 Baghdasaryan" <surenb@...gle.com>, Michal Hocko <mhocko@...e.com>, "Naoya
 Horiguchi" <nao.horiguchi@...il.com>, Harry Yoo <harry.yoo@...cle.com>,
	"Matthew Wilcox (Oracle)" <willy@...radead.org>, Yu Zhao <yuzhao@...gle.com>,
	Baolin Wang <baolin.wang@...ux.alibaba.com>, Wei Yang
	<richard.weiyang@...il.com>, <linux-mm@...ck.org>,
	<linux-kernel@...r.kernel.org>, 是参差 <shicenci@...il.com>
Subject: Re: [PATCH] mm/memory_failure: reject unsupported non-folio compound
 page

On 2026/2/5 8:56, Zi Yan wrote:
> When !CONFIG_TRANSPARENT_HUGEPAGE, a non-folio compound page can appear in
> a userspace mapping via either vm_insert_*() functions or
> vm_operatios_struct->fault(). They are not folios, thus should not be
> considered for folio operations like split. Change memory_failure() and
> soft_offline_page() to reject these non-folio compound pages as
> EOPNOTSUPP.
> 
> Add PageNonFolioCompound() helper function. This function is functionally
> equivalent to folio_test_large() && !folio_test_large_rmappable(), but it
> is supposed to be used on struct page. So open code it instead.
> 
> Fixes: 689b8986776c ("mm/memory-failure: improve large block size folio handling")
> Reported-by: 是参差 <shicenci@...il.com>
> Closes: https://lore.kernel.org/all/PS1PPF7E1D7501F1E4F4441E7ECD056DEADAB98A@PS1PPF7E1D7501F.apcprd02.prod.outlook.com/
> Signed-off-by: Zi Yan <ziy@...dia.com>
> ---
>  include/linux/page-flags.h | 16 ++++++++++++++++
>  mm/memory-failure.c        |  9 ++++++---
>  2 files changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index f7a0e4af0c73..2fe8047f42a3 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -1102,6 +1102,22 @@ static inline bool folio_contain_hwpoisoned_page(struct folio *folio)
>  
>  bool is_free_buddy_page(const struct page *page);
>  
> +static inline bool PageNonFolioCompound(const struct page *page)
> +{
> +	if (PageCompound(page)) {
> +		const struct page *head = compound_head(page);
> +
> +		/*
> +		 * Without CONFIG_TRANSPARENT_HUGEPAGE, PG_large_rmappable
> +		 * should not be set/used.
> +		 */
> +		return !IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) ||
> +		       !test_bit(PG_large_rmappable, &head[1].flags.f);
> +	}
> +
> +	return false;
> +}
> +
>  #ifdef CONFIG_MIGRATION
>  /*
>   * This page is migratable through movable_ops (for selected typed pages
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index cf0d526e6d41..8b6b5950bb66 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -2440,9 +2440,12 @@ int memory_failure(unsigned long pfn, int flags)
>  
>  	folio = page_folio(p);
>  
> -	/* filter pages that are protected from hwpoison test by users */
> +	/*
> +	 * filter pages that are protected from hwpoison test by users or
> +	 * unsupported non folio compound ones
> +	 */
>  	folio_lock(folio);
> -	if (hwpoison_filter(p)) {
> +	if (hwpoison_filter(p) || PageNonFolioCompound(p)) {
>  		ClearPageHWPoison(p);
>  		folio_unlock(folio);
>  		folio_put(folio);
> @@ -2945,7 +2948,7 @@ int soft_offline_page(unsigned long pfn, int flags)
>  	ret = get_hwpoison_page(page, flags | MF_SOFT_OFFLINE);
>  	put_online_mems();
>  
> -	if (hwpoison_filter(page)) {
> +	if (hwpoison_filter(page) || PageNonFolioCompound(page)) {

There should be no problem in soft_offline_page(). HWPoisonHandlable() check will be used
by get_hwpoison_page() to reject PageNonFolioCompound folios. Or am I miss something?

Thanks.
.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ