Skip to content

Commit c5a709f

Browse files
namjaejeonsmfrench
authored andcommitted
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: [email protected] # v5.15+ Reported-by: Ray Zhang <[email protected]> Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent ca4974c commit c5a709f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

fs/smb/server/vfs.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ static bool __caseless_lookup(struct dir_context *ctx, const char *name,
11671167
if (cmp < 0)
11681168
cmp = strncasecmp((char *)buf->private, name, namlen);
11691169
if (!cmp) {
1170-
memcpy((char *)buf->private, name, namlen);
1170+
memcpy((char *)buf->private, name, buf->used);
11711171
buf->dirent_count = 1;
11721172
return false;
11731173
}
@@ -1235,10 +1235,7 @@ int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
12351235
char *filepath;
12361236
size_t path_len, remain_len;
12371237

1238-
filepath = kstrdup(name, GFP_KERNEL);
1239-
if (!filepath)
1240-
return -ENOMEM;
1241-
1238+
filepath = name;
12421239
path_len = strlen(filepath);
12431240
remain_len = path_len;
12441241

@@ -1281,10 +1278,9 @@ int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
12811278
err = -EINVAL;
12821279
out2:
12831280
path_put(parent_path);
1284-
out1:
1285-
kfree(filepath);
12861281
}
12871282

1283+
out1:
12881284
if (!err) {
12891285
err = mnt_want_write(parent_path->mnt);
12901286
if (err) {

0 commit comments

Comments
 (0)