Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4166921pxj; Tue, 25 May 2021 01:45:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwY+aO64olo6a+vArIBO2TCbKatVVYQHOsFMqakVTVjRGUasiAl1GNzm7mxwNfSNbYYYiey X-Received: by 2002:a05:6402:4cf:: with SMTP id n15mr31655735edw.162.1621932349442; Tue, 25 May 2021 01:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621932349; cv=none; d=google.com; s=arc-20160816; b=Ls18K/ecC/gR5eyq1gMaY1VlPMxrTzN48qRXCJ9Z4IxddkNEF6b43glwdfB/lZ9yDk srU2O51Y1wcjdRXCIEPL3dRdcJ4kLKU4SRvw6r0SiDhpZfo/vuj7A1uQ0vqT4lOcNWvC sVDOatCcdPmSWXG3p1FsPddm/NQt+aSvr2u9UhgplbWpJrmZLRevCelbuzvM+N/Yxpjd ImQjIfpMcEdeYGGpD1kA/bp/UKaGp6WQAXLjl+WfcsCbf9DpiQms6ZMxIaMXUGJBd0JI ck+2Ix9OwpxH0TEMb1b1Coef843QKU+JjiohC3KAdSpIMqMbUVt4QCOm+AFKR6tYdUhf riDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=X4K/eFCPs5ZyC3dq4RSvLq5Boc7xvE8slnEIPMBZGpw=; b=nVSXh4F7GtuPy3a9ODmi3geio8ntywIv8rJNKyqwsHNtaaXE7trEjrqa4X0EO4Wqh+ h0WaTU20VAf4/KZcJ1Bn3lRFiLR+Sw5A8y6ZiBSOWuHkn00iI+DoZiijAfT2ZEbCP6zp pdkn6EosJ6MnIpKgbbvEw5Jb46VyTu868eFHc3B6YAVyRpEhA8IUfiDtogJHnR95FFtM 0if2/7ubB+5GHbloFXooZkbu1yRrwToRTF/KRAKTZkU7kjueP9sJP+/s2j/lmR1gmnOu PU1SwSdlDFaSGH20uI8pW1Uf7+xx2lGpfHqG8oHvyicVnYRDVRb+sO6jkkOWg+udXLoI GZnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=c1s1plU6; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=ADAQcDeX; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co18si14777838edb.537.2021.05.25.01.45.26; Tue, 25 May 2021 01:45:49 -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=@suse.de header.s=susede2_rsa header.b=c1s1plU6; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=ADAQcDeX; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232166AbhEYIMs (ORCPT + 99 others); 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-kernel@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