]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ksmbd: clear RENAME_NOREPLACE before calling vfs_rename
authorMarios Makassikis <mmakassikis@freebox.fr>
Mon, 15 Apr 2024 13:12:48 +0000 (15:12 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 May 2024 09:50:44 +0000 (11:50 +0200)
[ Upstream commit 4973b04d3ea577db80c501c5f14e68ec69fe1794 ]

File overwrite case is explicitly handled, so it is not necessary to
pass RENAME_NOREPLACE to vfs_rename.

Clearing the flag fixes rename operations when the share is a ntfs-3g
mount. The latter uses an older version of fuse with no support for
flags in the ->rename op.

Cc: stable@vger.kernel.org
Signed-off-by: Marios Makassikis <mmakassikis@freebox.fr>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ksmbd/vfs.c

index 173a488bfeee4ec3ef2a8e7dbbb4f326096dc967..7afb2412c4d432a590d1b203838dab8b4837ab74 100644 (file)
@@ -745,10 +745,15 @@ retry:
                goto out4;
        }
 
+       /*
+        * explicitly handle file overwrite case, for compatibility with
+        * filesystems that may not support rename flags (e.g: fuse)
+        */
        if ((flags & RENAME_NOREPLACE) && d_is_positive(new_dentry)) {
                err = -EEXIST;
                goto out4;
        }
+       flags &= ~(RENAME_NOREPLACE);
 
        if (old_child == trap) {
                err = -EINVAL;