Skip to content

Commit 62e1f3b

Browse files
committed
Merge tag '6.10-rc3-smb3-server-fixes' of git://git.samba.org/ksmbd
Pull smb server fixes from Steve French: "Two small smb3 server fixes: - set xatttr fix - pathname parsing check fix" * tag '6.10-rc3-smb3-server-fixes' of git://git.samba.org/ksmbd: ksmbd: fix missing use of get_write in in smb2_set_ea() ksmbd: move leading slash check to smb2_get_name()
2 parents 08a6b55 + 2bfc421 commit 62e1f3b

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

fs/smb/server/smb2pdu.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,12 @@ smb2_get_name(const char *src, const int maxlen, struct nls_table *local_nls)
630630
return name;
631631
}
632632

633+
if (*name == '\\') {
634+
pr_err("not allow directory name included leading slash\n");
635+
kfree(name);
636+
return ERR_PTR(-EINVAL);
637+
}
638+
633639
ksmbd_conv_path_to_unix(name);
634640
ksmbd_strip_last_slash(name);
635641
return name;
@@ -2361,7 +2367,8 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
23612367
if (rc > 0) {
23622368
rc = ksmbd_vfs_remove_xattr(idmap,
23632369
path,
2364-
attr_name);
2370+
attr_name,
2371+
get_write);
23652372

23662373
if (rc < 0) {
23672374
ksmbd_debug(SMB,
@@ -2376,7 +2383,7 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
23762383
} else {
23772384
rc = ksmbd_vfs_setxattr(idmap, path, attr_name, value,
23782385
le16_to_cpu(eabuf->EaValueLength),
2379-
0, true);
2386+
0, get_write);
23802387
if (rc < 0) {
23812388
ksmbd_debug(SMB,
23822389
"ksmbd_vfs_setxattr is failed(%d)\n",
@@ -2468,7 +2475,7 @@ static int smb2_remove_smb_xattrs(const struct path *path)
24682475
!strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX,
24692476
STREAM_PREFIX_LEN)) {
24702477
err = ksmbd_vfs_remove_xattr(idmap, path,
2471-
name);
2478+
name, true);
24722479
if (err)
24732480
ksmbd_debug(SMB, "remove xattr failed : %s\n",
24742481
name);
@@ -2842,20 +2849,11 @@ int smb2_open(struct ksmbd_work *work)
28422849
}
28432850

28442851
if (req->NameLength) {
2845-
if ((req->CreateOptions & FILE_DIRECTORY_FILE_LE) &&
2846-
*(char *)req->Buffer == '\\') {
2847-
pr_err("not allow directory name included leading slash\n");
2848-
rc = -EINVAL;
2849-
goto err_out2;
2850-
}
2851-
28522852
name = smb2_get_name((char *)req + le16_to_cpu(req->NameOffset),
28532853
le16_to_cpu(req->NameLength),
28542854
work->conn->local_nls);
28552855
if (IS_ERR(name)) {
28562856
rc = PTR_ERR(name);
2857-
if (rc != -ENOMEM)
2858-
rc = -ENOENT;
28592857
name = NULL;
28602858
goto err_out2;
28612859
}

fs/smb/server/vfs.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,16 +1058,21 @@ int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length,
10581058
}
10591059

10601060
int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap,
1061-
const struct path *path, char *attr_name)
1061+
const struct path *path, char *attr_name,
1062+
bool get_write)
10621063
{
10631064
int err;
10641065

1065-
err = mnt_want_write(path->mnt);
1066-
if (err)
1067-
return err;
1066+
if (get_write == true) {
1067+
err = mnt_want_write(path->mnt);
1068+
if (err)
1069+
return err;
1070+
}
10681071

10691072
err = vfs_removexattr(idmap, path->dentry, attr_name);
1070-
mnt_drop_write(path->mnt);
1073+
1074+
if (get_write == true)
1075+
mnt_drop_write(path->mnt);
10711076

10721077
return err;
10731078
}
@@ -1380,7 +1385,7 @@ int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, const struct path *path)
13801385
ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name));
13811386

13821387
if (!strncmp(name, XATTR_NAME_SD, XATTR_NAME_SD_LEN)) {
1383-
err = ksmbd_vfs_remove_xattr(idmap, path, name);
1388+
err = ksmbd_vfs_remove_xattr(idmap, path, name, true);
13841389
if (err)
13851390
ksmbd_debug(SMB, "remove xattr failed : %s\n", name);
13861391
}

fs/smb/server/vfs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ int ksmbd_vfs_setxattr(struct mnt_idmap *idmap,
114114
int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name,
115115
size_t *xattr_stream_name_size, int s_type);
116116
int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap,
117-
const struct path *path, char *attr_name);
117+
const struct path *path, char *attr_name,
118+
bool get_write);
118119
int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
119120
unsigned int flags, struct path *parent_path,
120121
struct path *path, bool caseless);

fs/smb/server/vfs_cache.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ static void __ksmbd_inode_close(struct ksmbd_file *fp)
254254
ci->m_flags &= ~S_DEL_ON_CLS_STREAM;
255255
err = ksmbd_vfs_remove_xattr(file_mnt_idmap(filp),
256256
&filp->f_path,
257-
fp->stream.name);
257+
fp->stream.name,
258+
true);
258259
if (err)
259260
pr_err("remove xattr failed : %s\n",
260261
fp->stream.name);

0 commit comments

Comments
 (0)