Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp140530imm; Mon, 2 Jul 2018 09:00:51 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfbSF1qyG/EuKGLNfn1mkKFpINxyWzlMihFUuNjiBRZ0Ep3fbyun8ohcgjI1HiTLVjo/B7s X-Received: by 2002:a65:6188:: with SMTP id c8-v6mr20900036pgv.432.1530547251795; Mon, 02 Jul 2018 09:00:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530547251; cv=none; d=google.com; s=arc-20160816; b=jr+DQ1/D8SjefAZoX14XBMMQFdacRnqk7YWRflPM18NYyPLlx9qP/ZM/s/COmhC8FC VrRpVLSw3/e1I8abA6jIB/9whzXi0Falm98zbqaE0+sw4T3UopWuGgDoag13uiBAQoeP vICfSxfTWBzXbMPhCi5V9tw02J1W1IEnd2EZiX0+Cf4TtAniaAXBYPs2jw+ApQKGnZ3n b9sCNn1Whyz1Gw38vM7z8j6q3s23Fy3INaH2k4lIccWYiZNqn1o0R/VDgQFhoEZbI6RR bLNxJ8S0IscGrRYcwHW7mfNSbNw+tNO9PmNyTd1UFJkE9eunBLYcrM7QrEDkGURPjd5F jgCw== 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:arc-authentication-results; bh=LkPhLXBLLSlyX7rP/f2F1vPK/cGUIyU5NN6krhu5sUI=; b=poqBvKnhAr1fueBPK08LLJ/k7ZOECw2w/8TGIbqZzErWVChy4jAQexRAEKftrI7t+s cY/8kM9Pop5IoYYjuAS50aFmY0DfORdAu5o6KKD+w8NmX1agRPUIF0OBSIM0LyvnNS8C K/IKIPzFhcscFOUDBYdsGmEJPocBrzXh4PL9qg7Nv+ekxEOm2nsVY7jxOT/yOskjLUET QvTBy2Ssog9k2+ixQczfP5UmrvFVrQCT6i/vY1Z6QtHH/aiNWhAe2p7v5KS+KU9ebqRW WhH667CMzIUhHlwLW9mcVyj4GNBSMbLFIGkQxS5zxi5mKw1A+eiwDnmw2cS51qdL0+OG 3O2A== 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 61-v6si16494336plr.483.2018.07.02.09.00.36; Mon, 02 Jul 2018 09:00:51 -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 S1752508AbeGBP7C (ORCPT + 99 others); Mon, 2 Jul 2018 11:59:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:53514 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752184AbeGBP7B (ORCPT ); Mon, 2 Jul 2018 11:59:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 51593AD0E; Mon, 2 Jul 2018 15:59:00 +0000 (UTC) Date: Mon, 2 Jul 2018 17:58:58 +0200 From: Michal Hocko To: Pavel Tatashin Cc: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, linux-mm@kvack.org, mgorman@techsingularity.net, gregkh@linuxfoundation.org Subject: Re: [PATCH] mm: teach dump_page() to correctly output poisoned struct pages Message-ID: <20180702155858.GE19043@dhcp22.suse.cz> References: <20180702152745.27596-1-pasha.tatashin@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180702152745.27596-1-pasha.tatashin@oracle.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 02-07-18 11:27:45, Pavel Tatashin wrote: > If struct page is poisoned, and uninitialized access is detected via > PF_POISONED_CHECK(page) dump_page() is called to output the page. But, > the dump_page() itself accesses struct page to determine how to print > it, and therefore gets into a recursive loop. > > For example: > dump_page() > __dump_page() > PageSlab(page) > PF_POISONED_CHECK(page) > VM_BUG_ON_PGFLAGS(PagePoisoned(page), page) > dump_page() recursion loop. This deserves a big fat comment in __dump_page. Basically no Page$FOO can be used on an HWPoison page. > Fixes: f165b378bbdf ("mm: uninitialized struct page poisoning sanity checking") > Signed-off-by: Pavel Tatashin Acked-by: Michal Hocko > --- > mm/debug.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/mm/debug.c b/mm/debug.c > index 56e2d9125ea5..469b526e6abc 100644 > --- a/mm/debug.c > +++ b/mm/debug.c > @@ -43,12 +43,20 @@ const struct trace_print_flags vmaflag_names[] = { > > void __dump_page(struct page *page, const char *reason) > { > + bool page_poisoned = PagePoisoned(page); > + int mapcount; > + > + if (page_poisoned) { > + pr_emerg("page:%px is uninitialized and poisoned", page); > + goto hex_only; > + } > + > /* > * Avoid VM_BUG_ON() in page_mapcount(). > * page->_mapcount space in struct page is used by sl[aou]b pages to > * encode own info. > */ > - int mapcount = PageSlab(page) ? 0 : page_mapcount(page); > + mapcount = PageSlab(page) ? 0 : page_mapcount(page); > > pr_emerg("page:%px count:%d mapcount:%d mapping:%px index:%#lx", > page, page_ref_count(page), mapcount, > @@ -60,6 +68,7 @@ void __dump_page(struct page *page, const char *reason) > > pr_emerg("flags: %#lx(%pGp)\n", page->flags, &page->flags); > > +hex_only: > print_hex_dump(KERN_ALERT, "raw: ", DUMP_PREFIX_NONE, 32, > sizeof(unsigned long), page, > sizeof(struct page), false); > @@ -68,7 +77,7 @@ void __dump_page(struct page *page, const char *reason) > pr_alert("page dumped because: %s\n", reason); > > #ifdef CONFIG_MEMCG > - if (page->mem_cgroup) > + if (!page_poisoned && page->mem_cgroup) > pr_alert("page->mem_cgroup:%px\n", page->mem_cgroup); > #endif > } > -- > 2.18.0 > -- Michal Hocko SUSE Labs