Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1019290ybp; Wed, 9 Oct 2019 07:44:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7VXTIfzOU7v1WhYznUWR5/ihFLzTasQYM6gy9Eo7OLnCsiR0I+y284vY2MWK7rJ2fR4wF X-Received: by 2002:a50:c2c2:: with SMTP id u2mr3356206edf.133.1570632271493; Wed, 09 Oct 2019 07:44:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570632271; cv=none; d=google.com; s=arc-20160816; b=ZuV+CsWOA0pCzYeZL2AJssf5wUVPGnKXp+T8E7QnrocOXZqHp32BOWxhS8QbpZfUuK bMYzj+NzH1QKE8gAUitmlaU8jNxeWihImGUUcPGBiFH9gRzSu0hkWkJLBV7nicRli8oN AMD8sD7FueteF8aeh+XVset6ovaFMvNFNPWzGw6J7CEaDWJJBjOMflW3Y9S+JK0WBgar NXzf6uSE2d1PtduM/hzAJrDKZ71bzKZaC0fpPNYY8ib4xHJSJI4N9KjGf3OS2n6X0mCd 7RXteFf98UHxmDZtBPF94JUpiUwcEgScPIv4HOnec76A5AmsEAWvYSrXV4Yxmb8jV3v4 EBSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=zTdJ+ea72aPx3YmbMLC2bYo/NxReybsbyhEBFCrucvM=; b=iQoY7l7lsp1cayiqtSSU3PlOMuNbIEmgPOsS3Cn0zl4CR6p4lbhrJDVQp9gnN4uIeY PE9oVGkcPtT0R0AgoNyeYnidQ6HBd4Q/O46Q4h5/M9f771Re9CR1mrX+bMhsC9N9dnS+ 0Zs6/0NFx8vUx7cnE3WvDOduDjI/tzsMaD/hvoqqe44OfTZCO9Z7BCzlRmqRySjTil8C vGj4xL8aToIVmxE6uuUHaByHzMDCtFCJqZsNxgZRYEFCr7l29hkYYtbG9A0eOa9psInC PNFs9RKA9qjPEddQcG4ojkmCUkA/+ZoiJYfUGE19fQIhoWdfPprJeb0dNNjkD0SKl8Xs U+5Q== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si1217108eju.422.2019.10.09.07.44.06; Wed, 09 Oct 2019 07:44:31 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731552AbfJIOnZ (ORCPT + 99 others); Wed, 9 Oct 2019 10:43:25 -0400 Received: from mx2.suse.de ([195.135.220.15]:35940 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730674AbfJIOnZ (ORCPT ); Wed, 9 Oct 2019 10:43:25 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A297DAD12; Wed, 9 Oct 2019 14:43:23 +0000 (UTC) Date: Wed, 9 Oct 2019 16:43:23 +0200 From: Michal Hocko To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Naoya Horiguchi , Andrew Morton Subject: Re: [PATCH v2 2/2] mm/memory-failure.c: Don't access uninitialized memmaps in memory_failure() Message-ID: <20191009144323.GH6681@dhcp22.suse.cz> References: <20191009142435.3975-1-david@redhat.com> <20191009142435.3975-3-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191009142435.3975-3-david@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 09-10-19 16:24:35, 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; Don't we need that earlier at hwpoison_inject level? -- Michal Hocko SUSE Labs