From: Mike Rapoport <rppt@linux.ibm.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
John Hubbard <jhubbard@nvidia.com>,
Vlastimil Babka <vbabka@suse.cz>
Subject: Re: [PATCH] mm/debug: Do not dereference i_ino blindly
Date: Thu, 20 Aug 2020 00:00:24 +0300 [thread overview]
Message-ID: <20200819210024.GO969206@linux.ibm.com> (raw)
In-Reply-To: <20200819185710.28180-1-willy@infradead.org>
On Wed, Aug 19, 2020 at 07:57:10PM +0100, Matthew Wilcox (Oracle) wrote:
> We check i_dentry is fetchable and i_ino is earlier in the struct
> than i_ino, so it ought to work fine, but it's possible that struct
> randomisation has reordered i_ino after i_dentry and the pointer is
> just wild enough that i_dentry is fetchable and i_ino isn't.
>
> Also print the inode number if the dentry is invalid.
>
> Reported-by: Vlastimil Babka <vbabka@suse.cz>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
> ---
> mm/debug.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/mm/debug.c b/mm/debug.c
> index ca8d1cacdecc..2a767865145c 100644
> --- a/mm/debug.c
> +++ b/mm/debug.c
> @@ -120,6 +120,7 @@ void __dump_page(struct page *page, const char *reason)
> struct hlist_node *dentry_first;
> struct dentry *dentry_ptr;
> struct dentry dentry;
> + unsigned long ino;
>
> /*
> * mapping can be invalid pointer and we don't want to crash
> @@ -136,21 +137,22 @@ void __dump_page(struct page *page, const char *reason)
> goto out_mapping;
> }
>
> - if (get_kernel_nofault(dentry_first, &host->i_dentry.first)) {
> + if (get_kernel_nofault(dentry_first, &host->i_dentry.first) ||
> + get_kernel_nofault(ino, &host->i_ino)) {
> pr_warn("aops:%ps with invalid host inode %px\n",
> a_ops, host);
> goto out_mapping;
> }
>
> if (!dentry_first) {
> - pr_warn("aops:%ps ino:%lx\n", a_ops, host->i_ino);
> + pr_warn("aops:%ps ino:%lx\n", a_ops, ino);
> goto out_mapping;
> }
>
> dentry_ptr = container_of(dentry_first, struct dentry, d_u.d_alias);
> if (get_kernel_nofault(dentry, dentry_ptr)) {
> - pr_warn("aops:%ps with invalid dentry %px\n", a_ops,
> - dentry_ptr);
> + pr_warn("aops:%ps ino:%lx with invalid dentry %px\n",
> + a_ops, ino, dentry_ptr);
> } else {
> /*
> * if dentry is corrupted, the %pd handler may still
> @@ -158,7 +160,7 @@ void __dump_page(struct page *page, const char *reason)
> * corrupted struct page
> */
> pr_warn("aops:%ps ino:%lx dentry name:\"%pd\"\n",
> - a_ops, host->i_ino, &dentry);
> + a_ops, ino, &dentry);
> }
> }
> out_mapping:
> --
> 2.28.0
>
--
Sincerely yours,
Mike.
prev parent reply other threads:[~2020-08-19 21:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-19 18:57 Matthew Wilcox (Oracle)
2020-08-19 19:10 ` John Hubbard
2020-08-19 21:00 ` Mike Rapoport [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=20200819210024.GO969206@linux.ibm.com \
--to=rppt@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=jhubbard@nvidia.com \
--cc=linux-mm@kvack.org \
--cc=vbabka@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