Skip to content

Commit

Permalink
Merge pull request #52 from namjaejeon/cifsd-for-next
Browse files Browse the repository at this point in the history
cifsd-fixes
  • Loading branch information
smfrench authored Jun 1, 2021
2 parents 10a96b2 + 2ae1a6c commit 55b4fcd
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 36 deletions.
2 changes: 1 addition & 1 deletion fs/cifsd/smb2ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void init_smb3_0_server(struct ksmbd_conn *conn)
conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING;

if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION &&
conn->cli_cap & SMB2_GLOBAL_CAP_ENCRYPTION)
conn->cli_cap & SMB2_GLOBAL_CAP_ENCRYPTION)
conn->vals->capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
}

Expand Down
2 changes: 1 addition & 1 deletion fs/cifsd/smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ int smb2_allocate_rsp_buf(struct ksmbd_work *work)
sz = large_sz;

if (server_conf.flags & KSMBD_GLOBAL_FLAG_CACHE_TBUF &&
work->set_trans_buf)
work->set_trans_buf)
work->response_buf = ksmbd_find_buffer(sz);
else
work->response_buf = kvmalloc(sz, GFP_KERNEL | __GFP_ZERO);
Expand Down
4 changes: 2 additions & 2 deletions fs/cifsd/smb2pdu.h
Original file line number Diff line number Diff line change
Expand Up @@ -1623,10 +1623,10 @@ void smb2_set_sign_rsp(struct ksmbd_work *work);
int smb3_check_sign_req(struct ksmbd_work *work);
void smb3_set_sign_rsp(struct ksmbd_work *work);
int find_matching_smb2_dialect(int start_index, __le16 *cli_dialects,
__le16 dialects_count);
__le16 dialects_count);
struct file_lock *smb_flock_init(struct file *f);
int setup_async_work(struct ksmbd_work *work, void (*fn)(void **),
void **arg);
void **arg);
void smb2_send_interim_resp(struct ksmbd_work *work, __le32 status);
struct channel *lookup_chann_list(struct ksmbd_session *sess);
void smb3_preauth_hash_rsp(struct ksmbd_work *work);
Expand Down
15 changes: 8 additions & 7 deletions fs/cifsd/smbacl.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,23 @@ struct posix_acl_state {
};

int parse_sec_desc(struct smb_ntsd *pntsd, int acl_len,
struct smb_fattr *fattr);
struct smb_fattr *fattr);
int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *ppntsd,
int addition_info, __u32 *secdesclen, struct smb_fattr *fattr);
int addition_info, __u32 *secdesclen,
struct smb_fattr *fattr);
int init_acl_state(struct posix_acl_state *state, int cnt);
void free_acl_state(struct posix_acl_state *state);
void posix_state_to_acl(struct posix_acl_state *state,
struct posix_acl_entry *pace);
struct posix_acl_entry *pace);
int compare_sids(const struct smb_sid *ctsid, const struct smb_sid *cwsid);
bool smb_inherit_flags(int flags, bool is_dir);
int smb_inherit_dacl(struct ksmbd_conn *conn, struct dentry *dentry,
unsigned int uid, unsigned int gid);
unsigned int uid, unsigned int gid);
int smb_check_perm_dacl(struct ksmbd_conn *conn, struct dentry *dentry,
__le32 *pdaccess, int uid);
__le32 *pdaccess, int uid);
int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
struct dentry *dentry, struct smb_ntsd *pntsd, int ntsd_len,
bool type_check);
struct dentry *dentry, struct smb_ntsd *pntsd, int ntsd_len,
bool type_check);
void id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid);
void ksmbd_init_domain(u32 *sub_auth);
#endif /* _SMBACL_H */
6 changes: 3 additions & 3 deletions fs/cifsd/transport_ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ struct sockaddr;

struct ksmbd_tree_connect_response *
ksmbd_ipc_tree_connect_request(struct ksmbd_session *sess,
struct ksmbd_share_config *share,
struct ksmbd_tree_connect *tree_conn,
struct sockaddr *peer_addr);
struct ksmbd_share_config *share,
struct ksmbd_tree_connect *tree_conn,
struct sockaddr *peer_addr);
int ksmbd_ipc_tree_disconnect_request(unsigned long long session_id,
unsigned long long connect_id);
int ksmbd_ipc_logout_request(const char *account);
Expand Down
8 changes: 4 additions & 4 deletions fs/cifsd/transport_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,10 @@ static int create_socket(struct interface *iface)
ksmbd_tcp_reuseaddr(ksmbd_socket);

ret = sock_setsockopt(ksmbd_socket,
SOL_SOCKET,
SO_BINDTODEVICE,
KERNEL_SOCKPTR(iface->name),
strlen(iface->name));
SOL_SOCKET,
SO_BINDTODEVICE,
KERNEL_SOCKPTR(iface->name),
strlen(iface->name));
if (ret != -ENODEV && ret < 0) {
ksmbd_err("Failed to set SO_BINDTODEVICE: %d\n", ret);
goto out_error;
Expand Down
28 changes: 18 additions & 10 deletions fs/cifsd/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ static int ksmbd_vfs_stream_read(struct ksmbd_file *fp, char *buf, loff_t *pos,
{
ssize_t v_len;
char *stream_buf = NULL;
int err;

ksmbd_debug(VFS, "read stream data pos : %llu, count : %zd\n",
*pos, count);
Expand All @@ -283,14 +282,22 @@ static int ksmbd_vfs_stream_read(struct ksmbd_file *fp, char *buf, loff_t *pos,
fp->stream.name,
fp->stream.size,
&stream_buf);
if (v_len == -ENOENT) {
ksmbd_err("not found stream in xattr : %zd\n", v_len);
err = -ENOENT;
return err;
if ((int)v_len <= 0)
return (int)v_len;

if (v_len <= *pos) {
count = -EINVAL;
goto free_buf;
}

if (v_len - *pos < count)
count = v_len - *pos;

memcpy(buf, &stream_buf[*pos], count);
return v_len > count ? count : v_len;

free_buf:
kvfree(stream_buf);
return count;
}

/**
Expand Down Expand Up @@ -414,9 +421,9 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
fp->stream.name,
fp->stream.size,
&stream_buf);
if (v_len == -ENOENT) {
if ((int)v_len < 0) {
ksmbd_err("not found stream in xattr : %zd\n", v_len);
err = -ENOENT;
err = (int)v_len;
goto out;
}

Expand All @@ -429,6 +436,7 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,

if (v_len > 0)
memcpy(wbuf, stream_buf, v_len);
kvfree(stream_buf);
stream_buf = wbuf;
}

Expand Down Expand Up @@ -934,8 +942,8 @@ ssize_t ksmbd_vfs_getxattr(struct dentry *dentry, char *xattr_name,
if (!buf)
return -ENOMEM;

xattr_len = vfs_getxattr(&init_user_ns, dentry, xattr_name, (void *)buf,
xattr_len);
xattr_len = vfs_getxattr(&init_user_ns, dentry, xattr_name,
(void *)buf, xattr_len);
if (xattr_len > 0)
*xattr_buf = buf;
else
Expand Down
16 changes: 8 additions & 8 deletions fs/cifsd/vfs_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
#define KSMBD_NO_FID (UINT_MAX)
#define SMB2_NO_FID (0xFFFFFFFFFFFFFFFFULL)

#define FP_FILENAME(fp) fp->filp->f_path.dentry->d_name.name
#define FP_INODE(fp) d_inode(fp->filp->f_path.dentry)
#define PARENT_INODE(fp) d_inode(fp->filp->f_path.dentry->d_parent)

#define ATTR_FP(fp) (fp->attrib_only && \
(fp->cdoption != FILE_OVERWRITE_IF_LE && \
fp->cdoption != FILE_OVERWRITE_LE && \
fp->cdoption != FILE_SUPERSEDE_LE))
#define FP_FILENAME(fp) ((fp)->filp->f_path.dentry->d_name.name)
#define FP_INODE(fp) d_inode((fp)->filp->f_path.dentry)
#define PARENT_INODE(fp) d_inode((fp)->filp->f_path.dentry->d_parent)

#define ATTR_FP(fp) ((fp)->attrib_only && \
((fp)->cdoption != FILE_OVERWRITE_IF_LE && \
(fp)->cdoption != FILE_OVERWRITE_LE && \
(fp)->cdoption != FILE_SUPERSEDE_LE))

struct ksmbd_conn;
struct ksmbd_session;
Expand Down

0 comments on commit 55b4fcd

Please sign in to comment.