Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1612502ybp; Wed, 9 Oct 2019 17:28:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJee6liSnRK1zq7NGa0fvNbshQGD+wMIg8p3FtEyaACBUS4VvMY8uhPOxFx6pmuelXzAo3 X-Received: by 2002:a17:906:2410:: with SMTP id z16mr5506057eja.120.1570667323332; Wed, 09 Oct 2019 17:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570667323; cv=none; d=google.com; s=arc-20160816; b=1GVUTCCg6PUYzoldyHhYSNcVs3y/qCT9XmzWo35zh4POd2JUjKEdodejpGC5AQW37L z1EXr6CRZMy4Z6HehIOrxQmKlYdJlPZlDzlv5DDiJGFOyckGxLzv0lSqlB5YhqRzqtuk wRJOm+qnZIpLZSXWuBUZs2ctHl2/8L+abKyyrdFUdP8kLm2R4oUJLOoTn4nEpYMh9Jv3 yv34c60at2uByifOgAoly6NQqoBLH41TVm7VqUkmHQS8dItrx2S1Tcx2JFUv0FQmEE+A xqDV/eyzy4IVJTrpCt7WbtR3jiIo0NnMl3oNJSRXEtKbK7leMXu2kWYjvJHHEDy7Xn+g 3VBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from; bh=5arhTtO4iZJMJXh/WB+B/8pW6GWlI6DjIBg/YzQNvto=; b=b3v6X0Dz+E+dsDJ0O8cbgPXI5BUcW/cvLsy2kVTV1bBXtFcOXTl/M3769g8SIkjwjb 5PTBYcFXZxXOZscQ+G+DeiZ7BMFHmqxaMc6NUfbogkbJL0ehMlExHxVUZidpYJj4R64y UU93TpLxXoayrnmLMCzNII0zvbWWMfOzv51vBg0J7+Cqss0wu2cAifYMTbphMEaamgoK ZRqNmCRT7ehgeQpA04qm4OJUygZDA53gsMWh9l2DleCkdYBWgDE/bE+KADQ0BCx+qnOj kG9mpNdqd2fYXbgNKK6+O57nhMcV6U2MNP506QSLNIhTAnOrvZJApPPvUzAL5gEZyAP5 MnHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1si2204290ede.255.2019.10.09.17.28.19; Wed, 09 Oct 2019 17:28:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732447AbfJJA1f convert rfc822-to-8bit (ORCPT + 99 others); Wed, 9 Oct 2019 20:27:35 -0400 Received: from tyo161.gate.nec.co.jp ([114.179.232.161]:33851 "EHLO tyo161.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732421AbfJJA1f (ORCPT ); Wed, 9 Oct 2019 20:27:35 -0400 Received: from mailgate02.nec.co.jp ([114.179.233.122]) by tyo161.gate.nec.co.jp (8.15.1/8.15.1) with ESMTPS id x9A0RKQN018137 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 10 Oct 2019 09:27:20 +0900 Received: from mailsv02.nec.co.jp (mailgate-v.nec.co.jp [10.204.236.94]) by mailgate02.nec.co.jp (8.15.1/8.15.1) with ESMTP id x9A0RK5D006401; Thu, 10 Oct 2019 09:27:20 +0900 Received: from mail02.kamome.nec.co.jp (mail02.kamome.nec.co.jp [10.25.43.5]) by mailsv02.nec.co.jp (8.15.1/8.15.1) with ESMTP id x9A0R49V023354; Thu, 10 Oct 2019 09:27:20 +0900 Received: from bpxc99gp.gisp.nec.co.jp ([10.38.151.148] [10.38.151.148]) by mail01b.kamome.nec.co.jp with ESMTP id BT-MMP-9297955; Thu, 10 Oct 2019 09:26:20 +0900 Received: from BPXM23GP.gisp.nec.co.jp ([10.38.151.215]) by BPXC20GP.gisp.nec.co.jp ([10.38.151.148]) with mapi id 14.03.0439.000; Thu, 10 Oct 2019 09:26:19 +0900 From: Naoya Horiguchi To: David Hildenbrand CC: "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , Andrew Morton , Michal Hocko Subject: Re: [PATCH v2 2/2] mm/memory-failure.c: Don't access uninitialized memmaps in memory_failure() Thread-Topic: [PATCH v2 2/2] mm/memory-failure.c: Don't access uninitialized memmaps in memory_failure() Thread-Index: AQHVfq1QC/9/3IlYuEK91tWnhgAEnKdSbnGA Date: Thu, 10 Oct 2019 00:26:19 +0000 Message-ID: <20191010002619.GB3585@hori.linux.bs1.fc.nec.co.jp> References: <20191009142435.3975-1-david@redhat.com> <20191009142435.3975-3-david@redhat.com> In-Reply-To: <20191009142435.3975-3-david@redhat.com> Accept-Language: en-US, ja-JP Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.34.125.96] Content-Type: text/plain; charset="iso-2022-jp" Content-ID: Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-TM-AS-MML: disable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 09, 2019 at 04:24:35PM +0200, David Hildenbrand wrote: > We should check for pfn_to_online_page() to not access uninitialized > memmaps. Reshuffle the code so we don't have to duplicate the error > message. > > Cc: Naoya Horiguchi > Cc: Andrew Morton > Cc: Michal Hocko > Signed-off-by: David Hildenbrand > --- > mm/memory-failure.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 7ef849da8278..e866e6e5660b 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1253,17 +1253,19 @@ int memory_failure(unsigned long pfn, int flags) > if (!sysctl_memory_failure_recovery) > panic("Memory failure on page %lx", pfn); > > - if (!pfn_valid(pfn)) { > + p = pfn_to_online_page(pfn); > + if (!p) { > + if (pfn_valid(pfn)) { > + pgmap = get_dev_pagemap(pfn, NULL); > + if (pgmap) > + return memory_failure_dev_pagemap(pfn, flags, > + pgmap); > + } > pr_err("Memory failure: %#lx: memory outside kernel control\n", > pfn); > return -ENXIO; > } > > - pgmap = get_dev_pagemap(pfn, NULL); > - if (pgmap) > - return memory_failure_dev_pagemap(pfn, flags, pgmap); > - > - p = pfn_to_page(pfn); This change seems to assume that memory_failure_dev_pagemap() is never called for online pages. Is it an intended behavior? Or the concept "online pages" is not applicable to zone device pages? Thanks, Naoya Horiguchi