From: Vlastimil Babka <vbabka@suse.cz>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Matthew Wilcox <willy@infradead.org>,
John Hubbard <jhubbard@nvidia.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Petr Tesarik <ptesarik@suse.cz>
Subject: Re: [PATCH] mm, dump_page(): do not crash with invalid mapping pointer
Date: Thu, 2 Apr 2020 10:30:35 +0200 [thread overview]
Message-ID: <a5ebb5eb-ccda-eb74-422c-cddea792894f@suse.cz> (raw)
In-Reply-To: <20200401140544.pkhgfmo5pks3dw6v@box>
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 <ptesarik@suse.cz>
>> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
>> ---
>> 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.
next prev parent reply other threads:[~2020-04-02 8:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-31 16:54 [PATCH] mm, dump_page(): do not crash with invalid mapping pointer Vlastimil Babka
2020-04-01 14:05 ` Kirill A. Shutemov
2020-04-02 8:30 ` Vlastimil Babka [this message]
2020-04-03 12:19 ` Kirill A. Shutemov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a5ebb5eb-ccda-eb74-422c-cddea792894f@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=jhubbard@nvidia.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ptesarik@suse.cz \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).