Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp699810pxb; Tue, 5 Apr 2022 19:19:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpD+F+DDxrBcXsSGM9wrmHqiLmeHm3yfM3mxBNFU49IlYQxjeGegW4yjxmHN4ar16TiAva X-Received: by 2002:a17:902:d48b:b0:156:bddf:f06 with SMTP id c11-20020a170902d48b00b00156bddf0f06mr6425989plg.141.1649211558096; Tue, 05 Apr 2022 19:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649211558; cv=none; d=google.com; s=arc-20160816; b=Xq3MI7Uw5upaVS70AiyPpfsfM2qRd7lP6VkQFWEg9uatP73FQwXnGntSSYtcT25KgI BqNp7ZqeHmjedwTDTj7t6ITf4y7nVwcYBxYRsdZJ4EY5DZAm1IZyXSvJevOozre1PA1O QQn9+XnhD7jBYh35odhA6L2Buo2tTSKPzUdacNTnTDwG78bjP58azQTtt/eyuRJ+qc20 k8kiANz0zdvM6OXb9x/muVfm2uEhBPdLaLdunr7A0Z9/oMhbcJvGnDULDzPY7NTkbzgx ii54x2pX5Xl9X4HU5dVsJfgjWHpuQJPOKRQ/Ku2w9/bQinZ0VvnneQJWGWkj1oyW67bo oERA== 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=MTKm039IN2NYW51Rpgnx0mE0eBHsSvN1lvLjhWP6rQk=; b=PC5W4SMMQUPlSoNGKNFs5ahKxvyOERWI865UsrfIf/DfKpUcJzhY6nvcKQDHWLJ/tc iKe/b104SwFle+eVicVoPyknjfiDSgGuTikoi0UzzrHaJtynebQ1uL1vicr1LM66bbQj 5UQQeUWbYW5O52eNSj16JnIfP3xznX1PDU3zhr3b98SChdTzDNUjT3IEUWd92yj2PWWP cKRoEe06BPJX7mkYavH+b+ABuDX6ONKhJvLowZIdLx5Q3uUhnb8Dgzb21HAHPk1IurAy vVxRKXtCpFsH90B99PXpsUXw5xG2R6+JzCO5esVt4PrYdClQu4Hmx9XFg2w7xy9A1HKB rnFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VLw2pkbE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v24-20020aa78098000000b004fa3a8dffeesi13818172pff.165.2022.04.05.19.19.01; Tue, 05 Apr 2022 19:19:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VLw2pkbE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233182AbiDEHwM (ORCPT + 99 others); Tue, 5 Apr 2022 03:52:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233045AbiDEHrY (ORCPT ); Tue, 5 Apr 2022 03:47:24 -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 5198E972E5; Tue, 5 Apr 2022 00:43:33 -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 EE661616C4; Tue, 5 Apr 2022 07:43:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05D82C340EE; Tue, 5 Apr 2022 07:43:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649144612; bh=cvKdZ6StMfm6zRKMs64+nsuqFYWwxL633CUZBelPVRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VLw2pkbEcUmqxE77Vdnh9AKrVmhFReFgcdU6n3/wwlXI09uCK8WutkEWPAUZcFrQJ 942pSCMLALOXF2lSTJ51CfQTa5h2C5UPZo6ihVRiTYbOTUqRMHr9rg6AnEhZ3WR59C OvdF31FjWBXvUzy0FDhVIFr6VVgdcT+NAxZ11vsk= 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.17 0108/1126] mm,hwpoison: unmap poisoned page before invalidation Date: Tue, 5 Apr 2022 09:14:15 +0200 Message-Id: <20220405070410.740756156@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 @@ -3893,14 +3893,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; }