From: Al Viro <viro@zeniv.linux.org.uk>
To: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, Miklos Szeredi <miklos@szeredi.hu>,
Christian Brauner <brauner@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH] fix a mount write count leak in ksmbd_vfs_kern_path_locked() (was Re: [RFC] MNT_WRITE_HOLD mess)
Date: Sun, 6 Jul 2025 02:26:45 +0100 [thread overview]
Message-ID: <20250706012645.GB1880847@ZenIV> (raw)
In-Reply-To: <20250705185359.GZ1880847@ZenIV>
If the call of ksmbd_vfs_lock_parent() fails, we drop the parent_path
references and return an error. We need to drop the write access we
just got on parent_path->mnt before we drop the mount reference - callers
assume that ksmbd_vfs_kern_path_locked() returns with mount write
access grabbed if and only if it has returned 0.
Fixes: 864fb5d37163 "ksmbd: fix possible deadlock in smb2_open"
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index 0f3aad12e495..d3437f6644e3 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -1282,6 +1282,7 @@ int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
err = ksmbd_vfs_lock_parent(parent_path->dentry, path->dentry);
if (err) {
+ mnt_drop_write(parent_path->mnt);
path_put(path);
path_put(parent_path);
}
next prev parent reply other threads:[~2025-07-06 1:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-04 19:44 [RFC] MNT_WRITE_HOLD mess Al Viro
2025-07-04 19:57 ` Linus Torvalds
2025-07-04 20:23 ` Al Viro
2025-07-05 0:01 ` Al Viro
2025-07-05 4:52 ` Miklos Szeredi
2025-07-05 5:57 ` Al Viro
2025-07-05 8:16 ` Al Viro
2025-07-05 18:53 ` Al Viro
2025-07-05 23:26 ` Al Viro
2025-07-07 10:26 ` Jan Kara
2025-07-06 1:26 ` Al Viro [this message]
2025-07-06 3:49 ` [PATCH] fix a mount write count leak in ksmbd_vfs_kern_path_locked() (was Re: [RFC] MNT_WRITE_HOLD mess) Namjae Jeon
2025-07-07 8:24 ` [RFC] MNT_WRITE_HOLD mess Christian Brauner
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=20250706012645.GB1880847@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=brauner@kernel.org \
--cc=linkinjeon@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.