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=-3.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 78735C43331 for ; Fri, 3 Apr 2020 12:19:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0DD9D20737 for ; Fri, 3 Apr 2020 12:19:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="DzUeiEZ7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0DD9D20737 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5E8D78E0008; Fri, 3 Apr 2020 08:19:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 599428E0007; Fri, 3 Apr 2020 08:19:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 488798E0008; Fri, 3 Apr 2020 08:19:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0249.hostedemail.com [216.40.44.249]) by kanga.kvack.org (Postfix) with ESMTP id 2EAE98E0007 for ; Fri, 3 Apr 2020 08:19:51 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E3EFF6103 for ; Fri, 3 Apr 2020 12:19:50 +0000 (UTC) X-FDA: 76666450140.28.loaf61_38d9e95d2f017 X-HE-Tag: loaf61_38d9e95d2f017 X-Filterd-Recvd-Size: 5645 Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Fri, 3 Apr 2020 12:19:50 +0000 (UTC) Received: by mail-lj1-f196.google.com with SMTP id r7so6645415ljg.13 for ; Fri, 03 Apr 2020 05:19:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=g/ynuYjJt7Qm1NRNhiAHFZpsxO5RlOPe2UghsFzLBKM=; b=DzUeiEZ7cwkwl5tdjKkU98tl91HYziVlmcmErrC1AH3nBpIUo/DPaOAJ605N0VK12S l/uxhlKaw5EoY1L/1gdEwRnU/7TMHBUfzlbZL6bSUs4lGftmFqrfk4AWEhV9GFrAYyst ejqIngi5DPgXuN6Noa2W/P7OGwx2HYGauYzD0dqpYc/+03ikuHgxxlo5uc3QQ3Nbu4Jg 411RYmp8GpTrlqHkmvbC1hHp0XlpvhY3EvFEgb5xXG2Laggv9pZA0BcwhZEcFUou17Tg +AEGMOq0Rbv4vgnBXrS724vzIf6gCsZdCOF5kBdkQtzuUGGr1TWFyNSOSJ8mu50Ljnuz jNPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=g/ynuYjJt7Qm1NRNhiAHFZpsxO5RlOPe2UghsFzLBKM=; b=K1i05gfUysLhwPROaFmb3fYuDAMfysUCB+Q5M3VGK2CZk35dWyBoas84fc+TQ+KZs3 cZGd6OJpa+pIWONZuOaA4fjShzSlYU/I/btxoQRSywwWSK43V7fbqToNn2Ngn4qAcxtt jlNDdPS218IPB2fMI7Sb3FLfHUT2KSJw7iriFvvH1XB2GDVKt3u9M7tQDoDtJDxD6GYv QSs+2j1LNyis0/sf280e39FjZ4XbAwnJ7Y3tJk4lIgLPo0/ZUe7Bo+VAovuKJXVjDuly DDqbaQuoGgqznn8E5ucTnq9aRV6+/8xa/sN1PqH2c9oNvTc8JXbteUd61rYSXPOZNIlm ZFMA== X-Gm-Message-State: AGi0PuY3yIZWZUhGMWGPJIRtNDB1V/1rsygho9xUlgORQlekKn+s9HVw jQM1sMxMgZ5BjXadjK0n5aHJwrlBJXE= X-Google-Smtp-Source: APiQypK33qY7ePoFZ2Cih5owCFLqMBrh9ojn/DSWQVBEZFJXNA1avafYNNQjzI3nlOb68pyibjWVnA== X-Received: by 2002:a2e:3c0a:: with SMTP id j10mr4729637lja.205.1585916388999; Fri, 03 Apr 2020 05:19:48 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id l21sm6739854lfh.63.2020.04.03.05.19.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 05:19:48 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id AF97B10132C; Fri, 3 Apr 2020 15:19:47 +0300 (+03) Date: Fri, 3 Apr 2020 15:19:47 +0300 From: "Kirill A. Shutemov" To: Vlastimil Babka Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Matthew Wilcox , John Hubbard , "Kirill A. Shutemov" , Petr Tesarik Subject: Re: [PATCH] mm, dump_page(): do not crash with invalid mapping pointer Message-ID: <20200403121947.sk5oif775op6mubk@box> References: <20200331165454.12263-1-vbabka@suse.cz> <20200401140544.pkhgfmo5pks3dw6v@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Thu, Apr 02, 2020 at 10:30:35AM +0200, Vlastimil Babka wrote: > 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 Crash fast, crash often :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. Okay, fair enough. Acked-by: Kirill A. Shutemov -- Kirill A. Shutemov