From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755501AbdESOtB (ORCPT ); Fri, 19 May 2017 10:49:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:54601 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755351AbdESOs7 (ORCPT ); Fri, 19 May 2017 10:48:59 -0400 Date: Fri, 19 May 2017 16:48:56 +0200 From: Michal Hocko To: Firo Yang Cc: akpm@linux-foundation.org, vbabka@suse.cz, mgorman@techsingularity.net, hannes@cmpxchg.org, bigeasy@linutronix.de, iamjoonsoo.kim@lge.com, rientjes@google.com, hughd@google.com, cl@linux.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm, vmstat: Fix NULL pointer dereference during pagetypeinfo print Message-ID: <20170519144856.GK29839@dhcp22.suse.cz> References: <20170519143936.21209-1-firogm@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170519143936.21209-1-firogm@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 19-05-17 22:39:36, Firo Yang wrote: > During showing the pagetypeinfo, we forgot to save the found page > and dereference a invalid page address from the stack. > > To fix it, save and reference the page address returned by > pfn_to_online_page(). Thanks for taking catching that and your fix. I have already posted a fix http://lkml.kernel.org/r/20170519072225.GA13041@dhcp22.suse.cz earlier today. Sorry about troubles > Signed-off-by: Firo Yang > --- > mm/vmstat.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/vmstat.c b/mm/vmstat.c > index c432e58..6dae6b2 100644 > --- a/mm/vmstat.c > +++ b/mm/vmstat.c > @@ -1223,7 +1223,8 @@ static void pagetypeinfo_showblockcount_print(struct seq_file *m, > for (pfn = start_pfn; pfn < end_pfn; pfn += pageblock_nr_pages) { > struct page *page; > > - if (!pfn_to_online_page(pfn)) > + page = pfn_to_online_page(pfn); > + if (!page) > continue; > > /* Watch for unexpected holes punched in the memmap */ > -- > 2.9.4 > -- Michal Hocko SUSE Labs