From patchwork Mon Jul 2 15:27:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Tatashin X-Patchwork-Id: 10501907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 42E5160284 for ; Mon, 2 Jul 2018 15:28:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3110D27FB3 for ; Mon, 2 Jul 2018 15:28:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23B9B28C99; Mon, 2 Jul 2018 15:28:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D31D528C96 for ; Mon, 2 Jul 2018 15:27:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D9706B0003; Mon, 2 Jul 2018 11:27:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 989406B0005; Mon, 2 Jul 2018 11:27:58 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A07A6B0006; Mon, 2 Jul 2018 11:27:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ua0-f198.google.com (mail-ua0-f198.google.com [209.85.217.198]) by kanga.kvack.org (Postfix) with ESMTP id 58B8E6B0003 for ; Mon, 2 Jul 2018 11:27:58 -0400 (EDT) Received: by mail-ua0-f198.google.com with SMTP id j5-v6so4688292uap.16 for ; Mon, 02 Jul 2018 08:27:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:subject:date:message-id; bh=7JVta26K3EWVK9Ef4HUOSNMhHsGCCm/X3kHEZ+2IeBY=; b=lyLpjVV77pl9a8YU+VsV6v62QiegmCr6MPBuCkWOLS5v0quZX9ZYpL9lj3qiYO8Lq6 EjkvH3X0z9cxljSYrapuJQiKX4tQcK8daPKc4oURsPDo/bvvwau289lRaYeUonLKwUqk T1aIsv8ZyL5MQNwxY/W82rVy39rOFaVxz8kgJR8ao2m55ZieXjR6Med7+kZiHA265OBg igefpoP8PG1grtd0xc3JdY4b8NAuQwhwnKmK9inMi7hkvQS/p3gbbVDVzcptYJff/Ni5 oErAiRcHV6ZtKGBQdLlpiymASgzRA4VCsT9B8rQmsb107y910Q/j+nPkxLqHdLKwopik o4Gg== X-Gm-Message-State: APt69E2vsS5u1I1C0R3sOuFnfD3PRNNDGZE90XLX7DMeGvmgrhMpseCY b4C6GT/mO2n9OydgQpGFnakZ769SN38YZu6LidA+wvOIN4MEdzd7F9d/4whsHbILTL+c6JTnTkS U6iqvJnJiLAQTE/UGoHWKMm8TUb9xjNc3SIKJhQD0vrdjdDhf2M8dzaAVkZb2rPG6uQ== X-Received: by 2002:a1f:2444:: with SMTP id k65-v6mr15817262vkk.115.1530545277985; Mon, 02 Jul 2018 08:27:57 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeR3qrh2rEkg+ZswVC+CxketKMsX43124dS6NFJ4wM6b+DssnEnlD4u233bfEvrE9zzgeIt X-Received: by 2002:a1f:2444:: with SMTP id k65-v6mr15817242vkk.115.1530545276976; Mon, 02 Jul 2018 08:27:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530545276; cv=none; d=google.com; s=arc-20160816; b=ZtF3aqGtt0knMGl8rQ67s8ESN324zwR+KWRAY/yUZasDJucZ1Ud+7P1BRTyBtAhtKX ygQprqNgXgaFCDh+nKcCnLtG47ETDRlkURZxA/xCwpLP3rNJl1dc33qfwhZrw2npazMo kuzfLhD2l2tdxdDjouGAZOgvsS+BN2kf374GRkasRXJ6P+Sx4tMo+tf5q04NHglgQ7kB 9I7XXg36pR3zwfoAjLw3A19FW43qVxluUWCi/F1APXrR15ETkqoKC3/T3gJ7xXcI5vFX 78GRlrGA86SWU4jQKJrKIIWcKGhZp3FUaFztEGNPWf23q1z0mlrcvfbo8vG8NqFbSjsE HCCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:dkim-signature :arc-authentication-results; bh=7JVta26K3EWVK9Ef4HUOSNMhHsGCCm/X3kHEZ+2IeBY=; b=V2otxf9ybfjQjaaIiQuTDQat11gJ9wqnsmh3tBUSW7WMpOFUeJToQ6zvQg8W0gBV60 oPNoERe9RiYRcbWHdOw5J58O1cVGhdW3z57/WGY6bacXEugLzI9Zhy1UM7wsIkCtZXzW 1TOx6OaQQ6/AzungCfi4cj/MLhLYWwaQLMciZTL+pksOGHMp2730jkLRLG5iN30kDlKT 7B4MgGzgxVhEyRT9xYpX2TsL6zZ0ICaFLLwtbj3m645Zzj2/DqBwb7Vd/zsMNgDa4Mt8 4t/mqDCMCJuuloVgc83ssNGyZ1V/SrJB8Yn3k+9+RQTO/WeRJue+rXjudhJlAQRQV5IZ MxVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=ez4NJT9j; spf=pass (google.com: domain of pasha.tatashin@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=pasha.tatashin@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2120.oracle.com (userp2120.oracle.com. [156.151.31.85]) by mx.google.com with ESMTPS id i1-v6si3829689uai.169.2018.07.02.08.27.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 08:27:56 -0700 (PDT) Received-SPF: pass (google.com: domain of pasha.tatashin@oracle.com designates 156.151.31.85 as permitted sender) client-ip=156.151.31.85; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=ez4NJT9j; spf=pass (google.com: domain of pasha.tatashin@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=pasha.tatashin@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w62FNhXW059281; Mon, 2 Jul 2018 15:27:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id; s=corp-2017-10-26; bh=7JVta26K3EWVK9Ef4HUOSNMhHsGCCm/X3kHEZ+2IeBY=; b=ez4NJT9jXd/9sAGgqM0Hbr2LszyOIZkbFq3gqEPEkwZSuxdcYFNQI1txdUWBDGFVockX 3613pMoqDicXJRO64eHUYElEbe+CFl/4LrFu3gc3S96va6S0u47+9Mc19M3+83lZEkzD d9hV3SSTWw9Oz1T/4H4F4cvzOOKzOjeD3UvVeIk0ENYE3bIWsi6q4UU7DB3/yjRPRzTR Mt9RkpZvt3ipEpn/rNNiX68ZQrEQXDgsGuY7/bnXHjqv+SZS9PLbUzDYph+OXXCpefUy k1cwMrZHtk/fdr8Ndkh7S6StK1/4tzOXJ1jLqHgs+RCHIwq6nvPODU2bFKYpDbMI1Bdi IA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2jx2gpvx64-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 02 Jul 2018 15:27:53 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w62FRpYG026287 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 2 Jul 2018 15:27:51 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w62FRoTu022580; Mon, 2 Jul 2018 15:27:50 GMT Received: from localhost.localdomain (/73.69.118.222) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 02 Jul 2018 08:27:49 -0700 From: Pavel Tatashin To: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, mhocko@suse.com, linux-mm@kvack.org, mgorman@techsingularity.net, gregkh@linuxfoundation.org, pasha.tatashin@oracle.com Subject: [PATCH] mm: teach dump_page() to correctly output poisoned struct pages Date: Mon, 2 Jul 2018 11:27:45 -0400 Message-Id: <20180702152745.27596-1-pasha.tatashin@oracle.com> X-Mailer: git-send-email 2.18.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8941 signatures=668704 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807020176 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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. 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 }