From: Christian Brauner <brauner@kernel.org>
To: Li Dong <lidong@vivo.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
"open list:FILESYSTEMS (VFS and infrastructure)"
<linux-fsdevel@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>,
opensource.kernel@vivo.com
Subject: Re: [PATCH] fs: Fix bug in lock_rename_child that can cause deadlock
Date: Tue, 20 Jun 2023 11:44:17 +0200 [thread overview]
Message-ID: <20230620-abfertigung-notlage-8b1c217bddf3@brauner> (raw)
In-Reply-To: <20230619133734.851-1-lidong@vivo.com>
On Mon, Jun 19, 2023 at 09:37:14PM +0800, Li Dong wrote:
> Function xx causes a deadlock,because s_vfs_rename_mutex was not released when return
>
> Signed-off-by: Li Dong <lidong@vivo.com>
> ---
This is a cross-directory rename which requires s_vfs_rename_mutex to be
held. You're suggesting to drop it, violating basic locking assumptions
with dire consequences:
lock_rename_child()
{
c1->d_parent != p2
-> acquire s_vfs_rename_mutex
}
pairs with
old_parent = c1->d_parent;
unlock_rename(old_parent, p2)
{
if (old_parent != p2)
-> release s_vfs_rename_mutex
}
See the usage in ksmbd:
trap = lock_rename_child(old_child, new_path.dentry);
old_parent = dget(old_child->d_parent);
unlock_rename(old_parent, new_path.dentry);
prev parent reply other threads:[~2023-06-20 9:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-19 13:37 Li Dong
2023-06-20 9:44 ` Christian Brauner [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=20230620-abfertigung-notlage-8b1c217bddf3@brauner \
--to=brauner@kernel.org \
--cc=lidong@vivo.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=opensource.kernel@vivo.com \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®