Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1702582pxy; Sat, 1 May 2021 23:34:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcfiSSY0TYqYgsFxIuhtz1u6Y17i/5M0FXoxqoNCXD9UXBXF4SbZ/8N6S4tPJ/aCDowhEn X-Received: by 2002:a05:6402:4390:: with SMTP id o16mr14099009edc.14.1619937281841; Sat, 01 May 2021 23:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619937281; cv=none; d=google.com; s=arc-20160816; b=pvNnDk5jbPv1Oy4dwlgsQ8YaJUiQcLuCq+nZu72Zz0/nJHN/CEHDy1ScrofnLntKA4 Y+z8+Nb0fUAUrb/czhVpCYv986ihyOq8++4X/I/j2e8mZOX97y/OKdzpQEgJtcJwxGIv yrQyyfX/CMnnsOT7T870jLMfDK5rvHhK7Hj7Bx4O2gc1Dgyq1qaUBeTxRPyl+yaDAr9E 4sbma308wC8e0KTqRZWleuq07Pip74bOAe0lumbSNyk0TGiJfrQtMwDL6pQxZG7l9XwI +ToMJC/OvbRjwOqYKATAAChyA6enWF5EsmPDm537p7KdlI2t9oIDqCefXl7F1lsFlGAy mYRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rkKLxRPyORy4e0EMz6c4JMCvoslcGC7G79HtfISY8Dc=; b=VJRVCS0OxCGwsfQxzM2rncv00vHE8zIoDc2FTIkNZNqMkRy01qQqKYbu3SXeDluizG BgkNSMrXyBABbJE9mAXjGhNPXkBbwThiAe3mqzvFjBKudj1i0f44JCB+MIyPhoonx8YL rTubKskijo0jig5sdtKV5cbURm4dlyncHe+8k6CYCSKmhwcbf5RyuOSJANxfvTB1ODPh e07rggsvIPVJDEhv+eWeK7y8V6jKJ5qeNcjXVYV2rybpkJqq61dPncsrtm4KRGCO9By1 xsshA0iEJ9qAsgyegkdrUMfr8eGn9VlXkNq6Zm23ettSxiFMIocTfpWhm0KHx2na15Fm hbPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dlhipPfm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j16si8081441edj.357.2021.05.01.23.34.18; Sat, 01 May 2021 23:34:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dlhipPfm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231284AbhEBGdS (ORCPT + 99 others); Sun, 2 May 2021 02:33:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:59980 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbhEBGdR (ORCPT ); Sun, 2 May 2021 02:33:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1DA726128E; Sun, 2 May 2021 06:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619937146; bh=IiEyzQs5MLcZFCvU0d7y1MV8UlTREQiWGwIM/9pwy/Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dlhipPfmdUEHaMz4+QQjq3Zbf4C91HXPY9jQtLKOtWhXziDi2vDX110O2ODTHZhkY jFmPlvBfLY2BUWZrFMUeguICwHOl7dXe99mF/2nXZtjUwtowpV1soCnNlZ9kkKV204 z+s4nzQu24hvfIVUSL4ZPa6Cx4gNz2XQoIZ663xHMGJUxqp7SN0vf+X5xzTPN0yhCv lo9KL8d+NnO9W9LxDL7tT2WCdH97cyrejOoatl5+mj0A4RXiw5o4IBVBWoYYdoQt0E enrlier3FVU1aSesUwDjPdM6JgY1OQ9Bj42qMecSqHnIgEpFhW/TdKtyQlOsdi998M mElZpvzgq2zOw== Date: Sun, 2 May 2021 09:32:14 +0300 From: Mike Rapoport To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, Andrew Morton , "Michael S. Tsirkin" , Jason Wang , Alexey Dobriyan , "Matthew Wilcox (Oracle)" , Oscar Salvador , Michal Hocko , Roman Gushchin , Alex Shi , Steven Price , Mike Kravetz , Aili Yao , Jiri Bohac , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Naoya Horiguchi , linux-hyperv@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v1 3/7] mm: rename and move page_is_poisoned() Message-ID: References: <20210429122519.15183-1-david@redhat.com> <20210429122519.15183-4-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210429122519.15183-4-david@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 29, 2021 at 02:25:15PM +0200, David Hildenbrand wrote: > Commit d3378e86d182 ("mm/gup: check page posion status for coredump.") > introduced page_is_poisoned(), however, v5 [1] of the patch used > "page_is_hwpoison()" and something went wrong while upstreaming. Rename the > function and move it to page-flags.h, from where it can be used in other > -- kcore -- context. > > Move the comment to the place where it belongs and simplify. > > [1] https://lkml.kernel.org/r/20210322193318.377c9ce9@alex-virtual-machine > > Signed-off-by: David Hildenbrand Reviewed-by: Mike Rapoport > --- > include/linux/page-flags.h | 7 +++++++ > mm/gup.c | 6 +++++- > mm/internal.h | 20 -------------------- > 3 files changed, 12 insertions(+), 21 deletions(-) Nice :) > > diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h > index 04a34c08e0a6..b8c56672a588 100644 > --- a/include/linux/page-flags.h > +++ b/include/linux/page-flags.h > @@ -694,6 +694,13 @@ PAGEFLAG_FALSE(DoubleMap) > TESTSCFLAG_FALSE(DoubleMap) > #endif > > +static inline bool is_page_hwpoison(struct page *page) > +{ > + if (PageHWPoison(page)) > + return true; > + return PageHuge(page) && PageHWPoison(compound_head(page)); > +} > + > /* > * For pages that are never mapped to userspace (and aren't PageSlab), > * page_type may be used. Because it is initialised to -1, we invert the > diff --git a/mm/gup.c b/mm/gup.c > index ef7d2da9f03f..000f3303e7f2 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -1536,7 +1536,11 @@ struct page *get_dump_page(unsigned long addr) > if (locked) > mmap_read_unlock(mm); > > - if (ret == 1 && is_page_poisoned(page)) > + /* > + * We might have hwpoisoned pages still mapped into user space. Don't > + * read these pages when creating a coredump, access could be fatal. > + */ > + if (ret == 1 && is_page_hwpoison(page)) > return NULL; > > return (ret == 1) ? page : NULL; > diff --git a/mm/internal.h b/mm/internal.h > index cb3c5e0a7799..1432feec62df 100644 > --- a/mm/internal.h > +++ b/mm/internal.h > @@ -97,26 +97,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; > > /* > -- > 2.30.2 > -- Sincerely yours, Mike.