Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0BB5C43381 for ; Fri, 29 Mar 2019 03:44:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 95D8420693 for ; Fri, 29 Mar 2019 03:44:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553831044; bh=4cqClj1gHjcpL2r1Y66vJH6VAO95hypCFem9gTKRpeE=; h=Date:From:To:Subject:List-ID:From; b=h1e3StdVWU/F7eeO3Zjtjb//ElcOqJgSoZUInLACDJRWmP0vnt7+aHPi3kGb5u9bQ mNjvS12iQlQsSHdUypLb/GDwmZwsYU0BxGLX9zQVRLXRVIjZqH2RQJ+pOimvuKJW2e zNZboMwxN7X1gPPluh1BrPm2JtCrRk4NLpnYLBmo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728648AbfC2DoE (ORCPT ); Thu, 28 Mar 2019 23:44:04 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48790 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727675AbfC2DoE (ORCPT ); Thu, 28 Mar 2019 23:44:04 -0400 Received: from localhost.localdomain (c-73-223-200-170.hsd1.ca.comcast.net [73.223.200.170]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1D7D4B79; Fri, 29 Mar 2019 03:44:03 +0000 (UTC) Date: Thu, 28 Mar 2019 20:44:01 -0700 From: akpm@linux-foundation.org To: akpm@linux-foundation.org, hughd@google.com, mhocko@suse.com, mm-commits@vger.kernel.org, osalvador@suse.de, stable@vger.kernel.org, torvalds@linux-foundation.org Subject: [patch 12/22] mm/debug.c: fix __dump_page when mapping->host is not set Message-ID: <20190329034401.mwSHC5mTM%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Oscar Salvador Subject: mm/debug.c: fix __dump_page when mapping->host is not set While debugging something, I added a dump_page() into do_swap_page(), and I got the splat from below. The issue happens when dereferencing mapping->host in __dump_page(): ... else if (mapping) { pr_warn("%ps ", mapping->a_ops); if (mapping->host->i_dentry.first) { struct dentry *dentry; dentry = container_of(mapping->host->i_dentry.first, struct dentry, d_u.d_alias); pr_warn("name:\"%pd\" ", dentry); } } ... Swap address space does not contain an inode information, and so mapping->host equals NULL. Although the dump_page() call was added artificially into do_swap_page(), I am not sure if we can hit this from any other path, so it looks worth fixing it. We can easily do that by checking mapping->host first. Link: http://lkml.kernel.org/r/20190318072931.29094-1-osalvador@suse.de Fixes: 1c6fb1d89e73c ("mm: print more information about mapping in __dump_page") Signed-off-by: Oscar Salvador Acked-by: Michal Hocko Acked-by: Hugh Dickins Cc: Signed-off-by: Andrew Morton --- mm/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/debug.c~mm-fix-__dump_page-when-mapping-host-is-not-set +++ a/mm/debug.c @@ -79,7 +79,7 @@ void __dump_page(struct page *page, cons pr_warn("ksm "); else if (mapping) { pr_warn("%ps ", mapping->a_ops); - if (mapping->host->i_dentry.first) { + if (mapping->host && mapping->host->i_dentry.first) { struct dentry *dentry; dentry = container_of(mapping->host->i_dentry.first, struct dentry, d_u.d_alias); pr_warn("name:\"%pd\" ", dentry); _