From nobody Mon Feb 9 12:09:00 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C174EB64DC for ; Sat, 15 Jul 2023 03:17:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229832AbjGODRd (ORCPT ); Fri, 14 Jul 2023 23:17:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbjGODRY (ORCPT ); Fri, 14 Jul 2023 23:17:24 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 492133A84 for ; Fri, 14 Jul 2023 20:17:23 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4R2tjQ0L4lzNm6c; Sat, 15 Jul 2023 11:14:02 +0800 (CST) Received: from huawei.com (10.174.151.185) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Sat, 15 Jul 2023 11:17:19 +0800 From: Miaohe Lin To: , CC: , , , Subject: [PATCH 1/4] mm/swapfile: fix wrong swap entry type for hwpoisoned swapcache page Date: Sat, 15 Jul 2023 11:17:26 +0800 Message-ID: <20230715031729.2420338-2-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230715031729.2420338-1-linmiaohe@huawei.com> References: <20230715031729.2420338-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Hwpoisoned dirty swap cache page is kept in the swap cache and there's simple interception code in do_swap_page() to catch it. But when trying to swapoff, unuse_pte() will wrongly install a general sense of "future accesses are invalid" swap entry for hwpoisoned swap cache page due to unaware of such type of page. The user will receive SIGBUS signal without expected BUS_MCEERR_AR payload. Fixes: 6b970599e807 ("mm: hwpoison: support recovery from ksm_might_need_to= _copy()") Signed-off-by: Miaohe Lin --- mm/swapfile.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 346e22b8ae97..02f6808e65bf 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1767,7 +1767,8 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_= t *pmd, swp_entry_t swp_entry; =20 dec_mm_counter(vma->vm_mm, MM_SWAPENTS); - if (hwposioned) { + /* Hwpoisoned swapcache page is also !PageUptodate. */ + if (hwposioned || PageHWPoison(page)) { swp_entry =3D make_hwpoison_entry(swapcache); page =3D swapcache; } else { --=20 2.33.0