From: Al Viro <viro@zeniv.linux.org.uk>
To: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: akpm@linux-foundation.org, willy@infradead.org,
brauner@kernel.org, jack@suse.cz, linux-mm@kvack.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs: improve dump_mapping() robustness
Date: Thu, 18 Jan 2024 01:38:57 +0000 [thread overview]
Message-ID: <20240118013857.GO1674809@ZenIV> (raw)
In-Reply-To: <937ab1f87328516821d39be672b6bc18861d9d3e.1705391420.git.baolin.wang@linux.alibaba.com>
On Tue, Jan 16, 2024 at 03:53:35PM +0800, Baolin Wang wrote:
> With checking the 'dentry.parent' and 'dentry.d_name.name' used by
> dentry_name(), I can see dump_mapping() will output the invalid dentry
> instead of crashing the system when this issue is reproduced again.
> dentry_ptr = container_of(dentry_first, struct dentry, d_u.d_alias);
> - if (get_kernel_nofault(dentry, dentry_ptr)) {
> + if (get_kernel_nofault(dentry, dentry_ptr) ||
> + !dentry.d_parent || !dentry.d_name.name) {
> pr_warn("aops:%ps ino:%lx invalid dentry:%px\n",
> a_ops, ino, dentry_ptr);
> return;
That's nowhere near enough. Your ->d_name.name can bloody well be pointing
to an external name that gets freed right under you. Legitimately so.
Think what happens if dentry has a long name (longer than would fit into
the embedded array) and gets renamed name just after you copy it into
a local variable. Old name will get freed. Yes, freeing is RCU-delayed,
but I don't see anything that would prevent your thread losing CPU
and not getting it back until after the sucker's been freed.
next prev parent reply other threads:[~2024-01-18 1:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-16 7:53 [PATCH] fs: improve dump_mapping() robustness Baolin Wang
2024-01-16 11:16 ` Christian Brauner
2024-01-18 1:27 ` Baolin Wang
2024-01-18 1:38 ` Al Viro [this message]
2024-01-18 2:12 ` Matthew Wilcox
2024-01-18 14:04 ` Christian Brauner
2024-01-18 2:43 ` Baolin Wang
2024-01-19 15:48 ` Charan Teja Kalla
2024-01-22 7:17 ` Baolin Wang
2024-01-22 16:28 ` Charan Teja Kalla
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=20240118013857.GO1674809@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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).