summaryrefslogtreecommitdiff
path: root/fs/smb/server
diff options
context:
space:
mode:
authorNamjae Jeon <linkinjeon@kernel.org>2024-09-08 15:23:48 +0900
committerSteve French <stfrench@microsoft.com>2024-09-14 00:03:15 -0500
commitc5a709f08d40b1a082e44ffcde1aea4d2822ddd5 (patch)
tree1e2d9c50263bdc2fb4868afe420fca66fc06953f /fs/smb/server
parentca4974ca954561e79f8871d220bb08f14f64f57c (diff)
downloadlwn-c5a709f08d40b1a082e44ffcde1aea4d2822ddd5.tar.gz
lwn-c5a709f08d40b1a082e44ffcde1aea4d2822ddd5.zip
ksmbd: handle caseless file creation
Ray Zhang reported ksmbd can not create file if parent filename is caseless. Y:\>mkdir A Y:\>echo 123 >a\b.txt The system cannot find the path specified. Y:\>echo 123 >A\b.txt This patch convert name obtained by caseless lookup to parent name. Cc: stable@vger.kernel.org # v5.15+ Reported-by: Ray Zhang <zhanglei002@gmail.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/smb/server')
-rw-r--r--fs/smb/server/vfs.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index 13dad48d950c..7cbd580120d1 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -1167,7 +1167,7 @@ static bool __caseless_lookup(struct dir_context *ctx, const char *name,
if (cmp < 0)
cmp = strncasecmp((char *)buf->private, name, namlen);
if (!cmp) {
- memcpy((char *)buf->private, name, namlen);
+ memcpy((char *)buf->private, name, buf->used);
buf->dirent_count = 1;
return false;
}
@@ -1235,10 +1235,7 @@ int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
char *filepath;
size_t path_len, remain_len;
- filepath = kstrdup(name, GFP_KERNEL);
- if (!filepath)
- return -ENOMEM;
-
+ filepath = name;
path_len = strlen(filepath);
remain_len = path_len;
@@ -1281,10 +1278,9 @@ int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
err = -EINVAL;
out2:
path_put(parent_path);
-out1:
- kfree(filepath);
}
+out1:
if (!err) {
err = mnt_want_write(parent_path->mnt);
if (err) {