Commit 62e1f3b3 authored by Linus Torvalds's avatar Linus Torvalds

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()
parents 08a6b55a 2bfc4214
...@@ -630,6 +630,12 @@ smb2_get_name(const char *src, const int maxlen, struct nls_table *local_nls) ...@@ -630,6 +630,12 @@ smb2_get_name(const char *src, const int maxlen, struct nls_table *local_nls)
return name; return name;
} }
if (*name == '\\') {
pr_err("not allow directory name included leading slash\n");
kfree(name);
return ERR_PTR(-EINVAL);
}
ksmbd_conv_path_to_unix(name); ksmbd_conv_path_to_unix(name);
ksmbd_strip_last_slash(name); ksmbd_strip_last_slash(name);
return name; return name;
...@@ -2361,7 +2367,8 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len, ...@@ -2361,7 +2367,8 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
if (rc > 0) { if (rc > 0) {
rc = ksmbd_vfs_remove_xattr(idmap, rc = ksmbd_vfs_remove_xattr(idmap,
path, path,
attr_name); attr_name,
get_write);
if (rc < 0) { if (rc < 0) {
ksmbd_debug(SMB, ksmbd_debug(SMB,
...@@ -2376,7 +2383,7 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len, ...@@ -2376,7 +2383,7 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
} else { } else {
rc = ksmbd_vfs_setxattr(idmap, path, attr_name, value, rc = ksmbd_vfs_setxattr(idmap, path, attr_name, value,
le16_to_cpu(eabuf->EaValueLength), le16_to_cpu(eabuf->EaValueLength),
0, true); 0, get_write);
if (rc < 0) { if (rc < 0) {
ksmbd_debug(SMB, ksmbd_debug(SMB,
"ksmbd_vfs_setxattr is failed(%d)\n", "ksmbd_vfs_setxattr is failed(%d)\n",
...@@ -2468,7 +2475,7 @@ static int smb2_remove_smb_xattrs(const struct path *path) ...@@ -2468,7 +2475,7 @@ static int smb2_remove_smb_xattrs(const struct path *path)
!strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX, !strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX,
STREAM_PREFIX_LEN)) { STREAM_PREFIX_LEN)) {
err = ksmbd_vfs_remove_xattr(idmap, path, err = ksmbd_vfs_remove_xattr(idmap, path,
name); name, true);
if (err) if (err)
ksmbd_debug(SMB, "remove xattr failed : %s\n", ksmbd_debug(SMB, "remove xattr failed : %s\n",
name); name);
...@@ -2842,20 +2849,11 @@ int smb2_open(struct ksmbd_work *work) ...@@ -2842,20 +2849,11 @@ int smb2_open(struct ksmbd_work *work)
} }
if (req->NameLength) { if (req->NameLength) {
if ((req->CreateOptions & FILE_DIRECTORY_FILE_LE) &&
*(char *)req->Buffer == '\\') {
pr_err("not allow directory name included leading slash\n");
rc = -EINVAL;
goto err_out2;
}
name = smb2_get_name((char *)req + le16_to_cpu(req->NameOffset), name = smb2_get_name((char *)req + le16_to_cpu(req->NameOffset),
le16_to_cpu(req->NameLength), le16_to_cpu(req->NameLength),
work->conn->local_nls); work->conn->local_nls);
if (IS_ERR(name)) { if (IS_ERR(name)) {
rc = PTR_ERR(name); rc = PTR_ERR(name);
if (rc != -ENOMEM)
rc = -ENOENT;
name = NULL; name = NULL;
goto err_out2; goto err_out2;
} }
......
...@@ -1058,16 +1058,21 @@ int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length, ...@@ -1058,16 +1058,21 @@ int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length,
} }
int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap, int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap,
const struct path *path, char *attr_name) const struct path *path, char *attr_name,
bool get_write)
{ {
int err; int err;
err = mnt_want_write(path->mnt); if (get_write == true) {
if (err) err = mnt_want_write(path->mnt);
return err; if (err)
return err;
}
err = vfs_removexattr(idmap, path->dentry, attr_name); err = vfs_removexattr(idmap, path->dentry, attr_name);
mnt_drop_write(path->mnt);
if (get_write == true)
mnt_drop_write(path->mnt);
return err; return err;
} }
...@@ -1380,7 +1385,7 @@ int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, const struct path *path) ...@@ -1380,7 +1385,7 @@ int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, const struct path *path)
ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name)); ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name));
if (!strncmp(name, XATTR_NAME_SD, XATTR_NAME_SD_LEN)) { if (!strncmp(name, XATTR_NAME_SD, XATTR_NAME_SD_LEN)) {
err = ksmbd_vfs_remove_xattr(idmap, path, name); err = ksmbd_vfs_remove_xattr(idmap, path, name, true);
if (err) if (err)
ksmbd_debug(SMB, "remove xattr failed : %s\n", name); ksmbd_debug(SMB, "remove xattr failed : %s\n", name);
} }
......
...@@ -114,7 +114,8 @@ int ksmbd_vfs_setxattr(struct mnt_idmap *idmap, ...@@ -114,7 +114,8 @@ int ksmbd_vfs_setxattr(struct mnt_idmap *idmap,
int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name, int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name,
size_t *xattr_stream_name_size, int s_type); size_t *xattr_stream_name_size, int s_type);
int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap, int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap,
const struct path *path, char *attr_name); const struct path *path, char *attr_name,
bool get_write);
int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name, int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
unsigned int flags, struct path *parent_path, unsigned int flags, struct path *parent_path,
struct path *path, bool caseless); struct path *path, bool caseless);
......
...@@ -254,7 +254,8 @@ static void __ksmbd_inode_close(struct ksmbd_file *fp) ...@@ -254,7 +254,8 @@ static void __ksmbd_inode_close(struct ksmbd_file *fp)
ci->m_flags &= ~S_DEL_ON_CLS_STREAM; ci->m_flags &= ~S_DEL_ON_CLS_STREAM;
err = ksmbd_vfs_remove_xattr(file_mnt_idmap(filp), err = ksmbd_vfs_remove_xattr(file_mnt_idmap(filp),
&filp->f_path, &filp->f_path,
fp->stream.name); fp->stream.name,
true);
if (err) if (err)
pr_err("remove xattr failed : %s\n", pr_err("remove xattr failed : %s\n",
fp->stream.name); fp->stream.name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment