Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1352492pxy; Thu, 29 Apr 2021 05:27:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8SA4Bd4ofebWlWM7mqU+J6jOcLi3+pgTwXr233Yb1WHCX9/dRD6/MB6PgREGQse9j9+Fr X-Received: by 2002:a17:90b:4c4f:: with SMTP id np15mr37541827pjb.191.1619699255586; Thu, 29 Apr 2021 05:27:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619699255; cv=none; d=google.com; s=arc-20160816; b=hflEBhPhwgmJ9Q0o8zOb2wJSs/KzZKaEr/tfPQPxyE1a5j3lpm/Od5nPbVUZSiUkWW 57hXSL7/xjCWzRArVpXdxnBEW4UbmyvLgwqlQwriQ6cDrmvMZd66d65Jswp30rKbhc0J d+FqSGJkAo/PAONdMuJis105c6tTnVMQwhzW073KO2TkLkOwP9o8+k5X70dzYFestW1A gsIA+4Qn6/Wzrv+oki+FToGgbs3ljyD2B6+7tDYB78wD00e5gVeVJO6HZQzGC+vkoTg6 jzLklXAal+ZYDPrFhgwPx2WjXwN/dTDm7c45/o6k9eoost5IuI4SFHdJEt7k3BRZOmB8 8Rdg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9yW4OuKyN35nF4beRa4G0zG5E1KxLWubZR1ZjeP0KtI=; b=qHG0FfNVgvHbmYGU4eCTJXECVBgpkj8auiw3LjsxrO2FwrDhYJtFrCr/tS2Az+kT2n bvIMZF3+aZXnfpJeDbsk+nZb9WQ1d0nfjOKcgvK9tQn6gLIuy5ZRA5l9J2OYdEXin935 QLyGNHyush931EQnXntnAhWwZ5xhnnFfcrzPliPHcFqKVvLD3konXAhkR5z5ibQsTsQ0 sBGsHW3tambLvTnkAtVIdq+zDGK6CwimGpMUI2Yri883Az87ZRtPR4D/9d6Ihw7fZF+f d25PjycnVVbSk/4wTUdxXPzxE7TW+vg3oqdNkPyVYQJ22593A+qVL8HqnZxrdh/YsM8Z NQvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YfE4oZdX; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r1si3047026pgs.431.2021.04.29.05.27.23; Thu, 29 Apr 2021 05:27:35 -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=@redhat.com header.s=mimecast20190719 header.b=YfE4oZdX; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235662AbhD2M0k (ORCPT + 99 others); Thu, 29 Apr 2021 08:26:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31121 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236612AbhD2M0g (ORCPT ); Thu, 29 Apr 2021 08:26:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619699150; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9yW4OuKyN35nF4beRa4G0zG5E1KxLWubZR1ZjeP0KtI=; b=YfE4oZdXNKlICUEPNXNRa/7MhrKt/zOHHL43XtfnMZQIKy4EUhw41LPH4evd/Sq7+SFGQf 7uzLLZQT9d2cfE4xAJpZwUWZWTGOtA+8IViaLuu0i+KTUrho3jeJ0Jeu4PlfvBZC5+P0M5 4491uSgVq8tefpjyqZ7RyKHm8OhatLg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-216-yxYYYYlMNcONjLFEyhJ5IQ-1; Thu, 29 Apr 2021 08:25:46 -0400 X-MC-Unique: yxYYYYlMNcONjLFEyhJ5IQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B20248042A6; Thu, 29 Apr 2021 12:25:43 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-50.ams2.redhat.com [10.36.114.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C08A18796; Thu, 29 Apr 2021 12:25:38 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: David Hildenbrand , Andrew Morton , "Michael S. Tsirkin" , Jason Wang , Alexey Dobriyan , Mike Rapoport , "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: [PATCH v1 3/7] mm: rename and move page_is_poisoned() Date: Thu, 29 Apr 2021 14:25:15 +0200 Message-Id: <20210429122519.15183-4-david@redhat.com> In-Reply-To: <20210429122519.15183-1-david@redhat.com> References: <20210429122519.15183-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- include/linux/page-flags.h | 7 +++++++ mm/gup.c | 6 +++++- mm/internal.h | 20 -------------------- 3 files changed, 12 insertions(+), 21 deletions(-) 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