Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp960077pxb; Wed, 6 Apr 2022 05:22:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyl1ekogywzwFzcD/ERZ5GQT/nCz//h8qVhI8E2n8EXYZahuYtj5VdejGVzzGJF5MGUuggY X-Received: by 2002:a63:4642:0:b0:398:b6b9:5f45 with SMTP id v2-20020a634642000000b00398b6b95f45mr7006323pgk.518.1649247720833; Wed, 06 Apr 2022 05:22:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649247720; cv=none; d=google.com; s=arc-20160816; b=ax/gf5kZWIfc9vGic4V7eef8aRqscBTB52pCbGPpcTC2zTUS2DFO7z+wRb0x7pS46L DYLMqEmxI1rRTmVzNsaXVaff/AlRB70Ejd84FtP4OMZmX2aV4kz3/m7KsithuP3lS9uR adnMAS78K15q9VkmeytCIFfLL++Zy69ikZJoqWMGrRELm3GlKPF8AN7d3UIy72m9MCeq dJk41+Q0P75qT+necFyF6NKfyDtZqQ1EfGpqjNpSCvo80D2LuaI4v/BU+g6PuZqfnMU7 LbnHa56XbLP/ocvozEN22ouBTcpCfDfZW1aECPTdSvgeAJkD6vj6rua+p490mTgyMVvC JojQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=C4tcbIWVledzMUCQ6aPLNLLq35KaupLtdVDL4nTN0qc=; b=UEt5zJCUXBAvWWiaJ5cjnh1lOjiotwbRViFbrVrDfRHYd8GaR1yKByIp9Jzw/4tqwU rWCUWP7qK/Wsi8nhddpnjCEt4msDbgnk/puHtvg0xfL+fbTWVd+Bm0YzBNgrA2/08B9K nbBfGuJazUD+1uIAh/3K1qjj3C0fPTAlosjj65WV2H5Cv98PZ+jcK5GPqEgUQOrBGZnR jVNdV3hGwLpVbEaJ9Q2TbmriPbg6PwtDWasPeoTl5O9OMtqLyIIwwqfYDRHuXCTigDHo SvchjTX7sdfiSI+mzaXg/S/r7d6OEbHi/K3ryepxU0F42ZyEEjkr9Kw5zpUu5+cYoP2g Ppdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nuY88ZRK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id a12-20020a056a000c8c00b004fa3a8dff62si16719057pfv.25.2022.04.06.05.22.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:22:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nuY88ZRK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 280AB6D5CF5; Wed, 6 Apr 2022 04:19:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384868AbiDEOS1 (ORCPT + 99 others); Tue, 5 Apr 2022 10:18:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240029AbiDEJeA (ORCPT ); Tue, 5 Apr 2022 05:34:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DBE37E0A1; Tue, 5 Apr 2022 02:23:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AE69261654; Tue, 5 Apr 2022 09:23:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC04CC385A2; Tue, 5 Apr 2022 09:23:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150594; bh=zJZvZVpLCc0e2RVJNQqJnkd54OH9Ak3/Lu4LUwktJeE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nuY88ZRK8Zb57NoxoALO1k8KHAyEICVprMnLrWip9evJIbndvBdTdEZVx3WyiBLOu xyoxkx6miBnL+lEDdg++k6iKNHECkwiyQNn6ndyo9Rh8J22CmwsTTVcJrX48jWkBhu eq6+/C6Wu9VsY8KrbVDKPEn9OzFKAcISB+/sUOms= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rik van Riel , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Mel Gorman , Johannes Weiner , Andrew Morton , Linus Torvalds Subject: [PATCH 5.15 110/913] mm,hwpoison: unmap poisoned page before invalidation Date: Tue, 5 Apr 2022 09:19:32 +0200 Message-Id: <20220405070343.124150095@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rik van Riel commit 3149c79f3cb0e2e3bafb7cfadacec090cbd250d3 upstream. In some cases it appears the invalidation of a hwpoisoned page fails because the page is still mapped in another process. This can cause a program to be continuously restarted and die when it page faults on the page that was not invalidated. Avoid that problem by unmapping the hwpoisoned page when we find it. Another issue is that sometimes we end up oopsing in finish_fault, if the code tries to do something with the now-NULL vmf->page. I did not hit this error when submitting the previous patch because there are several opportunities for alloc_set_pte to bail out before accessing vmf->page, and that apparently happened on those systems, and most of the time on other systems, too. However, across several million systems that error does occur a handful of times a day. It can be avoided by returning VM_FAULT_NOPAGE which will cause do_read_fault to return before calling finish_fault. Link: https://lkml.kernel.org/r/20220325161428.5068d97e@imladris.surriel.com Fixes: e53ac7374e64 ("mm: invalidate hwpoison page cache page in fault path") Signed-off-by: Rik van Riel Reviewed-by: Miaohe Lin Tested-by: Naoya Horiguchi Reviewed-by: Oscar Salvador Cc: Mel Gorman Cc: Johannes Weiner Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/memory.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/mm/memory.c +++ b/mm/memory.c @@ -3861,14 +3861,18 @@ static vm_fault_t __do_fault(struct vm_f return ret; if (unlikely(PageHWPoison(vmf->page))) { + struct page *page = vmf->page; vm_fault_t poisonret = VM_FAULT_HWPOISON; if (ret & VM_FAULT_LOCKED) { + if (page_mapped(page)) + unmap_mapping_pages(page_mapping(page), + page->index, 1, false); /* Retry if a clean page was removed from the cache. */ - if (invalidate_inode_page(vmf->page)) - poisonret = 0; - unlock_page(vmf->page); + if (invalidate_inode_page(page)) + poisonret = VM_FAULT_NOPAGE; + unlock_page(page); } - put_page(vmf->page); + put_page(page); vmf->page = NULL; return poisonret; }