From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 A3DF7C4707F for ; Tue, 25 May 2021 08:11:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 83562613F9 for ; Tue, 25 May 2021 08:11:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232167AbhEYIMs (ORCPT ); Tue, 25 May 2021 04:12:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:44046 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232340AbhEYILC (ORCPT ); Tue, 25 May 2021 04:11:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1621930172; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=X4K/eFCPs5ZyC3dq4RSvLq5Boc7xvE8slnEIPMBZGpw=; b=c1s1plU6q0xrLR+wXrLfQf62Fs8wZWwnwCoO9eX9RbnlSx1ytXiGg2P44Npq03wQ028FsM Pgv6/QpacFC/f/qRjUIhAlTYPlbJPDo7MUvqlxT5zDg/PV6Gcp2Al6e1IaSae4vwoLAj9n ora26UMWYB1ymnK3BrlQj4iK8b3K/3s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1621930172; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=X4K/eFCPs5ZyC3dq4RSvLq5Boc7xvE8slnEIPMBZGpw=; b=ADAQcDeXbTkMZE5JillIUtK1huQAY3rN8g/TrXwlUJb8X94NEHSD8dKdcBd+3MMfXW6E6n Y++137sQrMpl4cBw== Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id CBAC5AEBD; Tue, 25 May 2021 08:09:31 +0000 (UTC) Date: Tue, 25 May 2021 10:09:27 +0200 From: Oscar Salvador To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, Andrew Morton , "Michael S. Tsirkin" , Jason Wang , Alexey Dobriyan , Mike Rapoport , "Matthew Wilcox (Oracle)" , 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, Mike Rapoport Subject: Re: [PATCH v2 3/6] fs/proc/kcore: don't read offline sections, logically offline pages and hwpoisoned pages Message-ID: <20210525080922.GA3300@linux> References: <20210514172247.176750-1-david@redhat.com> <20210514172247.176750-4-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210514172247.176750-4-david@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Fri, May 14, 2021 at 07:22:44PM +0200, David Hildenbrand wrote: > Let's avoid reading: > > 1) Offline memory sections: the content of offline memory sections is stale > as the memory is effectively unused by the kernel. On s390x with standby > memory, offline memory sections (belonging to offline storage > increments) are not accessible. With virtio-mem and the hyper-v balloon, > we can have unavailable memory chunks that should not be accessed inside > offline memory sections. Last but not least, offline memory sections > might contain hwpoisoned pages which we can no longer identify > because the memmap is stale. > > 2) PG_offline pages: logically offline pages that are documented as > "The content of these pages is effectively stale. Such pages should not > be touched (read/write/dump/save) except by their owner.". > Examples include pages inflated in a balloon or unavailble memory > ranges inside hotplugged memory sections with virtio-mem or the hyper-v > balloon. > > 3) PG_hwpoison pages: Reading pages marked as hwpoisoned can be fatal. > As documented: "Accessing is not safe since it may cause another machine > check. Don't touch!" > > Introduce is_page_hwpoison(), adding a comment that it is inherently > racy but best we can really do. > > Reading /proc/kcore now performs similar checks as when reading > /proc/vmcore for kdump via makedumpfile: problematic pages are exclude. > It's also similar to hibernation code, however, we don't skip hwpoisoned > pages when processing pages in kernel/power/snapshot.c:saveable_page() yet. > > Note 1: we can race against memory offlining code, especially > memory going offline and getting unplugged: however, we will properly tear > down the identity mapping and handle faults gracefully when accessing > this memory from kcore code. > > Note 2: we can race against drivers setting PageOffline() and turning > memory inaccessible in the hypervisor. We'll handle this in a follow-up > patch. > > Reviewed-by: Mike Rapoport > Signed-off-by: David Hildenbrand Reviewed-by: Oscar Salvador -- Oscar Salvador SUSE L3