From patchwork Wed Mar 17 08:37:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?eWFvYWlsaSBb5LmI54ix5YipXQ==?= X-Patchwork-Id: 12145095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7884CC433DB for ; Wed, 17 Mar 2021 08:37:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 252D064F99 for ; Wed, 17 Mar 2021 08:37:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 252D064F99 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kingsoft.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A6F926B0070; Wed, 17 Mar 2021 04:37:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1E4A6B0071; Wed, 17 Mar 2021 04:37:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89A556B0073; Wed, 17 Mar 2021 04:37:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0156.hostedemail.com [216.40.44.156]) by kanga.kvack.org (Postfix) with ESMTP id 6AB026B0070 for ; Wed, 17 Mar 2021 04:37:24 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 27EF66139 for ; Wed, 17 Mar 2021 08:37:24 +0000 (UTC) X-FDA: 77928712008.16.05926A4 Received: from mail.kingsoft.com (mail.kingsoft.com [114.255.44.145]) by imf30.hostedemail.com (Postfix) with ESMTP id 74B1BE0011D9 for ; Wed, 17 Mar 2021 08:37:21 +0000 (UTC) X-AuditID: 0a580155-20dff7000005482e-d4-6051b80492ee Received: from mail.kingsoft.com (localhost [10.88.1.32]) (using TLS with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.kingsoft.com (SMG-2-NODE-85) with SMTP id A4.D4.18478.408B1506; Wed, 17 Mar 2021 16:04:20 +0800 (HKT) Received: from alex-virtual-machine (172.16.253.254) by KSBJMAIL2.kingsoft.cn (10.88.1.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 17 Mar 2021 16:37:14 +0800 Date: Wed, 17 Mar 2021 16:37:14 +0800 From: Aili Yao To: , CC: , , , , , Subject: [PATCH] mm/gup: check page posion status for coredump. Message-ID: <20210317163714.328a038d@alex-virtual-machine> Organization: kingsoft X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [172.16.253.254] X-ClientProxiedBy: KSBJMAIL1.kingsoft.cn (10.88.1.31) To KSBJMAIL2.kingsoft.cn (10.88.1.32) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGLMWRmVeSWpSXmKPExsXCFcGooMuyIzDB4N9yCYs569ewWVzeNYfN 4t6a/6wWFxsPMDqweGz6NInd48SM3yweL65uZPH4vEkugCWKyyYlNSezLLVI3y6BK+NL51Hm gnVcFRuOdLM0MC7g6GLk5JAQMJFYtGozcxcjF4eQwHQmiSt/1zBBOK8YJToOPmAFqWIRUJXY 9KWFEcRmA7J33ZsFFOfgEBGwkvhwUAiknllgHqPEljWHmUBqhAXsJf5M3QPWywtU09V0CKyX X0BMovfKfyaIzfYSbVsWMULUCEqcnPmEBcRmFtCROLHqGDOELS+x/e0cMFtIQFHi8JJf7BC9 ShJHumewQdixEsvmvWKdwCg4C8moWUhGzUIyagEj8ypGluLcdKNNjJCgDd3BOKPpo94hRiYO xkOMEhzMSiK8pnkBCUK8KYmVValF+fFFpTmpxYcYpTlYlMR5HSOBUgLpiSWp2ampBalFMFkm Dk6pBqaiVdy3hDx2P1rg2ybWPt3m2I9mwct8e9acePP1unDRkm+5xT5N/9wLEtltnNgrZeuy Vkodior89nqT1MqfHHpOG/r7TK1uTlx/ympPZdHkGwe0/06bcTh8QsaautVZvXGrf6euF11x e4KfxOKG5Ithc4PF3skd21G1dj7/nMoqrT1BzdPiz7dJuf2T9bOeLKvSd71n9drkje88N8Zw fl6X6vE4oSpOoF/T2sIqyuyS5uRUxzrdnzmnLIWv+qyO5Oa9qNae+Du5eMnFqTuNvrHwfTVo TNxSVL/n48nDh2PuCUq6SBUW9kadter0/rnkZ/hq1aedqo0bZkdP4a1L/TiJd+si1qu7vk4L W3vK6osSS3FGoqEWc1FxIgBCtczwyQIAAA== X-Stat-Signature: 3t1iwy7kibwb5pxe1td65friwhsp7ud5 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 74B1BE0011D9 Received-SPF: none (kingsoft.com>: No applicable sender policy available) receiver=imf30; identity=mailfrom; envelope-from=""; helo=mail.kingsoft.com; client-ip=114.255.44.145 X-HE-DKIM-Result: none/none X-HE-Tag: 1615970241-289125 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When we do coredump for user process signal, this may be an SIGBUS signal with BUS_MCEERR_AR or BUS_MCEERR_AO code, which means this signal is resulted from ECC memory fail like SRAR or SRAO, we expect the memory recovery work is finished correctly, then the get_dump_page() will not return the error page as its process pte is set invalid by memory_failure(). But memory_failure() may fail, and the process's related pte may not be correctly set invalid, for current code, we will return the poison page and get it dumped and lead to system panic as its in kernel code. So check the poison status in get_dump_page(), and if TRUE, return NULL. Signed-off-by: Aili Yao --- mm/gup.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/gup.c b/mm/gup.c index e4c224c..499a496 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1536,6 +1536,14 @@ struct page *get_dump_page(unsigned long addr) FOLL_FORCE | FOLL_DUMP | FOLL_GET); if (locked) mmap_read_unlock(mm); + + if (IS_ENABLED(CONFIG_MEMORY_FAILURE) && ret == 1) { + if (unlikely(PageHuge(page) && PageHWPoison(compound_head(page)))) + ret = 0; + else if (unlikely(PageHWPoison(page))) + ret = 0; + } + return (ret == 1) ? page : NULL; } #endif /* CONFIG_ELF_CORE */