Commit ae9fd76c authored by Miaohe Lin's avatar Miaohe Lin Committed by Andrew Morton
Browse files

mm/memory-failure: reject unsupported non-folio compound page

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.  To reject these pages, make
sure get_hwpoison_page() is always called as HWPoisonHandlable() will do
the right work.

[Some commit log borrowed from Zi Yan. Thanks.]

Link: https://lkml.kernel.org/r/20260205075328.523211-1-linmiaohe@huawei.com


Fixes: 689b8986 ("mm/memory-failure: improve large block size folio handling")
Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Reported-by: default avatar是参差 <shicenci@gmail.com>
Closes: https://lore.kernel.org/all/PS1PPF7E1D7501F1E4F4441E7ECD056DEADAB98A@PS1PPF7E1D7501F.apcprd02.prod.outlook.com/


Reviewed-by: default avatarZi Yan <ziy@nvidia.com>
Tested-by: default avatarZi Yan <ziy@nvidia.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Jane Chu <jane.chu@oracle.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent b5cbacd7
Loading
Loading
Loading
Loading
+20 −22
Original line number Diff line number Diff line
@@ -2411,7 +2411,6 @@ int memory_failure(unsigned long pfn, int flags)
	 * In fact it's dangerous to directly bump up page count from 0,
	 * that may make page_ref_freeze()/page_ref_unfreeze() mismatch.
	 */
	if (!(flags & MF_COUNT_INCREASED)) {
	res = get_hwpoison_page(p, flags);
	if (!res) {
		if (is_free_buddy_page(p)) {
@@ -2436,7 +2435,6 @@ int memory_failure(unsigned long pfn, int flags)
		res = action_result(pfn, MF_MSG_GET_HWPOISON, MF_IGNORED);
		goto unlock_mutex;
	}
	}

	folio = page_folio(p);