From patchwork Tue Jul 11 05:50:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13308136 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 E070EC001DF for ; Tue, 11 Jul 2023 05:50:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26C648D0003; Tue, 11 Jul 2023 01:50:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1ABCE8E0003; Tue, 11 Jul 2023 01:50:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9E4A8D0002; Tue, 11 Jul 2023 01:50:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id AB0568E0003 for ; Tue, 11 Jul 2023 01:50:10 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6BC738010C for ; Tue, 11 Jul 2023 05:50:10 +0000 (UTC) X-FDA: 80998255380.22.F093003 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf08.hostedemail.com (Postfix) with ESMTP id 049F8160003 for ; Tue, 11 Jul 2023 05:50:07 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 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=1689054608; 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=c3+4PRVCOc8lFGp+68fWiH4guLJbERi3j/h49cE9di0=; b=L5JC4BdJ11WKc166vcpypERYMij/DFyhW0ls8n2lbhE3EJyKp4iqoeAPZEd2PHawTXuqf3 WVdTmG5W5EAZUgNehreMkqvwua3zHqJ0TUo0epW9bTnDlc6dhOioA6kEyYyoFlUHNh/3Nd qf8JJiAzN4QfmwLX1rr/mxbxg0v7Mvg= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689054608; a=rsa-sha256; cv=none; b=5w510g+0oDwn77Rj4P/P8XxOGs9qPF5/b/uREx6RlNB+NZHe8PhXoMaKEYZJJO1WzKeCHT qSjGXmMhOnlpakRL3YME5M+q4BH1Fzd58hzVYikrzb+DbunJgbCvR0E75S88gXwKZgeT6g WOWaJoeeDHV7Z3JnFQ6ZDdAd49iu7iw= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4R0VJb4QvVzPk2m; Tue, 11 Jul 2023 13:47:43 +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; Tue, 11 Jul 2023 13:50:02 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 2/8] mm: memory-failure: ensure moving HWPoison flag to the raw error pages Date: Tue, 11 Jul 2023 13:50:10 +0800 Message-ID: <20230711055016.2286677-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230711055016.2286677-1-linmiaohe@huawei.com> References: <20230711055016.2286677-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-Rspam-User: X-Stat-Signature: ecf6wkr8cm7ujx7zydxa1j3i7yra3ump X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 049F8160003 X-HE-Tag: 1689054607-352977 X-HE-Meta: U2FsdGVkX18XcsM29r3Oi3yJSTGO09NdlrGYX78/ymQzZ9cul5DCrD6zl33rbVVqMW6FdaIWt2vBcGHCmfkSUI9uBvgfUekWy5v09lP3uvCorHktIMSWI3vry0lKx00Ahu39aoWOEiTfMmDhnXxxqcIStaU3e0l1vNEUHLEeCMuAaETgm4TVGygQCJ7Lzj9mmHL19xotI/vylyQr64cc4aIkp+Jeb6QVxYn7lguq7HNFg8R14CCtVsDJMnbmH9j6uhOFbRYbcO0s9DpyTTNL26lDYY10BLBV9HRng3LNSMCYf9qVIBU2hpA5xuR8lDLg9rQpNvTz3VX8ak6noFZ4lwOooHms9A+sH+A/q2JU6ijlcbAyyTRtR4AIX1fvCE+Bc0V1cstdcjiSRJ6XHYVJIZL6nsVRmm6M76r00gmqGoAr6ZeY/dMg9VK8rsIQeGy9mLZv9O8Hu0fxocJ13tYOP4+vV9S+PwLnZ1V76K7mcXR13Qp4s6H/6sSpJRlHFk/WSodlxWzFazBcVGy5I9/G/bJjiKG1PHWlNBDYuRxkoZBCnxram83hPaLbiUV23VNv9E7Yo5R63U6brSmT8LVkAKAk/msxIuO1QIrAJRjFlKneUoIXD25opnXhWGgcJEbSc7kuRDWMgFiqWsW99bViD/rg62l+PkRDOfHWK+FGmRiugQ4z9y3qZfVu+HwsVbRV3rKL7KKcGc4gMpJjUEpABLD+87tvfPWFTJXjNdl/XF0O75/J2UOSuMX/kTn2SoTAyoRuWTMBHB4K/WtC4mxdi2kSLmoDMgly7k7N2LKHgHFSQf+nIYvgGld4m7TzpuV21EWaWTxSOxdhT4zD3ZoYWmoT03OgqlelI9jKwCEfijHHjxTRbigG3CttAtUZbWDCTOdIhci2McoQ3mlukNPTZPjL4i9QXqnvOHXOWw7HE2LGwhgNJcNV0JKUUh8BiYObyxvQvZrwSFcnomnJn2g q1L/QIl1 qlAICFrCfIG1Z/4smsSYuwiZCzVUOk6R9+wUg2GXz1nUjXNOXXj8WnhmdnP+bUgU+2xB8KHeSRia7W4C6cloWnXcWbhavMzsLr2Vk21RJuVCTW2ea5E8817FLmO73Vs5xjcgZuEbI0rEUSYmbuIJfoRpXCjVRFKzVrO/5gKZXw/2AFI4= 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: If hugetlb_vmemmap_optimized is enabled, folio_clear_hugetlb_hwpoison() called from try_memory_failure_hugetlb() won't transfer HWPoison flag to subpages while folio's HWPoison flag is cleared. So when trying to free this hugetlb page into buddy, folio_clear_hugetlb_hwpoison() is not called to move HWPoison flag from head page to the raw error pages even if now hugetlb_vmemmap_optimized is cleared. This will results in HWPoisoned page being used again and raw_hwp_page leak. Fixes: ac5fcde0a96a ("mm, hwpoison: make unpoison aware of raw error info in hwpoisoned hugepage") Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 913fcf02ad38..feca3c4068a5 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1920,6 +1920,8 @@ void folio_clear_hugetlb_hwpoison(struct folio *folio) { if (folio_test_hugetlb_raw_hwp_unreliable(folio)) return; + if (folio_test_hugetlb_vmemmap_optimized(folio)) + return; folio_clear_hwpoison(folio); folio_free_raw_hwp(folio, true); }