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=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 5F509C43331 for ; Thu, 2 Apr 2020 08:30:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0C6032078E for ; Thu, 2 Apr 2020 08:30:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C6032078E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B6A228E0008; Thu, 2 Apr 2020 04:30:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF37F8E0007; Thu, 2 Apr 2020 04:30:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E2CA8E0008; Thu, 2 Apr 2020 04:30:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0134.hostedemail.com [216.40.44.134]) by kanga.kvack.org (Postfix) with ESMTP id 7F5F48E0007 for ; Thu, 2 Apr 2020 04:30:39 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 41DD175A6 for ; Thu, 2 Apr 2020 08:30:39 +0000 (UTC) X-FDA: 76662243798.16.ink79_22c2a1b539a3d X-HE-Tag: ink79_22c2a1b539a3d X-Filterd-Recvd-Size: 3307 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Thu, 2 Apr 2020 08:30:38 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 080ABACC6; Thu, 2 Apr 2020 08:30:37 +0000 (UTC) Subject: Re: [PATCH] mm, dump_page(): do not crash with invalid mapping pointer To: "Kirill A. Shutemov" Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Matthew Wilcox , John Hubbard , "Kirill A. Shutemov" , Petr Tesarik References: <20200331165454.12263-1-vbabka@suse.cz> <20200401140544.pkhgfmo5pks3dw6v@box> From: Vlastimil Babka Message-ID: Date: Thu, 2 Apr 2020 10:30:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200401140544.pkhgfmo5pks3dw6v@box> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: On 4/1/20 4:05 PM, Kirill A. Shutemov wrote: > On Tue, Mar 31, 2020 at 06:54:54PM +0200, Vlastimil Babka wrote: >> We have seen a following problem on a RPi4 with 1G RAM: >> >> Besides the underlying issue with page->mapping containing a bogus value for >> some reason, we can see that __dump_page() crashed by trying to read the >> pointer at mapping->host, turning a recoverable warning into full Oops. >> >> It can be expected that when page is reported as bad state for some reason, the >> pointers there should not be trusted blindly. So this patch treats all data in >> __dump_page() that depends on page->mapping as lava, using >> probe_kernel_read_strict(). Ideally this would include the dentry->d_parent >> recursively, but that would mean changing printk handler for %pd. Chances of >> reaching the dentry printing part with an initially bogus mapping pointer >> should be rather low, though. >> >> Also prefix printing mapping->a_ops with a description of what is being >> printed. In case the value is bogus, %ps will print raw value instead of >> the symbol name and then it's not obvious at all that it's printing a_ops. >> >> Reported-by: Petr Tesarik >> Signed-off-by: Vlastimil Babka >> --- >> mm/debug.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++------ >> 1 file changed, 50 insertions(+), 6 deletions(-) > > I'm not sure it worth the effort. It looks way too complex for what it > does. Well the human effort is done, and CPU cycles are cheap :P Complex is better than to crash, IMHO. > I also expect it to slowdown dump_page(), which is hotpath for some debug > scenarios :P It's still a debug code, better safe than fast :P > Maybe just move printing this info to the end, so we would see the rest > even if ->mapping is bogus? Well the thing is designed to be recoverable. Just today "mm: improve dump_page() for compound pages" was merged that AFAICS prevents similar crashes when the compound_head() is bogus.