Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp647519pxb; Tue, 5 Apr 2022 17:12:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgag6F3Lm2HgZeGOlWjMAfStkXVRiHZQnTc6agFmvIgHPTqUF7WGJAsAyzBfTFmXUS8oAB X-Received: by 2002:a17:90b:250f:b0:1ca:b9fa:efcd with SMTP id ns15-20020a17090b250f00b001cab9faefcdmr6987236pjb.123.1649203963914; Tue, 05 Apr 2022 17:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649203963; cv=none; d=google.com; s=arc-20160816; b=ngpw54Jc7IlBG7HqcJMylQ5hFEaxQkhAqgHi0NKuW1mg92whdfIt/4Pwy1lNAFtU03 YKTrV/3yxYMVWpMhDCa1egG3MCm8Yv8I7mVVb01FNAReNMcLXuaMpeXoem4ZJT3f5uJE mlUNIFeTys8fM6aDawCkPI8hvzx+/i1dGnWhOWGsxHFK+zV1tO/dPi3DNsMP8efalmOT O5S//Mzjj9j0H/MJcvDxo49pLm1JwRt6s4sMuCZiNNBPrxTMzScc8S16ufk1DTxXxqVe iQ5VCQlGwj040G6CKROK85sXp7tSMVsny1TGrqpf/aevxqLyfWp4Rn3IftF9ySTcxbSD ZbFA== 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=5U5eSwmBoV83vUAhpzTCkO7PAf4YRBFpxlvp0AwtuOQ=; b=eoqVwindDA5Xp6tT6nikPCMaGoxoo5VQTsfmAKjems1YgGimZe1O/eg/mpO/snu871 MDemk0cMqM6j2QSbYoCCHYP7Q/KnY4VlCA4OKcjzcoUgZLuuxGvhiuAPjEcaBNQWFNW+ IKG9/eV+53fY+oj3xAmtkcXeqJbbpfIMCvbYJHKemsBhvrCL+tdsmnLPfpfgTEi/Yw7j KvX49uj4UNdszCXqPnbu46JY7iGNawl16TYauSIXkO34VhGsd6fzkRW+TUNvwMrXPnxp Kcr2fZpdRY0GomKM3xb7575/wCtQ453+/N3eS0n15PWipqQFr6bC4x9lnLbVdcgtTGPk z+xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=btCeQXJ1; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id q88-20020a17090a4fe100b001bf082ef447si3254446pjh.111.2022.04.05.17.12.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 17:12:43 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=btCeQXJ1; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CAB62181B02; Tue, 5 Apr 2022 16:57:01 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351171AbiDELE0 (ORCPT + 99 others); Tue, 5 Apr 2022 07:04:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237486AbiDEImf (ORCPT ); Tue, 5 Apr 2022 04:42:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E296E0CD; Tue, 5 Apr 2022 01:34:58 -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 9DD6460B0A; Tue, 5 Apr 2022 08:34:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78671C385A0; Tue, 5 Apr 2022 08:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649147697; bh=iuu0YuAOVMFBxBVeMxgnFXwtYV2ssnNxwyvplSk10do=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=btCeQXJ1Ej0AY+OeUNKbpzVvgCki1pqIqjregzUe98kEpaNo/em/R4vu1Qx4/XPOv CqRZGSj6eLpd2rjbtGSTt3DZX55pexYdctEq5uXWdEgoyNkU4fMLUAH24Uqt4wrWVw DPxLODnisKpgjDNPx9Ir52LhQ4U7BCxjMBy7Ws0g= 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 , John Hubbard , Mel Gorman , Johannes Weiner , Matthew Wilcox , Andrew Morton , Linus Torvalds Subject: [PATCH 5.16 0089/1017] mm: invalidate hwpoison page cache page in fault path Date: Tue, 5 Apr 2022 09:16:42 +0200 Message-Id: <20220405070356.835980295@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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 e53ac7374e64dede04d745ff0e70ff5048378d1f upstream. Sometimes the page offlining code can leave behind a hwpoisoned clean page cache page. This can lead to programs being killed over and over and over again as they fault in the hwpoisoned page, get killed, and then get re-spawned by whatever wanted to run them. This is particularly embarrassing when the page was offlined due to having too many corrected memory errors. Now we are killing tasks due to them trying to access memory that probably isn't even corrupted. This problem can be avoided by invalidating the page from the page fault handler, which already has a branch for dealing with these kinds of pages. With this patch we simply pretend the page fault was successful if the page was invalidated, return to userspace, incur another page fault, read in the file from disk (to a new memory page), and then everything works again. Link: https://lkml.kernel.org/r/20220212213740.423efcea@imladris.surriel.com Signed-off-by: Rik van Riel Reviewed-by: Miaohe Lin Acked-by: Naoya Horiguchi Reviewed-by: Oscar Salvador Cc: John Hubbard Cc: Mel Gorman Cc: Johannes Weiner Cc: Matthew Wilcox Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/memory.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/mm/memory.c +++ b/mm/memory.c @@ -3888,11 +3888,16 @@ static vm_fault_t __do_fault(struct vm_f return ret; if (unlikely(PageHWPoison(vmf->page))) { - if (ret & VM_FAULT_LOCKED) + vm_fault_t poisonret = VM_FAULT_HWPOISON; + if (ret & VM_FAULT_LOCKED) { + /* Retry if a clean page was removed from the cache. */ + if (invalidate_inode_page(vmf->page)) + poisonret = 0; unlock_page(vmf->page); + } put_page(vmf->page); vmf->page = NULL; - return VM_FAULT_HWPOISON; + return poisonret; } if (unlikely(!(ret & VM_FAULT_LOCKED)))