Skip to content

Commit

Permalink
ksmbd: clear RENAME_NOREPLACE before calling vfs_rename
Browse files Browse the repository at this point in the history
commit 4973b04 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 <mmakassikis@freebox.fr>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Marios Makassikis authored and gregkh committed Apr 27, 2024
1 parent 5c20b24 commit 4cbb883
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs/smb/server/vfs.c
Expand Up @@ -745,10 +745,15 @@ int ksmbd_vfs_rename(struct ksmbd_work *work, const struct path *old_path,
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;
Expand Down

0 comments on commit 4cbb883

Please sign in to comment.