Skip to content

Commit

Permalink
ksmbd: fix unexpectedly changed path in ksmbd_vfs_kern_path_locked
Browse files Browse the repository at this point in the history
[ Upstream commit 2ac538e ]

When `ksmbd_vfs_kern_path_locked` met an error and it is not the last
entry, it will exit without restoring changed path buffer. But later this
buffer may be used as the filename for creation.

Fixes: c5a709f ("ksmbd: handle caseless file creation")
Signed-off-by: He Wang <xw897002528@gmail.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
xhebox authored and gregkh committed Jan 17, 2025
1 parent aabe47c commit 13e41c5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/smb/server/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1249,14 +1249,15 @@ int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
filepath,
flags,
path);
if (!is_last)
next[0] = '/';
if (err)
goto out2;
else if (is_last)
goto out1;
path_put(parent_path);
*parent_path = *path;

next[0] = '/';
remain_len -= filename_len + 1;
}

Expand Down

0 comments on commit 13e41c5

Please sign in to comment.