ksmbd: fix a mount write count leak in ksmbd_vfs_kern_path_locked()

commit 277627b431a0a6401635c416a21b2a0f77a77347 upstream.

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: 864fb5d371 ("ksmbd: fix possible deadlock in smb2_open")
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 4c4f931676b6b85623f69e40fae8ed607405f8ea)
This commit is contained in:
Al Viro 2025-07-06 02:26:45 +01:00 committed by Wentao Guan
parent e039ce5968
commit b657842ca7
1 changed files with 1 additions and 0 deletions

View File

@ -1293,6 +1293,7 @@ out1:
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);
}