Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4268290ybp; Mon, 14 Oct 2019 01:45:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyF6lPy3SUfna8FXmiFR2kGIiS9ls8hGAl62IqVt5tgvfHN377ba1piYZS0+MhcHeNzhsfi X-Received: by 2002:a17:906:480a:: with SMTP id w10mr27412869ejq.212.1571042713697; Mon, 14 Oct 2019 01:45:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571042713; cv=none; d=google.com; s=arc-20160816; b=yYb6yqe/VAUpcRXqVgFCK5edFK8NsWXW6pRWm1y5PhF2OXa1O9gDQ8x2H0Pj2DNGMx Y7sERw2dSZgC2LQd9Z5mtd5M4citnKqXVxp1kTNaiB5b01Bpab2gJ9r4g0AEfSZiTuPf CJlAWtITAYwDJoXcx37inFcBhPJ5bwdxrZ7Mo52j3ae7tOYTmQUJu+/HGUO6B2hbmaUZ zGkO//Gutp1/XSqbZyelfPKUtylq92s376UXZmdLLBhaaZ6262Kjr+cAztRsun4ChfaI wLWPcvBvl2PK6cw6WCao2Ic2JKlBju4XrqPBMs6Pj2QVw6qvTOOiiKC2UL7xM42lNJY9 htEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=Xej1W3jsSqSu9nCCuQXmK2WP2sH7y7/c6EvXnlJIU6g=; b=kUm1UW69hbTvyMJc0GIGFgOKCAUihnCqGBPOYFsa9311ctYZ2d00A+MqyNMoSmyJMA TyGIh/sEQ1naW93NIRgPma97cPFqARo6TeC3NWIO6mcqHB8I/HGo9qV5SuiVliRj4c+l OxMsU294tBIfgE3e9p2xOE7OJhXO1Q0uquF9LwMICw5VuLTUyiUEPyt0N39Bzl0z1HCB a7SUje5slmVpFkEwEmPsf0Lchm6eugPaZUbqH/pgAIUlmHNbNhLqHVO3qYfTk6A1qgTk kHRZDzR2v9itcqy65a1Uk/Xijqf6XO06QXIRcI44kW0XIlX8JxBtzha8DfNO5mp8Y8qu x4ag== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i24si10430814ejh.35.2019.10.14.01.44.50; Mon, 14 Oct 2019 01:45:13 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730558AbfJNIld (ORCPT + 99 others); Mon, 14 Oct 2019 04:41:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42968 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730281AbfJNIlc (ORCPT ); Mon, 14 Oct 2019 04:41:32 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7727C10CC1F7; Mon, 14 Oct 2019 08:41:32 +0000 (UTC) Received: from [10.36.117.10] (ovpn-117-10.ams2.redhat.com [10.36.117.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A62A5D6A3; Mon, 14 Oct 2019 08:41:31 +0000 (UTC) Subject: Re: [PATCH v2 2/2] mm/memory-failure.c: Don't access uninitialized memmaps in memory_failure() To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Naoya Horiguchi , Andrew Morton , Michal Hocko References: <20191009142435.3975-1-david@redhat.com> <20191009142435.3975-3-david@redhat.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <1c61f433-74a0-73ca-0a8b-9ac7252ec6f8@redhat.com> Date: Mon, 14 Oct 2019 10:41:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: <20191009142435.3975-3-david@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Mon, 14 Oct 2019 08:41:32 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09.10.19 16:24, 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); > if (PageHuge(p)) > return memory_failure_hugetlb(pfn, flags); > if (TestSetPageHWPoison(p)) { > @Andrew, can you add Fixes: f1dd2cd13c4b ("mm, memory_hotplug: do not associate hotadded memory to zones until online") # visible after d0dc12e86b319 And Cc: stable@vger.kernel.org # v4.13+ The stable backports won't be clean cherry-picks AFAIKS, but do-able. -- Thanks, David / dhildenb