From nobody Sun Feb 8 09:22:29 2026 Received: from canpmsgout07.his.huawei.com (canpmsgout07.his.huawei.com [113.46.200.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D581535CBB3 for ; Thu, 5 Feb 2026 07:43:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.222 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770277392; cv=none; b=sVVH+2TdNZK73R50aZiqq+3PI2SBXm+aNX6H0FNKRWZpMksyQhMWnXrpi8VCy+2tsvVouDkDSe+7ju5AL1hGi9yMFQR+4RVHptZWRfAOcOGtaRADWKPhz3il3K1651BmCItTJTsYiwB/jWJYMr9ytG5bXveoAtfdDkpDGC2jBow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770277392; c=relaxed/simple; bh=ezWHN5QGpO1rKKYFlGdEIBaAkrpLSY6fArdy8KwL+Z4=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=tJejNNvv5kmwPljHHT/wurgt35OMrIltmqoFY805UBfFbVRjqd74axagV29nUgEimiA3qjcpRrWzAkJbPPUtQc4QexlEZVmSScSgPD6dpCHjqFuQWwja/kzqvT5mcv+e5+SUmDZ/OysXx/TJDnbI+9WXzFz6xvO5veHGUK7D3Ck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=z0hFhj2S; arc=none smtp.client-ip=113.46.200.222 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="z0hFhj2S" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=2sEkyTYoXLoqsCh2Me8BmcoslamYjRf5TkQkVIJnLIE=; b=z0hFhj2SHpZLKHA0QzfvcJemSPOdSmSlDHv3pAJRdH/3jL0YqMgP3a5ZzAnxj4fFQawthP+oE NsWol7eY67E5r0IKVaxL2vr6pOuqaRywRthIvcvHNGEdq9WtiJLcebPCRfb43ySlqoJt+g+zzK0 hacammfPG8wiKV2ChdpDXhU= Received: from mail.maildlp.com (unknown [172.19.163.200]) by canpmsgout07.his.huawei.com (SkyGuard) with ESMTPS id 4f68GX24SLzLls7; Thu, 5 Feb 2026 15:38:28 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id CFB8640563; Thu, 5 Feb 2026 15:43:02 +0800 (CST) Received: from kwepemq500010.china.huawei.com (7.202.194.235) by dggemv705-chm.china.huawei.com (10.3.19.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 5 Feb 2026 15:43:02 +0800 Received: from huawei.com (10.173.125.37) by kwepemq500010.china.huawei.com (7.202.194.235) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 5 Feb 2026 15:43:01 +0800 From: Miaohe Lin To: CC: , , , , , , , Subject: [PATCH] mm/memory-failure: reject unsupported non-folio compound page Date: Thu, 5 Feb 2026 15:53:28 +0800 Message-ID: <20260205075328.523211-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems200002.china.huawei.com (7.221.188.68) To kwepemq500010.china.huawei.com (7.202.194.235) 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. Fixes: 689b8986776c ("mm/memory-failure: improve large block size folio han= dling") Reported-by: =E6=98=AF=E5=8F=82=E5=B7=AE Closes: https://lore.kernel.org/all/PS1PPF7E1D7501F1E4F4441E7ECD056DEADAB98= A@PS1PPF7E1D7501F.apcprd02.prod.outlook.com/ Reviewed-by: Zi Yan Tested-by: Zi Yan Signed-off-by: Miaohe Lin [Some commit log borrowed from Zi Yan . Thanks.] Reviewed-by: Jane Chu --- mm/memory-failure.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 825c706ac576..ba4231858a36 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2411,31 +2411,29 @@ 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 =3D get_hwpoison_page(p, flags); - if (!res) { - if (is_free_buddy_page(p)) { - if (take_page_off_buddy(p)) { - page_ref_inc(p); - res =3D MF_RECOVERED; - } else { - /* We lost the race, try again */ - if (retry) { - ClearPageHWPoison(p); - retry =3D false; - goto try_again; - } - res =3D MF_FAILED; - } - res =3D action_result(pfn, MF_MSG_BUDDY, res); + res =3D get_hwpoison_page(p, flags); + if (!res) { + if (is_free_buddy_page(p)) { + if (take_page_off_buddy(p)) { + page_ref_inc(p); + res =3D MF_RECOVERED; } else { - res =3D action_result(pfn, MF_MSG_KERNEL_HIGH_ORDER, MF_IGNORED); + /* We lost the race, try again */ + if (retry) { + ClearPageHWPoison(p); + retry =3D false; + goto try_again; + } + res =3D MF_FAILED; } - goto unlock_mutex; - } else if (res < 0) { - res =3D action_result(pfn, MF_MSG_GET_HWPOISON, MF_IGNORED); - goto unlock_mutex; + res =3D action_result(pfn, MF_MSG_BUDDY, res); + } else { + res =3D action_result(pfn, MF_MSG_KERNEL_HIGH_ORDER, MF_IGNORED); } + goto unlock_mutex; + } else if (res < 0) { + res =3D action_result(pfn, MF_MSG_GET_HWPOISON, MF_IGNORED); + goto unlock_mutex; } =20 folio =3D page_folio(p); --=20 2.33.0