Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4094989pxj; Tue, 11 May 2021 20:17:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwP0iMGCHTL6msCmEbXJd0UP8nuKEt865n2eb7kJa/eef1LUbfxcRdfBo+cDd08bp+BLRw X-Received: by 2002:a5d:8a16:: with SMTP id w22mr1954103iod.186.1620789431112; Tue, 11 May 2021 20:17:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620789431; cv=none; d=google.com; s=arc-20160816; b=Y4LOo8j61OLohaWprbY2toQ+F2mk3wnapg13bNB+yHud6UqU9oEh+IQQ4Yaz/MsXOt SLa7oqCFp3Ju5a5TumhXYfO/wrFiULXxuTIUL6ZhJKmnLJnWtcpf0w0/TLxUPZeyDr1C MnIQwakRUg0jXvHuGupwfhh6qEKoycFoj+c41ckRGZjz4DCmgiGAFzUWWDRhCB1UlHBT Qpa6msPuJkx8GEyANytgpJ1utPibpycxZcqMwo3ejL/MAkHKol8gqkecNGwdYsLHfeqq iYB4h4Ju/BUGWSzytXg/fax0Yid0QxE/1+hB9f/ikvDTboen4eB796ttRMDn6+nN5X0/ 1TUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=b3q1cOi5vzb/fYvgXV1ILp6S0UFGe9AtTSyL/tGSRuc=; b=eb2+sN3SKuvG1/sf3oHAamr2JDTyGM502HwgeDHKzTZaFxeHg4AIYea0mXhRvLWO9F GIkZxZrLxozLXt5Savy4wFUhwsJNKm1z/zV/VYiSUt+LCtMsL8HWcCXlUaPrT/E5q91o fkm6uBtEBUXcpECh3PUhKmzuiHpIO1hNemiOJ+S5bn69INNDvNaKTE0sven7xHh1Lq5L Zar631X/yxZOU4EsPidCkYxjSaKycczSG5h5URJjablMUsWPyXSVGFAiyAY17o1Afv45 Rnv7ena6GqEHDjx1KTrBpGmtqexmcUEwIZCyk6Xgn2GFZqCzaZv+uyghRbX/H0VFlLvI kJ0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=v7uCNGf4; 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 x9si6277595jas.106.2021.05.11.20.16.59; Tue, 11 May 2021 20:17:11 -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=@infradead.org header.s=casper.20170209 header.b=v7uCNGf4; 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 S229954AbhELDRC (ORCPT + 99 others); Tue, 11 May 2021 23:17:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229848AbhELDRC (ORCPT ); Tue, 11 May 2021 23:17:02 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A2DCC061574 for ; Tue, 11 May 2021 20:15:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=b3q1cOi5vzb/fYvgXV1ILp6S0UFGe9AtTSyL/tGSRuc=; b=v7uCNGf4pSOH3gT0X6IjJcmOHy JI9VLLn7NG+T1g8+fnu/w62HMsQbejNHTFcV3+ygfzu/NIIUBqe6ZjZTumpwYMqUv3Zd3eyHxz1vF 3oe+WHrz8qHgArXsllzikF9Gjg1WPqob0mFeHjDAg1/M6LpV/5RfuVLYhcDvBYAhRb2C82QP+zart 52ppKfh4FYvku2hRRvDc0HGfffDtqOO5Etg28OxY6naqBhTZ+pstUX4HYY58nfsM5Mykb9tIIKZpm mO+sJqw9s9OuT1rpXJCxAk/m1Q42eqP99HTHNV7vZGlQofAIjIE1wsAsdligDMqc2/WFXyOOhnZTl io6C0rRw==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lgfLB-007taj-9F; Wed, 12 May 2021 03:15:28 +0000 Date: Wed, 12 May 2021 04:15:17 +0100 From: Matthew Wilcox To: Kefeng Wang Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] mm/debug: Check page poisoned firstly in dump_page() Message-ID: References: <20210512031057.13580-1-wangkefeng.wang@huawei.com> <20210512031057.13580-3-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210512031057.13580-3-wangkefeng.wang@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 12, 2021 at 11:10:57AM +0800, Kefeng Wang wrote: > If page is poisoned, it will crash when we call some page related > functions, so must check whether the page is poisoned or not firstly. https://lore.kernel.org/linux-mm/20210430145549.2662354-4-willy@infradead.org/ > Fixes: 6197ab984b41 ("mm: improve dump_page() for compound pages") > Signed-off-by: Kefeng Wang > --- > mm/debug.c | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/mm/debug.c b/mm/debug.c > index 84cdcd0f7bd3..cf84cd9df527 100644 > --- a/mm/debug.c > +++ b/mm/debug.c > @@ -44,20 +44,19 @@ const struct trace_print_flags vmaflag_names[] = { > > static void __dump_page(struct page *page, const char *reason) > { > - struct page *head = compound_head(page); > + struct page *head = NULL; > struct address_space *mapping; > - bool page_poisoned = PagePoisoned(page); > - bool compound = PageCompound(page); > + bool compound; > /* > * Accessing the pageblock without the zone lock. It could change to > * "isolate" again in the meantime, but since we are just dumping the > * state for debugging, it should be fine to accept a bit of > * inaccuracy here due to racing. > */ > - bool page_cma = is_migrate_cma_page(page); > + bool page_cma; > int mapcount; > char *type = ""; > - > + bool page_poisoned = PagePoisoned(page); > /* > * If struct page is poisoned don't access Page*() functions as that > * leads to recursive loop. Page*() check for poisoned pages, and calls > @@ -68,6 +67,10 @@ static void __dump_page(struct page *page, const char *reason) > goto hex_only; > } > > + head = compound_head(page); > + page_poisoned = PagePoisoned(page); > + page_cma = is_migrate_cma_page(page); > + > if (page < head || (page >= head + MAX_ORDER_NR_PAGES)) { > /* > * Corrupt page, so we cannot call page_mapping. Instead, do a > @@ -178,7 +181,7 @@ static void __dump_page(struct page *page, const char *reason) > print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32, > sizeof(unsigned long), page, > sizeof(struct page), false); > - if (head != page) > + if (head && head != page) > print_hex_dump(KERN_WARNING, "head: ", DUMP_PREFIX_NONE, 32, > sizeof(unsigned long), head, > sizeof(struct page), false); > -- > 2.26.2 > >