]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ksmbd: fix a mount write count leak in ksmbd_vfs_kern_path_locked()
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 6 Jul 2025 01:26:45 +0000 (02:26 +0100)
committerSteve French <stfrench@microsoft.com>
Tue, 8 Jul 2025 16:25:44 +0000 (11:25 -0500)
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>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/vfs.c

index 0f3aad12e495329a16cca14875be3d1b722a4b7c..d3437f6644e334c6b31346ada021469a963a9323 100644 (file)
@@ -1282,6 +1282,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);
                }