From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.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,USER_AGENT_GIT autolearn=unavailable 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 31BCCC10F05 for ; Mon, 1 Apr 2019 18:07:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 045AB20880 for ; Mon, 1 Apr 2019 18:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554142021; bh=0xeruuBJBUdy3uFD0FBfyGBgD4qwEx+T8UsGvLSsGaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jLyB9Zbrykl5OQxeHIkAWazNVdyIEUsxkDb6QO6uV4wYnsENJ9pv9w5Dm+CGCg9Lm sbrEnS+ifg3wz6LTFI9qLiiLyX7QOl5/YVza5a0EJuud+iq+lJwUJUConORI10ONQD A3dxTJUiwANDfCbG4qMWpxYfaOulEgLIEHEA+5FU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730317AbfDARMF (ORCPT ); Mon, 1 Apr 2019 13:12:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:33214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729110AbfDARME (ORCPT ); Mon, 1 Apr 2019 13:12:04 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 601BE21925; Mon, 1 Apr 2019 17:12:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554138723; bh=0xeruuBJBUdy3uFD0FBfyGBgD4qwEx+T8UsGvLSsGaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tW7ySA+Im+fkWj6CpaX3zuSOybPaPtMLWTuvCQAhT1uV9t1PSZhd10lD/bby67mN4 S/cz48XBOJyJiy0OWdqbEd1gTBLiYWbrKVFCli0oVBxnJBVRqSOmz24w5bCMnxuJA2 Pn66T74FXCk2iRr7tGZhP45sVSIDgQ6mx+o09+3A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oscar Salvador , Michal Hocko , Hugh Dickins , Andrew Morton , Linus Torvalds Subject: [PATCH 5.0 129/146] mm/debug.c: fix __dump_page when mapping->host is not set Date: Mon, 1 Apr 2019 19:02:21 +0200 Message-Id: <20190401170059.158292132@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401170048.449559024@linuxfoundation.org> References: <20190401170048.449559024@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 5.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Oscar Salvador commit 5ae2efb1dea9f537453e841714e3ee2757595aec upstream. 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 Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/debug.c +++ b/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);