From: Marios Makassikis Date: Mon, 15 Apr 2024 13:12:48 +0000 (+0200) Subject: ksmbd: clear RENAME_NOREPLACE before calling vfs_rename X-Git-Tag: v6.6.29~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4cbb88351b5505bec5e8b33b85f012d8087c03b5;p=thirdparty%2Fkernel%2Fstable.git ksmbd: clear RENAME_NOREPLACE before calling vfs_rename commit 4973b04d3ea577db80c501c5f14e68ec69fe1794 upstream. 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 Acked-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c index a8936aba7710e..626406b0cf4ac 100644 --- a/fs/smb/server/vfs.c +++ b/fs/smb/server/vfs.c @@ -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;