From: Andrew Morton <akpm@linux-foundation.org>
To: "xiaosong.ma" <Xiaosong.Ma@unisoc.com>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
Zhaoyang Huang <huangzhaoyang@gmail.com>, <ke.wang@unisoc.com>
Subject: Re: [PATCH] mm: check mapping addr is correct when dump page
Date: Tue, 4 Apr 2023 14:17:22 -0700 [thread overview]
Message-ID: <20230404141722.45dbdc377e7e1547e302ffa5@linux-foundation.org> (raw)
In-Reply-To: <1680587425-4683-1-git-send-email-Xiaosong.Ma@unisoc.com>
On Tue, 4 Apr 2023 13:50:25 +0800 "xiaosong.ma" <Xiaosong.Ma@unisoc.com> wrote:
> when we debug with slub_debug_on, the following backtraces show dump_page
> will show wrong info when the bad page is non-NULL mapping and page->mapping
> is 0x80000000000 so do virt_addr valid check is needed when dump mapping page.
How did this page get ->mapping=0x80000000? I don't recall anywhere
where we deliberately set this state.
Maybe a random bitscribble? I guess being defensive in __dump_page()
is sensible - we have reason to believe that the page is in some bad
state.
> --- a/mm/debug.c
> +++ b/mm/debug.c
> @@ -109,7 +109,7 @@ static void __dump_page(struct page *page)
> type = "ksm ";
> else if (PageAnon(page))
> type = "anon ";
> - else if (mapping)
> + else if (mapping && virt_addr_valid(mapping))
> dump_mapping(mapping);
I expect the user will be interested in knowing that ->mapping contains
junk, so perhaps we should print some information telling them this.
In which case, dump_mapping() would be a better place to perform the
check.
And lo, dump_mapping() already did this, so I think all we need is
--- a/fs/inode.c~a
+++ a/fs/inode.c
@@ -565,7 +565,8 @@ void dump_mapping(const struct address_s
* If mapping is an invalid pointer, we don't want to crash
* accessing it, so probe everything depending on it carefully.
*/
- if (get_kernel_nofault(host, &mapping->host) ||
+ if (get_kernel_nofault(mapping) ||
+ get_kernel_nofault(host, &mapping->host) ||
get_kernel_nofault(a_ops, &mapping->a_ops)) {
pr_warn("invalid mapping:%px\n", mapping);
return;
_
prev parent reply other threads:[~2023-04-04 21:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-04 5:50 xiaosong.ma
2023-04-04 5:54 ` Zhaoyang Huang
2023-04-04 21:17 ` Andrew Morton [this message]
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=20230404141722.45dbdc377e7e1547e302ffa5@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=Xiaosong.Ma@unisoc.com \
--cc=huangzhaoyang@gmail.com \
--cc=ke.wang@unisoc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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