From patchwork Sat Jul 15 03:17:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13314365 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0A39C001DC for ; Sat, 15 Jul 2023 03:17:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E78E6B0072; Fri, 14 Jul 2023 23:17:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 021236B0074; Fri, 14 Jul 2023 23:17:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2C106B0075; Fri, 14 Jul 2023 23:17:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D27B96B0072 for ; Fri, 14 Jul 2023 23:17:26 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9D4BB803FB for ; Sat, 15 Jul 2023 03:17:26 +0000 (UTC) X-FDA: 81012385692.18.6FD900C Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf10.hostedemail.com (Postfix) with ESMTP id 272E4C0006 for ; Sat, 15 Jul 2023 03:17:23 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689391044; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iNQXzd4KrKutBsaSbfiDpnDpOW4z1ROINKZ0mOvwm/U=; b=WPg2/LGQFE9QvjiAYCQ3HaAUOZxkLNxzXlDYQ7jpJXV6wgOA1jrX3JMg3+56i+cmSGHqJQ wYawIUA3rtlZCJCApEF7D4V/Kg4KjEJj1aCuLJ20nZK1IJkQOXNIki79+CUmrgBAQLMjqE eOFaS4n84Mq/YuQElLjA1e1A0qCbEz8= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689391044; a=rsa-sha256; cv=none; b=uL1hENKbn7p/Eb6EEELY3cN0PAHROvBuKbaAZOJFpA4l9zGm0mFGkZ8mU70SrhrvxVY1IR EULhdqqUMSpLo0VCejluuOa0Qz+zlkhtMMb67WRwRp1pJsUS2QMTnGUeg2jyU5X4vNG0yy aqDqxQ/7cHbWVw7wkf6DT/qKBB+4BgM= 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 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 X-Rspamd-Queue-Id: 272E4C0006 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: sf194xjqtix44z9m71zs74xyebb1tuh1 X-HE-Tag: 1689391043-123789 X-HE-Meta: U2FsdGVkX1+1erhli6KTe9n4C178ssbYORQDnS2HRRxAF1p3ZnMbyGlW3eUCIOTQuT0sos4ruRL/VaGurOi4TA7kLg12EBhO5I5KqZ0XE59LJ1LYoAjphY+q8/aI3H2IrUzWYluUMt49qAUUmPIWwbtsXXR8HH+8Fd7DX6NlVNJVST7sodB8E6p6kVq7OKOib/sv8HugYGGkGRf3BFt+sCdRW76qR1rE65uCttVjnqi+sO5nYCrozk8zhjn4YTJ19M6TwHy9LA8c17ujHnoL8hyyh80uIQ4iOq2341ZO2PQ3xE+DxmcgbTaCjdWPJ4tXN77Q22If52DzPgIIAfh8RVhfU37EFc2rLTOyovAJK2k9MceKLWIC4IHP/WOPqftKB/gHwJ6xkDjJdwquOjR+2ZG9NmwNnY0DthOiUjEYCoZM8e0ZC4IYF5jbRq3ooHRuEOgSYKlSdlPNPddgYLRs5mOTnCJUbu0nNO8xn8VPEjIlyplUN88r8pZmf+ohY/rdO2IuV9uprXGbPFNi2nNcyGFbLD5/I2x5QMgmylHX/rLsTLjUYwp6hJtiXjld4cJxkOozxiKcj5WAFJAMvt1w0W/YLevCdu5Ojg0l1MUKGQaHJYIm+K2ooV5iYmMSGrR6uehoN5/3H3JkGTTaw5eMEgG+hfS0X+hId3klgoUClPO6Zc43DpyiOOoWEIhcASijUHpjzIa2s0lcpADUZatM9L0prXVOMG3UQgbBV14Wm6yHqbQRapNAnSbv7PoQDWehOAthg3BfxfS5SdibGEdYnObg3UgNjLZ+zEHBlLY6BtxHNrBoHfH2fez0W89K6FzyzfU39LECXNH1yhPMtaZYEHUmkrUZoIVTA9cbOF/4Gvng7hJc9TkACAINHba6AKmcRLMXXJBAPcdxDW4tPZGYKaGVj3fD6wT4L968V1m+vEQaJhxUtC5ah/Q9F7U2AYTtvKGHN+mvTtvk1dw/4HA J199VtGh Mb2P6elQiw2R11CRyLy9D6vJe2UEdoXqnHWYVr/JdCQKoe1DJUy5gTtj7nztwBnLXp5NjEo5hvD26AoirOVmZMQLAMRNffzhAK14EGY5ndlFUYuE3zNjMQfaWbYCD7Q1Lfx8vHEhNw9SIuIU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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; dec_mm_counter(vma->vm_mm, MM_SWAPENTS); - if (hwposioned) { + /* Hwpoisoned swapcache page is also !PageUptodate. */ + if (hwposioned || PageHWPoison(page)) { swp_entry = make_hwpoison_entry(swapcache); page = swapcache; } else {