Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752019AbdIEHMa (ORCPT ); Tue, 5 Sep 2017 03:12:30 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38500 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751709AbdIEHM1 (ORCPT ); Tue, 5 Sep 2017 03:12:27 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mel Gorman , "Wang, Wendy" , David Rientjes , Vlastimil Babka , "Hansen, Dave" , "Luck, Tony" , Naoya Horiguchi , Andrew Morton , Linus Torvalds Subject: [PATCH 4.12 11/27] mm, madvise: ensure poisoned pages are removed from per-cpu lists Date: Tue, 5 Sep 2017 09:11:27 +0200 Message-Id: <20170905070923.689712991@linuxfoundation.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170905070923.265950493@linuxfoundation.org> References: <20170905070923.265950493@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2299 Lines: 65 4.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mel Gorman commit c461ad6a63b37ba74632e90c063d14823c884247 upstream. Wendy Wang reported off-list that a RAS HWPOISON-SOFT test case failed and bisected it to the commit 479f854a207c ("mm, page_alloc: defer debugging checks of pages allocated from the PCP"). The problem is that a page that was poisoned with madvise() is reused. The commit removed a check that would trigger if DEBUG_VM was enabled but re-enabling the check only fixes the problem as a side-effect by printing a bad_page warning and recovering. The root of the problem is that an madvise() can leave a poisoned page on the per-cpu list. This patch drains all per-cpu lists after pages are poisoned so that they will not be reused. Wendy reports that the test case in question passes with this patch applied. While this could be done in a targeted fashion, it is over-complicated for such a rare operation. Link: http://lkml.kernel.org/r/20170828133414.7qro57jbepdcyz5x@techsingularity.net Fixes: 479f854a207c ("mm, page_alloc: defer debugging checks of pages allocated from the PCP") Signed-off-by: Mel Gorman Reported-by: Wang, Wendy Tested-by: Wang, Wendy Acked-by: David Rientjes Acked-by: Vlastimil Babka Cc: "Hansen, Dave" Cc: "Luck, Tony" Cc: Naoya Horiguchi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/madvise.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/mm/madvise.c +++ b/mm/madvise.c @@ -610,6 +610,7 @@ static int madvise_inject_error(int beha unsigned long start, unsigned long end) { struct page *page; + struct zone *zone; if (!capable(CAP_SYS_ADMIN)) return -EPERM; @@ -643,6 +644,11 @@ static int madvise_inject_error(int beha if (ret) return ret; } + + /* Ensure that all poisoned pages are removed from per-cpu lists */ + for_each_populated_zone(zone) + drain_all_pages(zone); + return 0; } #endif