From patchwork Wed May 5 13:54:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 12240011 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=-17.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 5DABCC433B4 for ; Wed, 5 May 2021 13:54:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E1DB161182 for ; Wed, 5 May 2021 13:54:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1DB161182 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 55C036B006C; Wed, 5 May 2021 09:54:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 530EE6B006E; Wed, 5 May 2021 09:54:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D2016B0070; Wed, 5 May 2021 09:54:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0127.hostedemail.com [216.40.44.127]) by kanga.kvack.org (Postfix) with ESMTP id 222266B006C for ; Wed, 5 May 2021 09:54:15 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id DC826180AD830 for ; Wed, 5 May 2021 13:54:14 +0000 (UTC) X-FDA: 78107321628.08.EDDEED6 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by imf01.hostedemail.com (Postfix) with ESMTP id 291E15001535 for ; Wed, 5 May 2021 13:54:02 +0000 (UTC) Received: by mail-wr1-f42.google.com with SMTP id l14so1947646wrx.5 for ; Wed, 05 May 2021 06:54:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eD6V+3EKLEZ2d3YHn8BHx9RbXqa4fEMUypgdABWHLlQ=; b=Vi3C0rBCRz7iVLRPQVptP5xNs0RnlZ6MkKKMTmOsOhiunjI96fX4Vczz0Z721P752k zO7TagYlpg6cjZnKzNMuQ6LVs0QZtPup4BlYJkDFaAOnWSBaJdYFWcFCu0O5QST8m1Xl DW/TuuIfjpF+ZebphEEfImaZ4CFKKUqguBd160eNLhz/y0pstD70aYpyCNmpxDnvQCwI OmrH1XyPAtWC5cw6mdZRranUzmrCFG0GnVi73uTCwIXl89E8QgqPIdKJNNDrgFlOK/Rk FgELJHZBDlu/MA29btEfdmfK10GtTR8a2voiOCInHiRJ3W7O0MZE16Gy9jYwnQb9M0zq JD1g== X-Gm-Message-State: AOAM530iYt0A2QSmHtFcy0WF7wH7dShM3GTMMNYOLb9o6K2AbpLvSHFX TxOElO4NZyoswf+cPtb3lkg= X-Google-Smtp-Source: ABdhPJwVZr25sOlVxz+KC0N/jYPU7xFY+zxzPB82mqgCwdIP8rqEAQfOaykCOk33AL8Bw/zvDc7k/w== X-Received: by 2002:a5d:64e5:: with SMTP id g5mr39262402wri.30.1620222853357; Wed, 05 May 2021 06:54:13 -0700 (PDT) Received: from tiehlicka.suse.cz (ip-85-160-7-215.eurotel.cz. [85.160.7.215]) by smtp.gmail.com with ESMTPSA id q12sm4893794wmj.7.2021.05.05.06.54.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 06:54:12 -0700 (PDT) From: Michal Hocko To: Andrew Morton Cc: David Hildenbrand , Aili Yao , , LKML , Michal Hocko Subject: [PATCH] Revert "mm/gup: check page posion status for coredump." Date: Wed, 5 May 2021 15:54:07 +0200 Message-Id: <20210505135407.31590-1-mhocko@kernel.org> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 291E15001535 Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf01.hostedemail.com: domain of mstsxfx@gmail.com designates 209.85.221.42 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com X-Rspamd-Server: rspam04 X-Stat-Signature: p5q5x76x18tiyswem7xd3t7wmcgpwygy Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=mail-wr1-f42.google.com; client-ip=209.85.221.42 X-HE-DKIM-Result: none/none X-HE-Tag: 1620222842-243472 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Michal Hocko While reviewing http://lkml.kernel.org/r/20210429122519.15183-4-david@redhat.com I have crossed d3378e86d182 ("mm/gup: check page posion status for coredump.") and noticed that this patch is broken in two ways. First it doesn't really prevent hwpoison pages from being dumped because hwpoison pages can be marked asynchornously at any time after the check. Secondly, and more importantly, the patch introduces a ref count leak because get_dump_page takes a reference on the page which is not releases. It also seems that the patch was merged incorrectly because there were follow up changes not included as well as discussions on how to address the underlying problem http://lkml.kernel.org/r/57ac524c-b49a-99ec-c1e4-ef5027bfb61b@redhat.com Therefore revert the original patch. Fixes: d3378e86d182 ("mm/gup: check page posion status for coredump.") Signed-off-by: Michal Hocko Reviewed-by: David Hildenbrand --- mm/gup.c | 4 ---- mm/internal.h | 20 -------------------- 2 files changed, 24 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 71e546e279fc..a33abe9048ed 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1592,10 +1592,6 @@ struct page *get_dump_page(unsigned long addr) FOLL_FORCE | FOLL_DUMP | FOLL_GET); if (locked) mmap_read_unlock(mm); - - if (ret == 1 && is_page_poisoned(page)) - return NULL; - return (ret == 1) ? page : NULL; } #endif /* CONFIG_ELF_CORE */ diff --git a/mm/internal.h b/mm/internal.h index ef5f336f59bd..43c4a2f8d4cc 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -96,26 +96,6 @@ static inline void set_page_refcounted(struct page *page) set_page_count(page, 1); } -/* - * When kernel touch the user page, the user page may be have been marked - * poison but still mapped in user space, if without this page, the kernel - * can guarantee the data integrity and operation success, the kernel is - * better to check the posion status and avoid touching it, be good not to - * panic, coredump for process fatal signal is a sample case matching this - * scenario. Or if kernel can't guarantee the data integrity, it's better - * not to call this function, let kernel touch the poison page and get to - * panic. - */ -static inline bool is_page_poisoned(struct page *page) -{ - if (PageHWPoison(page)) - return true; - else if (PageHuge(page) && PageHWPoison(compound_head(page))) - return true; - - return false; -} - extern unsigned long highest_memmap_pfn; /*