Buffer validation patches
Subsystems (2)
v5 cover Buffer validation patches
v2:
- update comments of smb2_get_data_area_len().
- fix wrong buffer size check in fsctl_query_iface_info_ioctl().
- fix 32bit overflow in smb2_set_info.
v3:
- add buffer check for ByteCount of smb negotiate request.
- Moved buffer check of to the top of loop to avoid unneeded behavior when out_buf_len is smaller than network_interface_info_ioctl_rsp.
- get correct out_buf_len which doesn't exceed max stream protocol length.
- subtract single smb2_lock_element for correct buffer size check in
ksmbd_smb2_check_message().
v4:
- use work->response_sz for out_buf_len calculation in smb2_ioctl.
- move smb2_neg size check to above to validate NegotiateContextOffset field.
- remove unneeded dialect checks in smb2_sess_setup() and smb2_handle_negotiate().
- split smb2_set_info patch into two patches(declaring smb2_file_basic_info and buffer check)
v5:
- remove PDU size validation from ksmbd_conn_handler_loop()
- add PDU size validation to ksmbd_smb2_check_message()
- fix compound non-related request handling
Hyunchul Lee (1):
ksmbd: add buffer validation for SMB2_CREATE_CONTEXT
Namjae Jeon (9):
ksmbd: add the check to vaildate if stream protocol length exceeds
maximum value
ksmbd: add validation in smb2_ioctl
ksmbd: use correct basic info level in set_file_basic_info()
ksmbd: add request buffer validation in smb2_set_info
ksmbd: check strictly data area in ksmbd_smb2_check_message()
ksmbd: add validation in smb2 negotiate
ksmbd: remove the leftover of smb2.0 dialect support
ksmbd: remove NTLMv1 authentication
ksmbd: fix transform header validation
Ralph Boehme (10):
ksmbd: use ksmbd_req_buf_next() in ksmbd_smb2_check_message()
ksmbd: use ksmbd_req_buf_next() in ksmbd_verify_smb_message()
ksmbd: remove ksmbd_verify_smb_message()
ksmbd: add ksmbd_smb2_cur_pdu_buflen()
ksmbd: use ksmbd_smb2_cur_pdu_buflen() in ksmbd_smb2_check_message()
ksmbd: check PDU len is at least header plus body size in
ksmbd_smb2_check_message()
ksmdb: use cmd helper variable in smb2_get_ksmbd_tcon()
ksmdb: make smb2_get_ksmbd_tcon() callable with chained PDUs
ksmbd: make smb2_check_user_session() callabe for compound PDUs
ksmdb: move session and tcon validation to ksmbd_smb2_check_message()
fs/ksmbd/auth.c | 205 --------------------- fs/ksmbd/connection.c | 9 +- fs/ksmbd/crypto_ctx.c | 16 -- fs/ksmbd/crypto_ctx.h | 8 - fs/ksmbd/ksmbd_work.h | 1 + fs/ksmbd/oplock.c | 41 ++++- fs/ksmbd/server.c | 19 +- fs/ksmbd/smb2misc.c | 164 ++++++++++------- fs/ksmbd/smb2ops.c | 5 - fs/ksmbd/smb2pdu.c | 411 ++++++++++++++++++++++++++++++------------ fs/ksmbd/smb2pdu.h | 11 +- fs/ksmbd/smb_common.c | 68 +++---- fs/ksmbd/smb_common.h | 5 +- fs/ksmbd/smbacl.c | 21 ++- fs/ksmbd/vfs.c | 2 +- fs/ksmbd/vfs.h | 2 +- 16 files changed, 496 insertions(+), 492 deletions(-)
Signature · 1 line
2.31.1
PATCH v5 1/20 ksmbd: add the check to vaildate if stream protocol length exceeds maximum value
From: Namjae Jeon <[email protected]>
This patch add MAX_STREAM_PROT_LEN macro and check if stream protocol length exceeds maximum value. opencode pdu size check in ksmbd_pdu_size_has_room().
--- fs/ksmbd/connection.c | 9 +++++---- fs/ksmbd/smb_common.c | 6 ------ fs/ksmbd/smb_common.h | 4 ++-- 3 files changed, 7 insertions(+), 12 deletions(-)
fs/ksmbd/connection.c +5 -4
@@ -296,10 +296,11 @@ int ksmbd_conn_handler_loop(void *p) pdu_size =get_rfc1002_len (hdr_buf);ksmbd_debug (CONN ,"RFC1002 header %u bytes\n" , pdu_size); -/* make sure we have enough to get to SMB header end */ -if (!ksmbd_pdu_size_has_room (pdu_size)) { -ksmbd_debug (CONN ,"SMB request too short (%u bytes)\n" , - pdu_size); +/* +* Check if pdu size is valid (min : smb header size, +* max : 0x00FFFFFF). +*/ +if (pdu_size >MAX_STREAM_PROT_LEN ) {continue ; }
fs/ksmbd/smb_common.c +0 -6
@@ -21,7 +21,6 @@ static const char basechars[43] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-!@#$%";#define MAGIC_CHAR '~'#define PERIOD '.'#define mangle (V ) ((char)(basechars[(V) % MANGLE_BASE])) -#define KSMBD_MIN_SUPPORTED_HEADER_SIZE (sizeof(struct smb2_hdr))struct smb_protocol {int index;
@@ -272,11 +271,6 @@ int ksmbd_init_smb_server(struct ksmbd_work *work)return 0 ; } -bool ksmbd_pdu_size_has_room (unsigned int pdu) -{ -return (pdu >=KSMBD_MIN_SUPPORTED_HEADER_SIZE -4 ); -} - int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level, struct ksmbd_file *dir, struct ksmbd_dir_info *d_info,
fs/ksmbd/smb_common.h +2 -2
@@ -48,6 +48,8 @@#define CIFS_DEFAULT_IOSIZE (64 * 1024)#define MAX_CIFS_SMALL_BUFFER_SIZE 448/* big enough for most */ +#define MAX_STREAM_PROT_LEN 0x00FFFFFF +/* Responses when opening a file. */ #define F_SUPERSEDED 0#define F_OPENED 1
@@ -493,8 +495,6 @@ int ksmbd_lookup_dialect_by_id(__le16 *cli_dialects, __le16 dialects_count);int ksmbd_init_smb_server (struct ksmbd_work *work); -bool ksmbd_pdu_size_has_room (unsigned int pdu); -struct ksmbd_kstat ; int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level,
Signature · 1 line
2.31.1
PATCH v5 2/20 ksmbd: add validation in smb2_ioctl
In reply to Ralph BoehmeFrom: Namjae Jeon <[email protected]>
Add validation for request/response buffer size check in smb2_ioctl and fsctl_copychunk() take copychunk_ioctl_req pointer and the other arguments instead of smb2_ioctl_req structure and remove an unused smb2_ioctl_req argument of fsctl_validate_negotiate_info.
--- fs/ksmbd/smb2pdu.c | 105 ++++++++++++++++++++++++++++++++++----------- fs/ksmbd/vfs.c | 2 +- fs/ksmbd/vfs.h | 2 +- 3 files changed, 83 insertions(+), 26 deletions(-)
fs/ksmbd/smb2pdu.c +81 -24
@@ -6918,24 +6918,26 @@ int smb2_lock(struct ksmbd_work *work)return err; } -static int fsctl_copychunk (struct ksmbd_work *work,struct smb2_ioctl_req *req, +static int fsctl_copychunk (struct ksmbd_work *work, +struct copychunk_ioctl_req *ci_req, +unsigned int cnt_code, +unsigned int input_count, +unsigned long long volatile_id, +unsigned long long persistent_id,struct smb2_ioctl_rsp *rsp) { -struct copychunk_ioctl_req *ci_req;struct copychunk_ioctl_rsp *ci_rsp;struct ksmbd_file *src_fp =NULL , *dst_fp =NULL ;struct srv_copychunk *chunks;unsigned int i, chunk_count, chunk_count_written =0 ;unsigned int chunk_size_written =0 ;loff_t total_size_written =0 ; -int ret, cnt_code; +int ret =0 ; - cnt_code =le32_to_cpu (req->CntCode); - ci_req = (struct copychunk_ioctl_req *)&req->Buffer[0 ]; ci_rsp = (struct copychunk_ioctl_rsp *)&rsp->Buffer[0 ]; - rsp->VolatileFileId = req->VolatileFileId; - rsp->PersistentFileId = req->PersistentFileId; + rsp->VolatileFileId =cpu_to_le64 (volatile_id); + rsp->PersistentFileId =cpu_to_le64 (persistent_id); ci_rsp->ChunksWritten =cpu_to_le32 (ksmbd_server_side_copy_max_chunk_count ()); ci_rsp->ChunkBytesWritten =
@@ -6945,12 +6947,13 @@ static int fsctl_copychunk(struct ksmbd_work *work, struct smb2_ioctl_req *req, chunks = (struct srv_copychunk *)&ci_req->Chunks[0 ]; chunk_count =le32_to_cpu (ci_req->ChunkCount); +if (chunk_count ==0 ) + goto out; total_size_written =0 ;/* verify the SRV_COPYCHUNK_COPY packet */ if (chunk_count >ksmbd_server_side_copy_max_chunk_count () || -le32_to_cpu (req->InputCount) < - offsetof(struct copychunk_ioctl_req , Chunks) + + input_count < offsetof(struct copychunk_ioctl_req , Chunks) + chunk_count *sizeof (struct srv_copychunk )) { rsp->hdr.Status =STATUS_INVALID_PARAMETER ;return -EINVAL ;
@@ -6971,9 +6974,7 @@ static int fsctl_copychunk(struct ksmbd_work *work, struct smb2_ioctl_req *req, src_fp =ksmbd_lookup_foreign_fd (work,le64_to_cpu (ci_req->ResumeKey[0 ])); - dst_fp =ksmbd_lookup_fd_slow (work, -le64_to_cpu (req->VolatileFileId), -le64_to_cpu (req->PersistentFileId)); + dst_fp =ksmbd_lookup_fd_slow (work, volatile_id, persistent_id); ret = -EINVAL ;if (!src_fp || src_fp->persistent_id !=le64_to_cpu (ci_req->ResumeKey[1 ])) {
@@ -7048,11 +7049,11 @@ static __be32 idev_ipv4_address(struct in_device *idev) }static int fsctl_query_iface_info_ioctl (struct ksmbd_conn *conn, -struct smb2_ioctl_req *req, -struct smb2_ioctl_rsp *rsp) +struct smb2_ioctl_rsp *rsp, +unsigned int out_buf_len) {struct network_interface_info_ioctl_rsp *nii_rsp =NULL ; -int nbytes =0 ; +unsigned int nbytes =0 ;struct net_device *netdev;struct sockaddr_storage_rsp *sockaddr_storage;unsigned int flags;
@@ -7061,6 +7062,10 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,rtnl_lock ();for_each_netdev (&init_net, netdev) { +if (out_buf_len < + nbytes +sizeof (struct network_interface_info_ioctl_rsp )) +break ; +if (netdev->type ==ARPHRD_LOOPBACK )continue ;
@@ -7132,6 +7137,8 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn, sockaddr_storage->addr6.ScopeId =0 ; } +if (out_buf_len - nbytes <sizeof (struct network_interface_info_ioctl_rsp )) +break ; nbytes +=sizeof (struct network_interface_info_ioctl_rsp ); }rtnl_unlock ();
@@ -7152,11 +7159,16 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,static int fsctl_validate_negotiate_info (struct ksmbd_conn *conn,struct validate_negotiate_info_req *neg_req, -struct validate_negotiate_info_rsp *neg_rsp) +struct validate_negotiate_info_rsp *neg_rsp, +unsigned int in_buf_len) {int ret =0 ;int dialect; +if (in_buf_len <sizeof (struct validate_negotiate_info_req ) + +le16_to_cpu (neg_req->DialectCount) *sizeof (__le16)) +return -EINVAL ; + dialect =ksmbd_lookup_dialect_by_id (neg_req->Dialects, neg_req->DialectCount);if (dialect ==BAD_PROT_ID || dialect != conn->dialect) {
@@ -7190,7 +7202,7 @@ static int fsctl_validate_negotiate_info(struct ksmbd_conn *conn,static int fsctl_query_allocated_ranges (struct ksmbd_work *work,u64 id,struct file_allocated_range_buffer *qar_req,struct file_allocated_range_buffer *qar_rsp, -int in_count,int *out_count) +unsigned int in_count,unsigned int *out_count) {struct ksmbd_file *fp;loff_t start, length;
@@ -7217,7 +7229,8 @@ static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id, }static int fsctl_pipe_transceive (struct ksmbd_work *work,u64 id, -int out_buf_len,struct smb2_ioctl_req *req, +unsigned int out_buf_len, +struct smb2_ioctl_req *req,struct smb2_ioctl_rsp *rsp) {struct ksmbd_rpc_command *rpc_resp;
@@ -7331,8 +7344,7 @@ int smb2_ioctl(struct ksmbd_work *work) {struct smb2_ioctl_req *req;struct smb2_ioctl_rsp *rsp, *rsp_org; -int cnt_code, nbytes =0 ; -int out_buf_len; +unsigned int cnt_code, nbytes =0 , out_buf_len, in_buf_len;u64 id =KSMBD_NO_FID ;struct ksmbd_conn *conn = work->conn;int ret =0 ;
@@ -7361,7 +7373,11 @@ int smb2_ioctl(struct ksmbd_work *work) cnt_code =le32_to_cpu (req->CntCode); out_buf_len =le32_to_cpu (req->MaxOutputResponse); - out_buf_len =min (KSMBD_IPC_MAX_PAYLOAD , out_buf_len); + out_buf_len = +min_t (u32, work->response_sz - work->next_smb2_rsp_hdr_off - + (offsetof(struct smb2_ioctl_rsp , Buffer) -4 ), + out_buf_len); + in_buf_len =le32_to_cpu (req->InputCount);switch (cnt_code) {case FSCTL_DFS_GET_REFERRALS :
@@ -7389,6 +7405,7 @@ int smb2_ioctl(struct ksmbd_work *work)break ; }case FSCTL_PIPE_TRANSCEIVE : + out_buf_len =min_t (u32,KSMBD_IPC_MAX_PAYLOAD , out_buf_len); nbytes =fsctl_pipe_transceive (work, id, out_buf_len, req, rsp);break ;case FSCTL_VALIDATE_NEGOTIATE_INFO :
@@ -7397,9 +7414,16 @@ int smb2_ioctl(struct ksmbd_work *work) goto out; } +if (in_buf_len <sizeof (struct validate_negotiate_info_req )) +return -EINVAL ; + +if (out_buf_len <sizeof (struct validate_negotiate_info_rsp )) +return -EINVAL ; + ret =fsctl_validate_negotiate_info (conn, (struct validate_negotiate_info_req *)&req->Buffer[0 ], - (struct validate_negotiate_info_rsp *)&rsp->Buffer[0 ]); + (struct validate_negotiate_info_rsp *)&rsp->Buffer[0 ], + in_buf_len);if (ret <0 ) goto out;
@@ -7408,7 +7432,7 @@ int smb2_ioctl(struct ksmbd_work *work) rsp->VolatileFileId =cpu_to_le64 (SMB2_NO_FID );break ;case FSCTL_QUERY_NETWORK_INTERFACE_INFO : - nbytes =fsctl_query_iface_info_ioctl (conn, req, rsp); + nbytes =fsctl_query_iface_info_ioctl (conn, rsp, out_buf_len);if (nbytes <0 ) goto out;break ;
@@ -7435,15 +7459,33 @@ int smb2_ioctl(struct ksmbd_work *work) goto out; } +if (in_buf_len <sizeof (struct copychunk_ioctl_req )) { + ret = -EINVAL ; + goto out; + } +if (out_buf_len <sizeof (struct copychunk_ioctl_rsp )) { ret = -EINVAL ; goto out; } nbytes =sizeof (struct copychunk_ioctl_rsp ); -fsctl_copychunk (work, req, rsp); + rsp->VolatileFileId = req->VolatileFileId; + rsp->PersistentFileId = req->PersistentFileId; +fsctl_copychunk (work, + (struct copychunk_ioctl_req *)&req->Buffer[0 ], +le32_to_cpu (req->CntCode), +le32_to_cpu (req->InputCount), +le64_to_cpu (req->VolatileFileId), +le64_to_cpu (req->PersistentFileId), + rsp);break ;case FSCTL_SET_SPARSE : +if (in_buf_len <sizeof (struct file_sparse )) { + ret = -EINVAL ; + goto out; + } + ret =fsctl_set_sparse (work, id, (struct file_sparse *)&req->Buffer[0 ]);if (ret <0 )
@@ -7462,6 +7504,11 @@ int smb2_ioctl(struct ksmbd_work *work) goto out; } +if (in_buf_len <sizeof (struct file_zero_data_information )) { + ret = -EINVAL ; + goto out; + } + zero_data = (struct file_zero_data_information *)&req->Buffer[0 ];
@@ -7481,6 +7528,11 @@ int smb2_ioctl(struct ksmbd_work *work)break ; }case FSCTL_QUERY_ALLOCATED_RANGES : +if (in_buf_len <sizeof (struct file_allocated_range_buffer )) { + ret = -EINVAL ; + goto out; + } + ret = fsctl_query_allocated_ranges(work, id, (struct file_allocated_range_buffer *)&req->Buffer[0], (struct file_allocated_range_buffer *)&rsp->Buffer[0],
@@ -7521,6 +7573,11 @@ int smb2_ioctl(struct ksmbd_work *work)struct duplicate_extents_to_file *dup_ext;loff_t src_off, dst_off, length, cloned; +if (in_buf_len <sizeof (struct duplicate_extents_to_file )) { + ret = -EINVAL ; + goto out; + } + dup_ext = (struct duplicate_extents_to_file *)&req->Buffer[0 ]; fp_in = ksmbd_lookup_fd_slow(work, dup_ext->VolatileFileHandle,
fs/ksmbd/vfs.c +1 -1
@@ -1023,7 +1023,7 @@ int ksmbd_vfs_zero_data(struct ksmbd_work *work, struct ksmbd_file *fp,int ksmbd_vfs_fqar_lseek (struct ksmbd_file *fp,loff_t start,loff_t length,struct file_allocated_range_buffer *ranges, -int in_count,int *out_count) +unsigned int in_count,unsigned int *out_count) {struct file *f = fp->filp;struct inode *inode =file_inode (fp->filp);
fs/ksmbd/vfs.h +1 -1
@@ -166,7 +166,7 @@ int ksmbd_vfs_zero_data(struct ksmbd_work *work, struct ksmbd_file *fp,struct file_allocated_range_buffer ;int ksmbd_vfs_fqar_lseek (struct ksmbd_file *fp,loff_t start,loff_t length,struct file_allocated_range_buffer *ranges, -int in_count,int *out_count); +unsigned int in_count,unsigned int *out_count);int ksmbd_vfs_unlink (struct user_namespace *user_ns,struct dentry *dir,struct dentry *dentry);void *ksmbd_vfs_init_kstat (char **p,struct ksmbd_kstat *ksmbd_kstat);
Signature · 1 line
2.31.1
PATCH v5 3/20 ksmbd: use correct basic info level in set_file_basic_info()
In reply to Ralph BoehmeFrom: Namjae Jeon <[email protected]>
Use correct basic info level in set/get_file_basic_info().
--- fs/ksmbd/smb2pdu.c | 13 ++++++------- fs/ksmbd/smb2pdu.h | 9 +++++++++ 2 files changed, 15 insertions(+), 7 deletions(-)
fs/ksmbd/smb2pdu.c +6 -7
@@ -4161,7 +4161,7 @@ static void get_file_access_info(struct smb2_query_info_rsp *rsp,static int get_file_basic_info (struct smb2_query_info_rsp *rsp,struct ksmbd_file *fp,void *rsp_org) { -struct smb2_file_all_info *basic_info; +struct smb2_file_basic_info *basic_info;struct kstat stat;u64 time;
@@ -4171,7 +4171,7 @@ static int get_file_basic_info(struct smb2_query_info_rsp *rsp,return -EACCES ; } - basic_info = (struct smb2_file_all_info *)rsp->Buffer; + basic_info = (struct smb2_file_basic_info *)rsp->Buffer;generic_fillattr (file_mnt_user_ns (fp->filp),file_inode (fp->filp), &stat); basic_info->CreationTime =cpu_to_le64 (fp->create_time);
@@ -4184,9 +4184,8 @@ static int get_file_basic_info(struct smb2_query_info_rsp *rsp, basic_info->Attributes = fp->f_ci->m_fattr; basic_info->Pad1 =0 ; rsp->OutputBufferLength = -cpu_to_le32 (offsetof(struct smb2_file_all_info , AllocationSize)); -inc_rfc1001_len (rsp_org, offsetof(struct smb2_file_all_info , - AllocationSize)); +cpu_to_le32 (sizeof (struct smb2_file_basic_info )); +inc_rfc1001_len (rsp_org,sizeof (struct smb2_file_basic_info ));return 0 ; }
@@ -5412,7 +5411,7 @@ static int smb2_create_link(struct ksmbd_work *work,static int set_file_basic_info (struct ksmbd_file *fp,char *buf,struct ksmbd_share_config *share) { -struct smb2_file_all_info *file_info; +struct smb2_file_basic_info *file_info;struct iattr attrs;struct timespec64 ctime;struct file *filp;
@@ -5423,7 +5422,7 @@ static int set_file_basic_info(struct ksmbd_file *fp, char *buf,if (!(fp->daccess &FILE_WRITE_ATTRIBUTES_LE ))return -EACCES ; - file_info = (struct smb2_file_all_info *)buf; + file_info = (struct smb2_file_basic_info *)buf; attrs.ia_valid =0 ; filp = fp->filp; inode =file_inode (filp);
fs/ksmbd/smb2pdu.h +9 -0
@@ -1464,6 +1464,15 @@ struct smb2_file_all_info { /* data block encoding of response to level 18 */char FileName[1 ]; } __packed;/* level 18 Query */ +struct smb2_file_basic_info {/* data block encoding of response to level 18 */ +__le64 CreationTime;/* Beginning of FILE_BASIC_INFO equivalent */ +__le64 LastAccessTime; +__le64 LastWriteTime; +__le64 ChangeTime; +__le32 Attributes; +__u32 Pad1;/* End of FILE_BASIC_INFO_INFO equivalent */ +} __packed; +struct smb2_file_alt_name_info {__le32 FileNameLength;char FileName[0 ];
Signature · 1 line
2.31.1
PATCH v5 4/20 ksmbd: add request buffer validation in smb2_set_info
In reply to Ralph BoehmeFrom: Namjae Jeon <[email protected]>
Add buffer validation in smb2_set_info, and remove unused variable in set_file_basic_info. and smb2_set_info infolevel functions take structure pointer argument.
--- fs/ksmbd/smb2pdu.c | 149 ++++++++++++++++++++++++++++++++------------- 1 file changed, 107 insertions(+), 42 deletions(-)
fs/ksmbd/smb2pdu.c +107 -42
@@ -2102,16 +2102,22 @@ static noinline int create_smb2_pipe(struct ksmbd_work *work)* smb2_set_ea() - handler for setting extended attributes using set * info command * @eabuf: set info command buffer +* @buf_len: set info command buffer length * @path: dentry path for get ea * * Return: 0 on success, otherwise error */ -static int smb2_set_ea (struct smb2_ea_info *eabuf,struct path *path) +static int smb2_set_ea (struct smb2_ea_info *eabuf,unsigned int buf_len, +struct path *path) {struct user_namespace *user_ns =mnt_user_ns (path->mnt);char *attr_name =NULL , *value;int rc =0 ; -int next =0 ; +unsigned int next =0 ; + +if (buf_len <sizeof (struct smb2_ea_info ) + eabuf->EaNameLength + +le16_to_cpu (eabuf->EaValueLength)) +return -EINVAL ; attr_name =kmalloc (XATTR_NAME_MAX +1 ,GFP_KERNEL );if (!attr_name)
@@ -2176,7 +2182,13 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, struct path *path) next: next =le32_to_cpu (eabuf->NextEntryOffset); +if (next ==0 || buf_len < next) +break ; + buf_len -= next; eabuf = (struct smb2_ea_info *)((char *)eabuf + next); +if (next < (u32 )eabuf->EaNameLength +le16_to_cpu (eabuf->EaValueLength)) +break ; + }while (next !=0 );kfree (attr_name);
@@ -2757,7 +2769,15 @@ int smb2_open(struct ksmbd_work *work) created = true; user_ns =mnt_user_ns (path.mnt);if (ea_buf) { - rc =smb2_set_ea (&ea_buf->ea, &path); +if (le32_to_cpu (ea_buf->ccontext.DataLength) < +sizeof (struct smb2_ea_info )) { + rc = -EINVAL ; + goto err_out; + } + + rc =smb2_set_ea (&ea_buf->ea, +le32_to_cpu (ea_buf->ccontext.DataLength), + &path);if (rc == -EOPNOTSUPP ) rc =0 ;else if (rc)
@@ -5341,7 +5361,7 @@ static int smb2_rename(struct ksmbd_work *work,static int smb2_create_link (struct ksmbd_work *work,struct ksmbd_share_config *share,struct smb2_file_link_info *file_info, -struct file *filp, +unsigned int buf_len,struct file *filp,struct nls_table *local_nls) {char *link_name =NULL , *target_name =NULL , *pathname =NULL ;
@@ -5349,6 +5369,10 @@ static int smb2_create_link(struct ksmbd_work *work,bool file_present = true;int rc; +if (buf_len < (u64 )sizeof (struct smb2_file_link_info ) + +le32_to_cpu (file_info->FileNameLength)) +return -EINVAL ; +ksmbd_debug (SMB ,"setting FILE_LINK_INFORMATION\n" ); pathname =kmalloc (PATH_MAX ,GFP_KERNEL );if (!pathname)
@@ -5408,10 +5432,10 @@ static int smb2_create_link(struct ksmbd_work *work,return rc; } -static int set_file_basic_info (struct ksmbd_file *fp,char *buf, +static int set_file_basic_info (struct ksmbd_file *fp, +struct smb2_file_basic_info *file_info,struct ksmbd_share_config *share) { -struct smb2_file_basic_info *file_info;struct iattr attrs;struct timespec64 ctime;struct file *filp;
@@ -5422,7 +5446,6 @@ static int set_file_basic_info(struct ksmbd_file *fp, char *buf,if (!(fp->daccess &FILE_WRITE_ATTRIBUTES_LE ))return -EACCES ; - file_info = (struct smb2_file_basic_info *)buf; attrs.ia_valid =0 ; filp = fp->filp; inode =file_inode (filp);
@@ -5499,7 +5522,8 @@ static int set_file_basic_info(struct ksmbd_file *fp, char *buf, }static int set_file_allocation_info (struct ksmbd_work *work, -struct ksmbd_file *fp,char *buf) +struct ksmbd_file *fp, +struct smb2_file_alloc_info *file_alloc_info) {/* * TODO : It's working fine only when store dos attributes
@@ -5507,7 +5531,6 @@ static int set_file_allocation_info(struct ksmbd_work *work,* properly with any smb.conf option */ -struct smb2_file_alloc_info *file_alloc_info;loff_t alloc_blks;struct inode *inode;int rc;
@@ -5515,7 +5538,6 @@ static int set_file_allocation_info(struct ksmbd_work *work,if (!(fp->daccess &FILE_WRITE_DATA_LE ))return -EACCES ; - file_alloc_info = (struct smb2_file_alloc_info *)buf; alloc_blks = (le64_to_cpu (file_alloc_info->AllocationSize) +511 ) >>9 ; inode =file_inode (fp->filp);
@@ -5551,9 +5573,8 @@ static int set_file_allocation_info(struct ksmbd_work *work, }static int set_end_of_file_info (struct ksmbd_work *work,struct ksmbd_file *fp, -char *buf) +struct smb2_file_eof_info *file_eof_info) { -struct smb2_file_eof_info *file_eof_info;loff_t newsize;struct inode *inode;int rc;
@@ -5561,7 +5582,6 @@ static int set_end_of_file_info(struct ksmbd_work *work, struct ksmbd_file *fp,if (!(fp->daccess &FILE_WRITE_DATA_LE ))return -EACCES ; - file_eof_info = (struct smb2_file_eof_info *)buf; newsize =le64_to_cpu (file_eof_info->EndOfFile); inode =file_inode (fp->filp);
@@ -5588,7 +5608,8 @@ static int set_end_of_file_info(struct ksmbd_work *work, struct ksmbd_file *fp, }static int set_rename_info (struct ksmbd_work *work,struct ksmbd_file *fp, -char *buf) +struct smb2_file_rename_info *rename_info, +unsigned int buf_len) {struct user_namespace *user_ns;struct ksmbd_file *parent_fp;
@@ -5601,6 +5622,10 @@ static int set_rename_info(struct ksmbd_work *work, struct ksmbd_file *fp,return -EACCES ; } +if (buf_len < (u64 )sizeof (struct smb2_file_rename_info ) + +le32_to_cpu (rename_info->FileNameLength)) +return -EINVAL ; + user_ns =file_mnt_user_ns (fp->filp);if (ksmbd_stream_fd (fp)) goto next;
@@ -5623,14 +5648,13 @@ static int set_rename_info(struct ksmbd_work *work, struct ksmbd_file *fp, } } next: -return smb2_rename (work, fp, user_ns, - (struct smb2_file_rename_info *)buf, +return smb2_rename (work, fp, user_ns, rename_info, work->sess->conn->local_nls); } -static int set_file_disposition_info (struct ksmbd_file *fp,char *buf) +static int set_file_disposition_info (struct ksmbd_file *fp, +struct smb2_file_disposition_info *file_info) { -struct smb2_file_disposition_info *file_info;struct inode *inode;if (!(fp->daccess &FILE_DELETE_LE )) {
@@ -5639,7 +5663,6 @@ static int set_file_disposition_info(struct ksmbd_file *fp, char *buf) } inode =file_inode (fp->filp); - file_info = (struct smb2_file_disposition_info *)buf;if (file_info->DeletePending) {if (S_ISDIR (inode->i_mode) &&ksmbd_vfs_empty_dir (fp) == -ENOTEMPTY )
@@ -5651,15 +5674,14 @@ static int set_file_disposition_info(struct ksmbd_file *fp, char *buf)return 0 ; } -static int set_file_position_info (struct ksmbd_file *fp,char *buf) +static int set_file_position_info (struct ksmbd_file *fp, +struct smb2_file_pos_info *file_info) { -struct smb2_file_pos_info *file_info;loff_t current_byte_offset;unsigned long sector_size;struct inode *inode; inode =file_inode (fp->filp); - file_info = (struct smb2_file_pos_info *)buf; current_byte_offset =le64_to_cpu (file_info->CurrentByteOffset); sector_size = inode->i_sb->s_blocksize;
@@ -5675,12 +5697,11 @@ static int set_file_position_info(struct ksmbd_file *fp, char *buf)return 0 ; } -static int set_file_mode_info (struct ksmbd_file *fp,char *buf) +static int set_file_mode_info (struct ksmbd_file *fp, +struct smb2_file_mode_info *file_info) { -struct smb2_file_mode_info *file_info;__le32 mode; - file_info = (struct smb2_file_mode_info *)buf; mode = file_info->Mode; if ((mode & ~FILE_MODE_INFO_MASK) ||
@@ -5710,40 +5731,74 @@ static int set_file_mode_info(struct ksmbd_file *fp, char *buf)* TODO: need to implement an error handling for STATUS_INFO_LENGTH_MISMATCH */ static int smb2_set_info_file (struct ksmbd_work *work,struct ksmbd_file *fp, -int info_class,char *buf, +struct smb2_set_info_req *req,struct ksmbd_share_config *share) { -switch (info_class) { +unsigned int buf_len =le32_to_cpu (req->BufferLength); + +switch (req->FileInfoClass) {case FILE_BASIC_INFORMATION : -return set_file_basic_info (fp, buf, share); + { +if (buf_len <sizeof (struct smb2_file_basic_info )) +return -EINVAL ; +return set_file_basic_info (fp, (struct smb2_file_basic_info *)req->Buffer, share); + }case FILE_ALLOCATION_INFORMATION : -return set_file_allocation_info (work, fp, buf); + { +if (buf_len <sizeof (struct smb2_file_alloc_info )) +return -EINVAL ; +return set_file_allocation_info (work, fp, + (struct smb2_file_alloc_info *)req->Buffer); + }case FILE_END_OF_FILE_INFORMATION : -return set_end_of_file_info (work, fp, buf); + { +if (buf_len <sizeof (struct smb2_file_eof_info )) +return -EINVAL ; +return set_end_of_file_info (work, fp, + (struct smb2_file_eof_info *)req->Buffer); + }case FILE_RENAME_INFORMATION : + {if (!test_tree_conn_flag (work->tcon,KSMBD_TREE_CONN_FLAG_WRITABLE )) {ksmbd_debug (SMB ,"User does not have write permission\n" );return -EACCES ; } -return set_rename_info (work, fp, buf); +if (buf_len <sizeof (struct smb2_file_rename_info )) +return -EINVAL ; + +return set_rename_info (work, fp, + (struct smb2_file_rename_info *)req->Buffer, + buf_len); + }case FILE_LINK_INFORMATION : + { +if (buf_len <sizeof (struct smb2_file_link_info )) +return -EINVAL ; +return smb2_create_link (work, work->tcon->share_conf, - (struct smb2_file_link_info *)buf, fp->filp, + (struct smb2_file_link_info *)req->Buffer, + buf_len, fp->filp, work->sess->conn->local_nls); - + }case FILE_DISPOSITION_INFORMATION : + {if (!test_tree_conn_flag (work->tcon,KSMBD_TREE_CONN_FLAG_WRITABLE )) {ksmbd_debug (SMB ,"User does not have write permission\n" );return -EACCES ; } -return set_file_disposition_info (fp, buf); +if (buf_len <sizeof (struct smb2_file_disposition_info )) +return -EINVAL ; + +return set_file_disposition_info (fp, + (struct smb2_file_disposition_info *)req->Buffer); + }case FILE_FULL_EA_INFORMATION : {if (!(fp->daccess &FILE_WRITE_EA_LE )) {
@@ -5752,18 +5807,29 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,return -EACCES ; } -return smb2_set_ea ((struct smb2_ea_info *)buf, - &fp->filp->f_path); - } +if (buf_len <sizeof (struct smb2_ea_info )) +return -EINVAL ; +return smb2_set_ea ((struct smb2_ea_info *)req->Buffer, + buf_len, &fp->filp->f_path); + }case FILE_POSITION_INFORMATION : -return set_file_position_info (fp, buf); + { +if (buf_len <sizeof (struct smb2_file_pos_info )) +return -EINVAL ; +return set_file_position_info (fp, (struct smb2_file_pos_info *)req->Buffer); + }case FILE_MODE_INFORMATION : -return set_file_mode_info (fp, buf); + { +if (buf_len <sizeof (struct smb2_file_mode_info )) +return -EINVAL ; + +return set_file_mode_info (fp, (struct smb2_file_mode_info *)req->Buffer); + } } -pr_err ("Unimplemented Fileinfoclass :%d\n" , info_class); +pr_err ("Unimplemented Fileinfoclass :%d\n" , req->FileInfoClass);return -EOPNOTSUPP ; }
@@ -5824,8 +5890,7 @@ int smb2_set_info(struct ksmbd_work *work)switch (req->InfoType) {case SMB2_O_INFO_FILE :ksmbd_debug (SMB ,"GOT SMB2_O_INFO_FILE\n" ); - rc =smb2_set_info_file (work, fp, req->FileInfoClass, - req->Buffer, work->tcon->share_conf); + rc =smb2_set_info_file (work, fp, req, work->tcon->share_conf);break ;case SMB2_O_INFO_SECURITY :ksmbd_debug (SMB ,"GOT SMB2_O_INFO_SECURITY\n" );
Signature · 1 line
2.31.1
PATCH v5 5/20 ksmbd: check strictly data area in ksmbd_smb2_check_message()
In reply to Ralph BoehmeFrom: Namjae Jeon <[email protected]>
When invalid data offset and data length in request, ksmbd_smb2_check_message check strictly and doesn't allow to process such requests.
--- fs/ksmbd/smb2misc.c | 98 ++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 51 deletions(-)
fs/ksmbd/smb2misc.c +47 -51
@@ -80,18 +80,21 @@ static const bool has_smb2_data_area[NUMBER_OF_SMB2_COMMANDS] = { };/* -* Returns the pointer to the beginning of the data area. Length of the data -* area and the offset to it (from the beginning of the smb are also returned. +* Set length of the data area and the offset to arguments. +* if they are invalid, return error. */ -static char *smb2_get_data_area_len (int *off,int *len,struct smb2_hdr *hdr) +static int smb2_get_data_area_len (unsigned int *off,unsigned int *len, +struct smb2_hdr *hdr) { +int ret =0 ; + *off =0 ; *len =0 ;/* error reqeusts do not have data area */ if (hdr->Status && hdr->Status !=STATUS_MORE_PROCESSING_REQUIRED && (((struct smb2_err_rsp *)hdr)->StructureSize) ==SMB2_ERROR_STRUCTURE_SIZE2_LE ) -return NULL ; +return ret;/* * Following commands have data areas so we have to get the location
@@ -165,69 +168,60 @@ static char *smb2_get_data_area_len(int *off, int *len, struct smb2_hdr *hdr)case SMB2_IOCTL : *off =le32_to_cpu (((struct smb2_ioctl_req *)hdr)->InputOffset); *len =le32_to_cpu (((struct smb2_ioctl_req *)hdr)->InputCount); -break ;default :ksmbd_debug (SMB ,"no length check for command\n" );break ; } -/* -* Invalid length or offset probably means data area is invalid, but -* we have little choice but to ignore the data area in this case. -*/ if (*off >4096 ) { -ksmbd_debug (SMB ,"offset %d too large, data area ignored\n" , - *off); - *len =0 ; - *off =0 ; - }else if (*off <0 ) { -ksmbd_debug (SMB , -"negative offset %d to data invalid ignore data area\n" , - *off); - *off =0 ; - *len =0 ; - }else if (*len <0 ) { -ksmbd_debug (SMB , -"negative data length %d invalid, data area ignored\n" , - *len); - *len =0 ; - }else if (*len >128 *1024 ) { -ksmbd_debug (SMB ,"data area larger than 128K: %d\n" , *len); - *len =0 ; +ksmbd_debug (SMB ,"offset %d too large\n" , *off); + ret = -EINVAL ; + }else if ((u64)*off + *len >MAX_STREAM_PROT_LEN ) { +ksmbd_debug (SMB ,"Request is larger than maximum stream protocol length(%u): %llu\n" , +MAX_STREAM_PROT_LEN , (u64)*off + *len); + ret = -EINVAL ; } -/* return pointer to beginning of data area, ie offset from SMB start */ -if ((*off !=0 ) && (*len !=0 )) -return (char *)hdr + *off; -else -return NULL ; +return ret; }/* * Calculate the size of the SMB message based on the fixed header * portion, the number of word parameters and the data portion of the message. */ -static unsigned int smb2_calc_size (void *buf) +static int smb2_calc_size (void *buf,unsigned int *len) {struct smb2_pdu *pdu = (struct smb2_pdu *)buf;struct smb2_hdr *hdr = &pdu->hdr; -int offset;/* the offset from the beginning of SMB to data area */ -int data_length;/* the length of the variable length data area */ +unsigned int offset;/* the offset from the beginning of SMB to data area */ +unsigned int data_length;/* the length of the variable length data area */ +int ret; +/* Structure Size has already been checked to make sure it is 64 */ -int len =le16_to_cpu (hdr->StructureSize); + *len =le16_to_cpu (hdr->StructureSize);/* * StructureSize2, ie length of fixed parameter area has already * been checked to make sure it is the correct length. */ - len +=le16_to_cpu (pdu->StructureSize2); + *len +=le16_to_cpu (pdu->StructureSize2); +/* +* StructureSize2 of smb2_lock pdu is set to 48, indicating +* the size of smb2 lock request with single smb2_lock_element +* regardless of number of locks. Subtract single +* smb2_lock_element for correct buffer size check. +*/ +if (hdr->Command ==SMB2_LOCK ) + *len -=sizeof (struct smb2_lock_element );if (has_smb2_data_area[le16_to_cpu (hdr->Command)] == false) goto calc_size_exit; -smb2_get_data_area_len (&offset, &data_length, hdr); -ksmbd_debug (SMB ,"SMB2 data length %d offset %d\n" , data_length, + ret =smb2_get_data_area_len (&offset, &data_length, hdr); +if (ret) +return ret; +ksmbd_debug (SMB ,"SMB2 data length %u offset %u\n" , data_length, offset);if (data_length >0 ) {
@@ -237,16 +231,19 @@ static unsigned int smb2_calc_size(void *buf)* for some commands, typically those with odd StructureSize, * so we must add one to the calculation. */ -if (offset +1 < len) +if (offset +1 < *len) {ksmbd_debug (SMB , -"data area offset %d overlaps SMB2 header %d\n" , - offset +1 , len); -else - len = offset + data_length; +"data area offset %d overlaps SMB2 header %u\n" , + offset +1 , *len); +return -EINVAL ; + } + + *len = offset + data_length; } + calc_size_exit: -ksmbd_debug (SMB ,"SMB2 len %d\n" , len); -return len; +ksmbd_debug (SMB ,"SMB2 len %u\n" , *len); +return 0 ; }static inline int smb2_query_info_req_len (struct smb2_query_info_req *h)
@@ -391,9 +388,11 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)return 1 ; } - clc_len =smb2_calc_size (hdr); +if (smb2_calc_size (hdr, &clc_len)) +return 1 ; +if (len != clc_len) { -/* server can return one byte more due to implied bcc[0] */ +/* client can return one byte more due to implied bcc[0] */ if (clc_len == len +1 )return 0 ;
@@ -418,9 +417,6 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)return 0 ; } -if (command ==SMB2_LOCK_HE && len ==88 ) -return 0 ; - ksmbd_debug(SMB, "cli req too short, len %d not %d. cmd:%d mid:%llu\n", len, clc_len, command,
Signature · 1 line
2.31.1
PATCH v5 6/20 ksmbd: add validation in smb2 negotiate
In reply to Ralph BoehmeFrom: Namjae Jeon <[email protected]>
This patch add validation to check request buffer check in smb2 negotiate and fix null pointer deferencing oops in smb3_preauth_hash_rsp() that found from manual test.
--- fs/ksmbd/smb2pdu.c | 42 +++++++++++++++++++++++++++++++++++++++++- fs/ksmbd/smb_common.c | 32 +++++++++++++++++++++++++++----- 2 files changed, 68 insertions(+), 6 deletions(-)
fs/ksmbd/smb2pdu.c +41 -1
@@ -1067,6 +1067,7 @@ int smb2_handle_negotiate(struct ksmbd_work *work)struct smb2_negotiate_req *req = work->request_buf;struct smb2_negotiate_rsp *rsp = work->response_buf;int rc =0 ; +unsigned int smb2_buf_len, smb2_neg_size;__le32 status;ksmbd_debug (SMB ,"Received negotiate request\n" );
@@ -1084,6 +1085,44 @@ int smb2_handle_negotiate(struct ksmbd_work *work) goto err_out; } + smb2_buf_len =get_rfc1002_len (work->request_buf); + smb2_neg_size = offsetof(struct smb2_negotiate_req , Dialects) -4 ; +if (smb2_neg_size > smb2_buf_len) { + rsp->hdr.Status =STATUS_INVALID_PARAMETER ; + rc = -EINVAL ; + goto err_out; + } + +if (conn->dialect ==SMB311_PROT_ID ) { +unsigned int nego_ctxt_off =le32_to_cpu (req->NegotiateContextOffset); + +if (smb2_buf_len < nego_ctxt_off) { + rsp->hdr.Status =STATUS_INVALID_PARAMETER ; + rc = -EINVAL ; + goto err_out; + } + +if (smb2_neg_size > nego_ctxt_off) { + rsp->hdr.Status =STATUS_INVALID_PARAMETER ; + rc = -EINVAL ; + goto err_out; + } + +if (smb2_neg_size +le16_to_cpu (req->DialectCount) *sizeof (__le16) > + nego_ctxt_off) { + rsp->hdr.Status =STATUS_INVALID_PARAMETER ; + rc = -EINVAL ; + goto err_out; + } + }else { +if (smb2_neg_size +le16_to_cpu (req->DialectCount) *sizeof (__le16) > + smb2_buf_len) { + rsp->hdr.Status =STATUS_INVALID_PARAMETER ; + rc = -EINVAL ; + goto err_out; + } + } + conn->cli_cap =le32_to_cpu (req->Capabilities);switch (conn->dialect) {case SMB311_PROT_ID :
@@ -8301,7 +8340,8 @@ void smb3_preauth_hash_rsp(struct ksmbd_work *work)WORK_BUFFERS (work, req, rsp); -if (le16_to_cpu (req->Command) ==SMB2_NEGOTIATE_HE ) +if (le16_to_cpu (req->Command) ==SMB2_NEGOTIATE_HE && + conn->preauth_info)ksmbd_gen_preauth_integrity_hash (conn, (char *)rsp, conn->preauth_info->Preauth_HashValue);
fs/ksmbd/smb_common.c +27 -5
@@ -168,10 +168,12 @@ static bool supported_protocol(int idx) idx <= server_conf.max_protocol); } -static char *next_dialect (char *dialect,int *next_off) +static char *next_dialect (char *dialect,int *next_off,int bcount) { dialect = dialect + *next_off; - *next_off =strlen (dialect); + *next_off =strnlen (dialect, bcount); +if (dialect[*next_off] !='\0' ) +return NULL ;return dialect; }
@@ -186,7 +188,9 @@ static int ksmbd_lookup_dialect_by_name(char *cli_dialects, __le16 byte_count) dialect = cli_dialects; bcount =le16_to_cpu (byte_count); do { - dialect = next_dialect(dialect, &next); + dialect = next_dialect(dialect, &next, bcount); + if (!dialect) + break; ksmbd_debug(SMB, "client requested dialect %s\n", dialect); if (!strcmp(dialect, smb1_protos[i].name)) {
@@ -234,13 +238,22 @@ int ksmbd_lookup_dialect_by_id(__le16 *cli_dialects, __le16 dialects_count)static int ksmbd_negotiate_smb_dialect (void *buf) { -__le32 proto; +int smb_buf_length =get_rfc1002_len (buf); +__le32 proto = ((struct smb2_hdr *)buf)->ProtocolId; - proto = ((struct smb2_hdr *)buf)->ProtocolId;if (proto ==SMB2_PROTO_NUMBER ) {struct smb2_negotiate_req *req; +int smb2_neg_size = + offsetof(struct smb2_negotiate_req , Dialects) -4 ; req = (struct smb2_negotiate_req *)buf; +if (smb2_neg_size > smb_buf_length) + goto err_out; + +if (smb2_neg_size +le16_to_cpu (req->DialectCount) *sizeof (__le16) > + smb_buf_length) + goto err_out; +return ksmbd_lookup_dialect_by_id (req->Dialects, req->DialectCount); }
@@ -250,10 +263,19 @@ static int ksmbd_negotiate_smb_dialect(void *buf)struct smb_negotiate_req *req; req = (struct smb_negotiate_req *)buf; +if (le16_to_cpu (req->ByteCount) <2 ) + goto err_out; + +if (offsetof(struct smb_negotiate_req , DialectsArray) -4 + +le16_to_cpu (req->ByteCount) > smb_buf_length) { + goto err_out; + } +return ksmbd_lookup_dialect_by_name (req->DialectsArray, req->ByteCount); } +err_out:return BAD_PROT_ID ; }
Signature · 1 line
2.31.1
PATCH v5 7/20 ksmbd: add buffer validation for SMB2_CREATE_CONTEXT
In reply to Ralph BoehmeFrom: Hyunchul Lee <[email protected]>
Add buffer validation for SMB2_CREATE_CONTEXT.
--- fs/ksmbd/oplock.c | 41 +++++++++++++++++++++++++++++++---------- fs/ksmbd/smb2pdu.c | 25 ++++++++++++++++++++++++- fs/ksmbd/smbacl.c | 21 +++++++++++++++++++-- 3 files changed, 74 insertions(+), 13 deletions(-)
fs/ksmbd/oplock.c +31 -10
@@ -1451,26 +1451,47 @@ struct lease_ctx_info *parse_lease_state(void *open_req)*/ struct create_context *smb2_find_context_vals (void *open_req,const char *tag) { -char *data_offset;struct create_context *cc;unsigned int next =0 ;char *name;struct smb2_create_req *req = (struct smb2_create_req *)open_req; +unsigned int remain_len, name_off, name_len, value_off, value_len, + cc_len; - data_offset = (char *)req +4 +le32_to_cpu (req->CreateContextsOffset); - cc = (struct create_context *)data_offset; +/* +* CreateContextsOffset and CreateContextsLength are guaranteed to +* be valid because of ksmbd_smb2_check_message(). +*/ + cc = (struct create_context *)((char *)req +4 + +le32_to_cpu (req->CreateContextsOffset)); + remain_len =le32_to_cpu (req->CreateContextsLength);do { -int val; - cc = (struct create_context *)((char *)cc + next); - name =le16_to_cpu (cc->NameOffset) + (char *)cc; - val =le16_to_cpu (cc->NameLength); -if (val <4 ) +if (remain_len < offsetof(struct create_context , Buffer))return ERR_PTR (-EINVAL ); -if (memcmp (name, tag, val) ==0 ) -return cc; next =le32_to_cpu (cc->Next); + name_off =le16_to_cpu (cc->NameOffset); + name_len =le16_to_cpu (cc->NameLength); + value_off =le16_to_cpu (cc->DataOffset); + value_len =le32_to_cpu (cc->DataLength); + cc_len = next ? next : remain_len; + +if ((next &0x7 ) !=0 || + next > remain_len || + name_off != offsetof(struct create_context , Buffer) || + name_len <4 || + name_off + name_len > cc_len || + (value_off &0x7 ) !=0 || + (value_off && (value_off < name_off + name_len)) || + ((u64 )value_off + value_len > cc_len)) +return ERR_PTR (-EINVAL ); + + name = (char *)cc + name_off; +if (memcmp (name, tag, name_len) ==0 ) +return cc; + + remain_len -= next; }while (next !=0 );return NULL ;
fs/ksmbd/smb2pdu.c +24 -1
@@ -2427,6 +2427,10 @@ static int smb2_create_sd_buffer(struct ksmbd_work *work,ksmbd_debug (SMB ,"Set ACLs using SMB2_CREATE_SD_BUFFER context\n" ); sd_buf = (struct create_sd_buf_req *)context; +if (le16_to_cpu (context->DataOffset) + +le32_to_cpu (context->DataLength) < +sizeof (struct create_sd_buf_req )) +return -EINVAL ;return set_info_sec (work->conn, work->tcon, path, &sd_buf->ntsd,le32_to_cpu (sd_buf->ccontext.DataLength), true); }
@@ -2621,6 +2625,12 @@ int smb2_open(struct ksmbd_work *work) goto err_out1; }else if (context) { ea_buf = (struct create_ea_buf_req *)context; +if (le16_to_cpu (context->DataOffset) + +le32_to_cpu (context->DataLength) < +sizeof (struct create_ea_buf_req )) { + rc = -EINVAL ; + goto err_out1; + }if (req->CreateOptions &FILE_NO_EA_KNOWLEDGE_LE ) { rsp->hdr.Status =STATUS_ACCESS_DENIED ; rc = -EACCES ;
@@ -2659,6 +2669,12 @@ int smb2_open(struct ksmbd_work *work) }else if (context) {struct create_posix *posix = (struct create_posix *)context; +if (le16_to_cpu (context->DataOffset) + +le32_to_cpu (context->DataLength) < +sizeof (struct create_posix )) { + rc = -EINVAL ; + goto err_out1; + }ksmbd_debug (SMB ,"get posix context\n" ); posix_mode =le32_to_cpu (posix->Mode);
@@ -3049,9 +3065,16 @@ int smb2_open(struct ksmbd_work *work) rc =PTR_ERR (az_req); goto err_out; }else if (az_req) { -loff_t alloc_size =le64_to_cpu (az_req->AllocationSize); +loff_t alloc_size;int err; +if (le16_to_cpu (az_req->ccontext.DataOffset) + +le32_to_cpu (az_req->ccontext.DataLength) < +sizeof (struct create_alloc_size_req )) { + rc = -EINVAL ; + goto err_out; + } + alloc_size =le64_to_cpu (az_req->AllocationSize);ksmbd_debug (SMB ,"request smb2 create allocate size : %llu\n" , alloc_size);
fs/ksmbd/smbacl.c +19 -2
@@ -380,7 +380,7 @@ static void parse_dacl(struct user_namespace *user_ns, {int i, ret;int num_aces =0 ; -int acl_size; +unsigned int acl_size;char *acl_base;struct smb_ace **ppace;struct posix_acl_entry *cf_pace, *cf_pdace;
@@ -392,7 +392,7 @@ static void parse_dacl(struct user_namespace *user_ns,return ;/* validate that we do not go past end of acl */ -if (end_of_acl <= (char *)pdacl || +if (end_of_acl < (char *)pdacl +sizeof (struct smb_acl ) || end_of_acl < (char *)pdacl +le16_to_cpu (pdacl->size)) {pr_err ("ACL too small to parse DACL\n" );return ;
@@ -431,8 +431,22 @@ static void parse_dacl(struct user_namespace *user_ns,* user/group/other have no permissions */ for (i =0 ; i < num_aces; ++i) { +if (end_of_acl - acl_base < acl_size) +break ; + ppace[i] = (struct smb_ace *)(acl_base + acl_size); acl_base = (char *)ppace[i]; + acl_size = offsetof(struct smb_ace , sid) + + offsetof(struct smb_sid , sub_auth); + +if (end_of_acl - acl_base < acl_size || + ppace[i]->sid.num_subauth >SID_MAX_SUB_AUTHORITIES || + (end_of_acl - acl_base < + acl_size +sizeof (__le32) * ppace[i]->sid.num_subauth) || + (le16_to_cpu (ppace[i]->size) < + acl_size +sizeof (__le32) * ppace[i]->sid.num_subauth)) +break ; + acl_size =le16_to_cpu (ppace[i]->size); ppace[i]->access_req =smb_map_generic_desired_access (ppace[i]->access_req);
@@ -807,6 +821,9 @@ int parse_sec_desc(struct user_namespace *user_ns, struct smb_ntsd *pntsd,if (!pntsd)return -EIO ; +if (acl_len <sizeof (struct smb_ntsd )) +return -EINVAL ; + owner_sid_ptr = (struct smb_sid *)((char *)pntsd +le32_to_cpu (pntsd->osidoffset)); group_sid_ptr = (struct smb_sid *)((char *)pntsd +
Signature · 1 line
2.31.1
PATCH v5 8/20 ksmbd: remove the leftover of smb2.0 dialect support
In reply to Ralph BoehmeFrom: Namjae Jeon <[email protected]>
Although ksmbd doesn't send SMB2.0 support in supported dialect list of smb negotiate response, There is the leftover of smb2.0 dialect. This patch remove it not to support SMB2.0 in ksmbd.
--- fs/ksmbd/smb2ops.c | 5 ----- fs/ksmbd/smb2pdu.c | 34 +++++++++------------------------- fs/ksmbd/smb2pdu.h | 1 - fs/ksmbd/smb_common.c | 6 +++--- 4 files changed, 12 insertions(+), 34 deletions(-)
fs/ksmbd/smb2ops.c +0 -5
@@ -187,11 +187,6 @@ static struct smb_version_cmds smb2_0_server_cmds[NUMBER_OF_SMB2_COMMANDS] = { [SMB2_CHANGE_NOTIFY_HE] = { .proc = smb2_notify}, }; -int init_smb2_0_server (struct ksmbd_conn *conn) -{ -return -EOPNOTSUPP ; -} -/** * init_smb2_1_server() - initialize a smb server connection with smb2.1 * command dispatcher
fs/ksmbd/smb2pdu.c +9 -25
@@ -236,9 +236,6 @@ int init_smb2_neg_rsp(struct ksmbd_work *work)if (conn->need_neg == false)return -EINVAL ; -if (!(conn->dialect >=SMB20_PROT_ID && - conn->dialect <=SMB311_PROT_ID )) -return -EINVAL ; rsp_hdr = work->response_buf;
@@ -1166,13 +1163,6 @@ int smb2_handle_negotiate(struct ksmbd_work *work)case SMB21_PROT_ID :init_smb2_1_server (conn);break ; -case SMB20_PROT_ID : - rc =init_smb2_0_server (conn); -if (rc) { - rsp->hdr.Status =STATUS_NOT_SUPPORTED ; - goto err_out; - } -break ;case SMB2X_PROT_ID :case BAD_PROT_ID :default :
@@ -1191,11 +1181,9 @@ int smb2_handle_negotiate(struct ksmbd_work *work) rsp->MaxReadSize =cpu_to_le32 (conn->vals->max_read_size); rsp->MaxWriteSize =cpu_to_le32 (conn->vals->max_write_size); -if (conn->dialect >SMB20_PROT_ID ) { -memcpy (conn->ClientGUID, req->ClientGUID, -SMB2_CLIENT_GUID_SIZE ); - conn->cli_sec_mode =le16_to_cpu (req->SecurityMode); - } +memcpy (conn->ClientGUID, req->ClientGUID, +SMB2_CLIENT_GUID_SIZE ); + conn->cli_sec_mode =le16_to_cpu (req->SecurityMode); rsp->StructureSize =cpu_to_le16 (65 ); rsp->DialectRevision =cpu_to_le16 (conn->dialect);
@@ -1537,11 +1525,9 @@ static int ntlm_authenticate(struct ksmbd_work *work) } } -if (conn->dialect >SMB20_PROT_ID ) { -if (!ksmbd_conn_lookup_dialect (conn)) { -pr_err ("fail to verify the dialect\n" ); -return -ENOENT ; - } +if (!ksmbd_conn_lookup_dialect (conn)) { +pr_err ("fail to verify the dialect\n" ); +return -ENOENT ; }return 0 ; }
@@ -1623,11 +1609,9 @@ static int krb5_authenticate(struct ksmbd_work *work) } } -if (conn->dialect >SMB20_PROT_ID ) { -if (!ksmbd_conn_lookup_dialect (conn)) { -pr_err ("fail to verify the dialect\n" ); -return -ENOENT ; - } +if (!ksmbd_conn_lookup_dialect (conn)) { +pr_err ("fail to verify the dialect\n" ); +return -ENOENT ; }return 0 ; }
fs/ksmbd/smb2pdu.h +0 -1
@@ -1637,7 +1637,6 @@ struct smb2_posix_info { } __packed;/* functions */ -int init_smb2_0_server (struct ksmbd_conn *conn);void init_smb2_1_server (struct ksmbd_conn *conn);void init_smb3_0_server (struct ksmbd_conn *conn);void init_smb3_02_server (struct ksmbd_conn *conn);
fs/ksmbd/smb_common.c +3 -3
@@ -88,7 +88,7 @@ unsigned int ksmbd_server_side_copy_max_total_size(void)inline int ksmbd_min_protocol (void ) { -return SMB2_PROT ; +return SMB21_PROT ; }inline int ksmbd_max_protocol (void )
@@ -427,7 +427,7 @@ int ksmbd_extract_shortname(struct ksmbd_conn *conn, const char *longname,static int __smb2_negotiate (struct ksmbd_conn *conn) { -return (conn->dialect >=SMB20_PROT_ID && +return (conn->dialect >=SMB21_PROT_ID && conn->dialect <=SMB311_PROT_ID ); }
@@ -457,7 +457,7 @@ int ksmbd_smb_negotiate_common(struct ksmbd_work *work, unsigned int command) } } -if (command ==SMB2_NEGOTIATE_HE ) { +if (command ==SMB2_NEGOTIATE_HE &&__smb2_negotiate (conn)) { ret =smb2_handle_negotiate (work);init_smb2_neg_rsp (work);return ret;
Signature · 1 line
2.31.1
PATCH v5 9/20 ksmbd: remove NTLMv1 authentication
In reply to Ralph BoehmeFrom: Namjae Jeon <[email protected]>
Remove insecure NTLMv1 authentication.
--- fs/ksmbd/auth.c | 205 ------------------------------------------ fs/ksmbd/crypto_ctx.c | 16 ---- fs/ksmbd/crypto_ctx.h | 8 -- 3 files changed, 229 deletions(-)
fs/ksmbd/auth.c +0 -205
@@ -68,125 +68,6 @@ void ksmbd_copy_gss_neg_header(void *buf)memcpy (buf,NEGOTIATE_GSS_HEADER ,AUTH_GSS_LENGTH ); } -static void -str_to_key (unsigned char *str,unsigned char *key) -{ -int i; - - key[0 ] = str[0 ] >>1 ; - key[1 ] = ((str[0 ] &0x01 ) <<6 ) | (str[1 ] >>2 ); - key[2 ] = ((str[1 ] &0x03 ) <<5 ) | (str[2 ] >>3 ); - key[3 ] = ((str[2 ] &0x07 ) <<4 ) | (str[3 ] >>4 ); - key[4 ] = ((str[3 ] &0x0F ) <<3 ) | (str[4 ] >>5 ); - key[5 ] = ((str[4 ] &0x1F ) <<2 ) | (str[5 ] >>6 ); - key[6 ] = ((str[5 ] &0x3F ) <<1 ) | (str[6 ] >>7 ); - key[7 ] = str[6 ] &0x7F ; -for (i =0 ; i <8 ; i++) - key[i] = (key[i] <<1 ); -} - -static int -smbhash (unsigned char *out,const unsigned char *in,unsigned char *key) -{ -unsigned char key2[8 ]; -struct des_ctx ctx; - -if (fips_enabled) { -ksmbd_debug (AUTH ,"FIPS compliance enabled: DES not permitted\n" ); -return -ENOENT ; - } - -str_to_key (key, key2); -des_expand_key (&ctx, key2,DES_KEY_SIZE ); -des_encrypt (&ctx, out, in); -memzero_explicit (&ctx,sizeof (ctx)); -return 0 ; -} - -static int ksmbd_enc_p24 (unsigned char *p21,const unsigned char *c8,unsigned char *p24) -{ -int rc; - - rc =smbhash (p24, c8, p21); -if (rc) -return rc; - rc =smbhash (p24 +8 , c8, p21 +7 ); -if (rc) -return rc; -return smbhash (p24 +16 , c8, p21 +14 ); -} - -/* produce a md4 message digest from data of length n bytes */ -static int ksmbd_enc_md4 (unsigned char *md4_hash,unsigned char *link_str, -int link_len) -{ -int rc; -struct ksmbd_crypto_ctx *ctx; - - ctx =ksmbd_crypto_ctx_find_md4 (); -if (!ctx) { -ksmbd_debug (AUTH ,"Crypto md4 allocation error\n" ); -return -ENOMEM ; - } - - rc =crypto_shash_init (CRYPTO_MD4 (ctx)); -if (rc) { -ksmbd_debug (AUTH ,"Could not init md4 shash\n" ); - goto out; - } - - rc =crypto_shash_update (CRYPTO_MD4 (ctx), link_str, link_len); -if (rc) { -ksmbd_debug (AUTH ,"Could not update with link_str\n" ); - goto out; - } - - rc =crypto_shash_final (CRYPTO_MD4 (ctx), md4_hash); -if (rc) -ksmbd_debug (AUTH ,"Could not generate md4 hash\n" ); -out: -ksmbd_release_crypto_ctx (ctx); -return rc; -} - -static int ksmbd_enc_update_sess_key (unsigned char *md5_hash,char *nonce, -char *server_challenge,int len) -{ -int rc; -struct ksmbd_crypto_ctx *ctx; - - ctx =ksmbd_crypto_ctx_find_md5 (); -if (!ctx) { -ksmbd_debug (AUTH ,"Crypto md5 allocation error\n" ); -return -ENOMEM ; - } - - rc =crypto_shash_init (CRYPTO_MD5 (ctx)); -if (rc) { -ksmbd_debug (AUTH ,"Could not init md5 shash\n" ); - goto out; - } - - rc =crypto_shash_update (CRYPTO_MD5 (ctx), server_challenge, len); -if (rc) { -ksmbd_debug (AUTH ,"Could not update with challenge\n" ); - goto out; - } - - rc =crypto_shash_update (CRYPTO_MD5 (ctx), nonce, len); -if (rc) { -ksmbd_debug (AUTH ,"Could not update with nonce\n" ); - goto out; - } - - rc =crypto_shash_final (CRYPTO_MD5 (ctx), md5_hash); -if (rc) -ksmbd_debug (AUTH ,"Could not generate md5 hash\n" ); -out: -ksmbd_release_crypto_ctx (ctx); -return rc; -} -/** * ksmbd_gen_sess_key() - function to generate session key * @sess: session of connection
@@ -324,43 +205,6 @@ static int calc_ntlmv2_hash(struct ksmbd_session *sess, char *ntlmv2_hash,return ret; } -/** -* ksmbd_auth_ntlm() - NTLM authentication handler -* @sess: session of connection -* @pw_buf: NTLM challenge response -* @passkey: user password -* -* Return: 0 on success, error number on error -*/ -int ksmbd_auth_ntlm (struct ksmbd_session *sess,char *pw_buf) -{ -int rc; -unsigned char p21[21 ]; -char key[CIFS_AUTH_RESP_SIZE ]; - -memset (p21,'\0' ,21 ); -memcpy (p21,user_passkey (sess->user),CIFS_NTHASH_SIZE ); - rc =ksmbd_enc_p24 (p21, sess->ntlmssp.cryptkey, key); -if (rc) { -pr_err ("password processing failed\n" ); -return rc; - } - -ksmbd_enc_md4 (sess->sess_key,user_passkey (sess->user), -CIFS_SMB1_SESSKEY_SIZE ); -memcpy (sess->sess_key +CIFS_SMB1_SESSKEY_SIZE , key, -CIFS_AUTH_RESP_SIZE ); - sess->sequence_number =1 ; - -if (strncmp (pw_buf, key,CIFS_AUTH_RESP_SIZE ) !=0 ) { -ksmbd_debug (AUTH ,"ntlmv1 authentication failed\n" ); -return -EINVAL ; - } - -ksmbd_debug (AUTH ,"ntlmv1 authentication pass\n" ); -return 0 ; -} -/** * ksmbd_auth_ntlmv2() - NTLMv2 authentication handler * @sess: session of connection
@@ -441,44 +285,6 @@ int ksmbd_auth_ntlmv2(struct ksmbd_session *sess, struct ntlmv2_resp *ntlmv2,return rc; } -/** -* __ksmbd_auth_ntlmv2() - NTLM2(extended security) authentication handler -* @sess: session of connection -* @client_nonce: client nonce from LM response. -* @ntlm_resp: ntlm response data from client. -* -* Return: 0 on success, error number on error -*/ -static int __ksmbd_auth_ntlmv2 (struct ksmbd_session *sess,char *client_nonce, -char *ntlm_resp) -{ -char sess_key[CIFS_SMB1_SESSKEY_SIZE ] = {0 }; -int rc; -unsigned char p21[21 ]; -char key[CIFS_AUTH_RESP_SIZE ]; - - rc =ksmbd_enc_update_sess_key (sess_key, - client_nonce, - (char *)sess->ntlmssp.cryptkey,8 ); -if (rc) { -pr_err ("password processing failed\n" ); - goto out; - } - -memset (p21,'\0' ,21 ); -memcpy (p21,user_passkey (sess->user),CIFS_NTHASH_SIZE ); - rc =ksmbd_enc_p24 (p21, sess_key, key); -if (rc) { -pr_err ("password processing failed\n" ); - goto out; - } - -if (memcmp (ntlm_resp, key,CIFS_AUTH_RESP_SIZE ) !=0 ) - rc = -EINVAL ; -out: -return rc; -} -/** * ksmbd_decode_ntlmssp_auth_blob() - helper function to construct * authenticate blob
@@ -512,17 +318,6 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob, nt_off =le32_to_cpu (authblob->NtChallengeResponse.BufferOffset); nt_len =le16_to_cpu (authblob->NtChallengeResponse.Length); -/* process NTLM authentication */ -if (nt_len ==CIFS_AUTH_RESP_SIZE ) { -if (le32_to_cpu (authblob->NegotiateFlags) & -NTLMSSP_NEGOTIATE_EXTENDED_SEC ) -return __ksmbd_auth_ntlmv2 (sess, (char *)authblob + - lm_off, (char *)authblob + nt_off); -else -return ksmbd_auth_ntlm (sess, (char *)authblob + - nt_off); - } -/* TODO : use domain name that imported from configuration file */ domain_name = smb_strndup_from_utf16((const char *)authblob + le32_to_cpu(authblob->DomainName.BufferOffset),
fs/ksmbd/crypto_ctx.c +0 -16
@@ -81,12 +81,6 @@ static struct shash_desc *alloc_shash_desc(int id)case CRYPTO_SHASH_SHA512 : tfm =crypto_alloc_shash ("sha512" ,0 ,0 );break ; -case CRYPTO_SHASH_MD4 : - tfm =crypto_alloc_shash ("md4" ,0 ,0 ); -break ; -case CRYPTO_SHASH_MD5 : - tfm =crypto_alloc_shash ("md5" ,0 ,0 ); -break ;default :return NULL ; }
@@ -214,16 +208,6 @@ struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_sha512(void)return ____crypto_shash_ctx_find (CRYPTO_SHASH_SHA512 ); } -struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_md4 (void ) -{ -return ____crypto_shash_ctx_find (CRYPTO_SHASH_MD4 ); -} - -struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_md5 (void ) -{ -return ____crypto_shash_ctx_find (CRYPTO_SHASH_MD5 ); -} -static struct ksmbd_crypto_ctx *____crypto_aead_ctx_find (int id) {struct ksmbd_crypto_ctx *ctx;
fs/ksmbd/crypto_ctx.h +0 -8
@@ -15,8 +15,6 @@ enum {CRYPTO_SHASH_CMACAES ,CRYPTO_SHASH_SHA256 ,CRYPTO_SHASH_SHA512 , -CRYPTO_SHASH_MD4 , -CRYPTO_SHASH_MD5 , CRYPTO_SHASH_MAX, };
@@ -43,8 +41,6 @@ struct ksmbd_crypto_ctx {#define CRYPTO_CMACAES (c) ((c)->desc[CRYPTO_SHASH_CMACAES])#define CRYPTO_SHA256 (c) ((c)->desc[CRYPTO_SHASH_SHA256])#define CRYPTO_SHA512 (c) ((c)->desc[CRYPTO_SHASH_SHA512]) -#define CRYPTO_MD4 (c) ((c)->desc[CRYPTO_SHASH_MD4]) -#define CRYPTO_MD5 (c) ((c)->desc[CRYPTO_SHASH_MD5])#define CRYPTO_HMACMD5_TFM (c) ((c)->desc[CRYPTO_SHASH_HMACMD5]->tfm)#define CRYPTO_HMACSHA256_TFM (c)\
@@ -52,8 +48,6 @@ struct ksmbd_crypto_ctx {#define CRYPTO_CMACAES_TFM (c) ((c)->desc[CRYPTO_SHASH_CMACAES]->tfm)#define CRYPTO_SHA256_TFM (c) ((c)->desc[CRYPTO_SHASH_SHA256]->tfm)#define CRYPTO_SHA512_TFM (c) ((c)->desc[CRYPTO_SHASH_SHA512]->tfm) -#define CRYPTO_MD4_TFM (c) ((c)->desc[CRYPTO_SHASH_MD4]->tfm) -#define CRYPTO_MD5_TFM (c) ((c)->desc[CRYPTO_SHASH_MD5]->tfm)#define CRYPTO_GCM (c) ((c)->ccmaes[CRYPTO_AEAD_AES_GCM])#define CRYPTO_CCM (c) ((c)->ccmaes[CRYPTO_AEAD_AES_CCM])
@@ -64,8 +58,6 @@ struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_hmacsha256(void);struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_cmacaes (void );struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_sha512 (void );struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_sha256 (void ); -struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_md4 (void ); -struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_md5 (void );struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_gcm (void );struct ksmbd_crypto_ctx *ksmbd_crypto_ctx_find_ccm (void );void ksmbd_crypto_destroy (void );
Signature · 1 line
2.31.1
PATCH v5 10/20 ksmbd: fix transform header validation
In reply to Ralph BoehmeFrom: Namjae Jeon <[email protected]>
Validate that the transform and smb request headers are present before checking OriginalMessageSize and SessionId fields.
--- fs/ksmbd/smb2pdu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
fs/ksmbd/smb2pdu.c +9 -9
@@ -8455,16 +8455,8 @@ int smb3_decrypt_req(struct ksmbd_work *work)unsigned int buf_data_size = pdu_length +4 -sizeof (struct smb2_transform_hdr );struct smb2_transform_hdr *tr_hdr = (struct smb2_transform_hdr *)buf; -unsigned int orig_len =le32_to_cpu (tr_hdr->OriginalMessageSize);int rc =0 ; - sess =ksmbd_session_lookup_all (conn,le64_to_cpu (tr_hdr->SessionId)); -if (!sess) { -pr_err ("invalid session id(%llx) in transform header\n" , -le64_to_cpu (tr_hdr->SessionId)); -return -ECONNABORTED ; - } -if (pdu_length +4 <sizeof (struct smb2_transform_hdr ) +sizeof (struct smb2_hdr )) { pr_err("Transform message is too small (%u)\n",
@@ -8472,11 +8464,19 @@ int smb3_decrypt_req(struct ksmbd_work *work)return -ECONNABORTED ; } -if (pdu_length +4 < orig_len +sizeof (struct smb2_transform_hdr )) { +if (pdu_length +4 < +le32_to_cpu (tr_hdr->OriginalMessageSize) +sizeof (struct smb2_transform_hdr )) {pr_err ("Transform message is broken\n" );return -ECONNABORTED ; } + sess =ksmbd_session_lookup_all (conn,le64_to_cpu (tr_hdr->SessionId)); +if (!sess) { +pr_err ("invalid session id(%llx) in transform header\n" , +le64_to_cpu (tr_hdr->SessionId)); +return -ECONNABORTED ; + } + iov[0 ].iov_base = buf; iov[0 ].iov_len =sizeof (struct smb2_transform_hdr ); iov[1 ].iov_base = buf +sizeof (struct smb2_transform_hdr );
Signature · 1 line
2.31.1
PATCH v5 11/20 ksmbd: use ksmbd_req_buf_next() in ksmbd_smb2_check_message()
In reply to Ralph BoehmeNo change in behaviour.
--- fs/ksmbd/smb2misc.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
fs/ksmbd/smb2misc.c +1 -6
@@ -329,17 +329,12 @@ static int smb2_validate_credit_charge(struct smb2_hdr *hdr)int ksmbd_smb2_check_message (struct ksmbd_work *work) { -struct smb2_pdu *pdu = work->request_buf; +struct smb2_pdu *pdu =ksmbd_req_buf_next (work);struct smb2_hdr *hdr = &pdu->hdr;int command;__u32 clc_len;/* calculated length */ __u32 len =get_rfc1002_len (pdu); -if (work->next_smb2_rcv_hdr_off) { - pdu =ksmbd_req_buf_next (work); - hdr = &pdu->hdr; - } -if (le32_to_cpu (hdr->NextCommand) >0 ) { len =le32_to_cpu (hdr->NextCommand); }else if (work->next_smb2_rcv_hdr_off) {
Signature · 1 line
2.31.1
PATCH v5 12/20 ksmbd: use ksmbd_req_buf_next() in ksmbd_verify_smb_message()
In reply to Ralph BoehmeNo change in behaviour.
--- fs/ksmbd/smb_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ksmbd/smb_common.c +1 -1
@@ -132,7 +132,7 @@ int ksmbd_lookup_protocol_idx(char *str)*/ int ksmbd_verify_smb_message (struct ksmbd_work *work) { -struct smb2_hdr *smb2_hdr = work->request_buf + work->next_smb2_rcv_hdr_off; +struct smb2_hdr *smb2_hdr =ksmbd_req_buf_next (work);struct smb_hdr *hdr;if (smb2_hdr->ProtocolId ==SMB2_PROTO_NUMBER )
Signature · 1 line
2.31.1
PATCH v5 13/20 ksmbd: remove ksmbd_verify_smb_message()
In reply to Ralph BoehmeAnother leftover from SMB1 support. Remove it and use ksmbd_verify_smb_message() directly in __process_request().
--- fs/ksmbd/server.c | 2 +- fs/ksmbd/smb_common.c | 24 ------------------------ fs/ksmbd/smb_common.h | 1 - 3 files changed, 1 insertion(+), 26 deletions(-)
fs/ksmbd/server.c +1 -1
@@ -114,7 +114,7 @@ static int __process_request(struct ksmbd_work *work, struct ksmbd_conn *conn,if (check_conn_state (work))return SERVER_HANDLER_CONTINUE ; -if (ksmbd_verify_smb_message (work)) +if (ksmbd_smb2_check_message (work))return SERVER_HANDLER_ABORT ; command = conn->ops->get_cmd_val (work);
fs/ksmbd/smb_common.c +0 -24
@@ -122,30 +122,6 @@ int ksmbd_lookup_protocol_idx(char *str)return -1 ; } -/** -* ksmbd_verify_smb_message() - check for valid smb2 request header -* @work: smb work -* -* check for valid smb signature and packet direction(request/response) -* -* Return: 0 on success, otherwise -EINVAL -*/ -int ksmbd_verify_smb_message (struct ksmbd_work *work) -{ -struct smb2_hdr *smb2_hdr =ksmbd_req_buf_next (work); -struct smb_hdr *hdr; - -if (smb2_hdr->ProtocolId ==SMB2_PROTO_NUMBER ) -return ksmbd_smb2_check_message (work); - - hdr = work->request_buf; -if (*(__le32 *)hdr->Protocol ==SMB1_PROTO_NUMBER && - hdr->Command ==SMB_COM_NEGOTIATE ) -return 0 ; - -return -EINVAL ; -} -/** * ksmbd_smb_request() - check for valid smb request type * @conn: connection instance
fs/ksmbd/smb_common.h +0 -1
@@ -488,7 +488,6 @@ int ksmbd_max_protocol(void);int ksmbd_lookup_protocol_idx (char *str); -int ksmbd_verify_smb_message (struct ksmbd_work *work);bool ksmbd_smb_request (struct ksmbd_conn *conn);int ksmbd_lookup_dialect_by_id (__le16 *cli_dialects,__le16 dialects_count);
Signature · 1 line
2.31.1
Namjae Jeon
maintainerRe: [PATCH v5 13/20] ksmbd: remove ksmbd_verify_smb_message()
2021-10-01 21:04 GMT+09:00, Ralph Boehme <[email protected]>:
Quoted 48 lines
Another leftover from SMB1 support. Remove it and use
ksmbd_verify_smb_message()
directly in__process_request().Cc Namjae Jeon <[email protected]>Cc Tom Talpey <[email protected]>Cc Ronnie Sahlberg <[email protected]>Cc Steve French <[email protected]>Cc Hyunchul Lee <[email protected]>Signed-off-by Ralph Boehme <[email protected]>--- fs/ksmbd/server.c | 2 +- fs/ksmbd/smb_common.c | 24 ------------------------ fs/ksmbd/smb_common.h | 1 - 3 files changed, 1 insertion(+), 26 deletions(-)fs/ksmbd/server.c +1
-1@@ -114,7 +114,7 @@ static int __process_request(struct ksmbd_work *work, struct ksmbd_conn *conn, if (check_conn_state(work)) return SERVER_HANDLER_CONTINUE; -if (ksmbd_verify_smb_message (work)) +if (ksmbd_smb2_check_message (work))return SERVER_HANDLER_ABORT ;fs/ksmbd/server.c +0
-0command = conn->ops->get_cmd_val (work);fs/ksmbd/smb_common.c +0
-10@@ -122,30 +122,6 @@ int ksmbd_lookup_protocol_idx(char *str)return -1 ; } -/** -* ksmbd_verify_smb_message() - check for valid smb2 request header -* @work: smb work -* -* check for valid smb signature and packet direction(request/response) -* -* Return: 0 on success, otherwise -EINVAL -*/ -int ksmbd_verify_smb_message (struct ksmbd_work *work) -{
fs/ksmbd/smb_common.c int ksmbd_lookup_protocol_idx(char *str) · line 144
Quoted 10 lines
fs/ksmbd/smb_common.c +0
-10-struct smb2_hdr *smb2_hdr =ksmbd_req_buf_next (work); -struct smb_hdr *hdr; - -if (smb2_hdr->ProtocolId ==SMB2_PROTO_NUMBER ) -return ksmbd_smb2_check_message (work); - - hdr = work->request_buf; -if (*(__le32 *)hdr->Protocol ==SMB1_PROTO_NUMBER && - hdr->Command ==SMB_COM_NEGOTIATE ) -return 0 ;
smb1 negotiate is needed for windows connection. Have you tested with windows client ?
Quoted 24 lines
fs/ksmbd/smb_common.c +0
-4- -return -EINVAL ; -} -/** * ksmbd_smb_request() - check for valid smb request type * @conn: connection instance fs/ksmbd/smb_common.h +0
-1@@ -488,7 +488,6 @@ int ksmbd_max_protocol(void);int ksmbd_lookup_protocol_idx (char *str); -int ksmbd_verify_smb_message (struct ksmbd_work *work);bool ksmbd_smb_request (struct ksmbd_conn *conn); int ksmbd_lookup_dialect_by_id(__le16 *cli_dialects, __le16
dialects_count);
--
2.31.1
Re: [PATCH v5 13/20] ksmbd: remove ksmbd_verify_smb_message()
Am 02.10.21 um 07:46 schrieb Namjae Jeon:
Quoted 53 lines
2021-10-01 21:04 GMT+09:00, Ralph Boehme <[email protected]>:
Quoted 52 lines
Another leftover from SMB1 support. Remove it and use
ksmbd_verify_smb_message()
directly in__process_request().Cc Namjae Jeon <[email protected]>Cc Tom Talpey <[email protected]>Cc Ronnie Sahlberg <[email protected]>Cc Steve French <[email protected]>Cc Hyunchul Lee <[email protected]>Signed-off-by Ralph Boehme <[email protected]>--- fs/ksmbd/server.c | 2 +- fs/ksmbd/smb_common.c | 24 ------------------------ fs/ksmbd/smb_common.h | 1 - 3 files changed, 1 insertion(+), 26 deletions(-)fs/ksmbd/server.c +1
-1@@ -114,7 +114,7 @@ static int __process_request(struct ksmbd_work *work, struct ksmbd_conn *conn, if (check_conn_state(work)) return SERVER_HANDLER_CONTINUE; -if (ksmbd_verify_smb_message (work)) +if (ksmbd_smb2_check_message (work))return SERVER_HANDLER_ABORT ;command = conn->ops->get_cmd_val(work);fs/ksmbd/smb_common.c +0
-14@@ -122,30 +122,6 @@ int ksmbd_lookup_protocol_idx(char *str)return -1 ; } -/** -* ksmbd_verify_smb_message() - check for valid smb2 request header -* @work: smb work -* -* check for valid smb signature and packet direction(request/response) -* -* Return: 0 on success, otherwise -EINVAL -*/ -int ksmbd_verify_smb_message (struct ksmbd_work *work) -{ -struct smb2_hdr *smb2_hdr =ksmbd_req_buf_next (work); -struct smb_hdr *hdr; - -if (smb2_hdr->ProtocolId ==SMB2_PROTO_NUMBER )
Quoted 8 lines
fs/ksmbd/smb_common.c int ksmbd_lookup_protocol_idx(char *str) · line 144
Quoted 6 lines
fs/ksmbd/smb_common.c +0
-6-return ksmbd_smb2_check_message (work); - - hdr = work->request_buf; -if (*(__le32 *)hdr->Protocol ==SMB1_PROTO_NUMBER && - hdr->Command ==SMB_COM_NEGOTIATE ) -return 0 ;smb1 negotiate is needed for windows connection. Have you tested with windows client ?
d'oh! You're right. Guess I got in a frenzy to remove more SMB1 stuff. :)
-slow
Signature · 2 lines
Ralph Boehme, Samba Team https://samba.org/ SerNet Samba Team Lead https://sernet.de/en/team-samba
Re: [PATCH v5 13/20] ksmbd: remove ksmbd_verify_smb_message()
In reply to Namjae JeonQuoted 2 lines · Namjae Jeon
smb1 negotiate is needed for windows connection. Have you tested with windows client ?
Isn't this only needed for Win7 upgrading a connection from SMB1 -> SMB2 on initial connect. I don't think Win8 and above need this.
Is this as far back as we want to support ?
Namjae Jeon
maintainerRe: [PATCH v5 13/20] ksmbd: remove ksmbd_verify_smb_message()
2021-10-04 8:37 GMT+09:00, Jeremy Allison <[email protected]>:
Quoted 5 lines · Namjae Jeon
Quoted 3 lines
smb1 negotiate is needed for windows connection. Have you tested with windows client ?
Hi Jeremy,
Quoted 5 lines
Isn't this only needed for Win7 upgrading a connection from SMB1 -> SMB2 on initial connect. I don't think Win8 and above need this.
Is this as far back as we want to support ?
Win10 still send smb1 negotiate request for auto negotiation.
Thanks!
Quoted 1 line
PATCH v5 14/20 ksmbd: add ksmbd_smb2_cur_pdu_buflen()
In reply to Ralph Boehme--- fs/ksmbd/smb2misc.c | 25 +++++++++++++++++++++++++ fs/ksmbd/smb2pdu.h | 1 + 2 files changed, 26 insertions(+)
fs/ksmbd/smb2misc.c +25 -0
@@ -427,3 +427,28 @@ int smb2_negotiate_request(struct ksmbd_work *work) {return ksmbd_smb_negotiate_common (work,SMB2_NEGOTIATE_HE ); } + +/** +* ksmbd_smb2_cur_pdu_buflen() - Get len of current SMB2 PDU buffer +* This returns the lenght including any possible padding. +* @work: smb work containing request buffer +*/ +unsigned int ksmbd_smb2_cur_pdu_buflen (struct ksmbd_work *work) +{ +struct smb2_hdr *hdr =ksmbd_req_buf_next (work); +unsigned int buf_len; +unsigned int pdu_len; + +if (hdr->NextCommand !=0 ) { +/* +* hdr->NextCommand has already been validated by +* init_chained_smb2_rsp(). +*/ +return __le32_to_cpu (hdr->NextCommand); + } + + buf_len =get_rfc1002_len (work->request_buf); + pdu_len = buf_len - work->next_smb2_rcv_hdr_off; +return pdu_len; +} +
fs/ksmbd/smb2pdu.h +1 -0
@@ -1680,6 +1680,7 @@ int smb2_set_rsp_credits(struct ksmbd_work *work);/* smb2 misc functions */ int ksmbd_smb2_check_message (struct ksmbd_work *work); +unsigned int ksmbd_smb2_cur_pdu_buflen (struct ksmbd_work *work);/* smb2 command handlers */ int smb2_handle_negotiate (struct ksmbd_work *work);
Signature · 1 line
2.31.1
Namjae Jeon
maintainerRe: [PATCH v5 14/20] ksmbd: add ksmbd_smb2_cur_pdu_buflen()
2021-10-01 21:04 GMT+09:00, Ralph Boehme <[email protected]>:
Quoted 17 lines
Cc Namjae Jeon <[email protected]>Cc Tom Talpey <[email protected]>Cc Ronnie Sahlberg <[email protected]>Cc Steve French <[email protected]>Cc Hyunchul Lee <[email protected]>Signed-off-by Ralph Boehme <[email protected]>--- fs/ksmbd/smb2misc.c | 25 +++++++++++++++++++++++++ fs/ksmbd/smb2pdu.h | 1 + 2 files changed, 26 insertions(+)fs/ksmbd/smb2misc.c +0
-0@@ -427,3 +427,28 @@ int smb2_negotiate_request(struct ksmbd_work *work) {
fs/ksmbd/smb2misc.c int smb2_negotiate_request(struct ksmbd_work *work) · line 437
Quoted 10 lines
fs/ksmbd/smb2misc.c +8
-0return ksmbd_smb_negotiate_common (work,SMB2_NEGOTIATE_HE ); } + +/** +* ksmbd_smb2_cur_pdu_buflen() - Get len of current SMB2 PDU buffer +* This returns the lenght including any possible padding. +* @work: smb work containing request buffer +*/ +unsigned int ksmbd_smb2_cur_pdu_buflen (struct ksmbd_work *work) +{
This patch will cause unused function build warning. so need to combine it with "ksmbd: use ksmbd_smb2_cur_pdu_buflen() in ksmbd_smb2_check_message() "
Thanks!
Quoted 33 lines
fs/ksmbd/smb2misc.c +17
-0+struct smb2_hdr *hdr =ksmbd_req_buf_next (work); +unsigned int buf_len; +unsigned int pdu_len; + +if (hdr->NextCommand !=0 ) { +/* +* hdr->NextCommand has already been validated by +* init_chained_smb2_rsp(). +*/ +return __le32_to_cpu (hdr->NextCommand); + } + + buf_len =get_rfc1002_len (work->request_buf); + pdu_len = buf_len - work->next_smb2_rcv_hdr_off; +return pdu_len; +} +fs/ksmbd/smb2pdu.h +1
-1@@ -1680,6 +1680,7 @@ int smb2_set_rsp_credits(struct ksmbd_work *work);/* smb2 misc functions */ int ksmbd_smb2_check_message (struct ksmbd_work *work); +unsigned int ksmbd_smb2_cur_pdu_buflen (struct ksmbd_work *work);/* smb2 command handlers */ int smb2_handle_negotiate (struct ksmbd_work *work); --2.31.1
Re: [PATCH v5 14/20] ksmbd: add ksmbd_smb2_cur_pdu_buflen()
Am 02.10.21 um 07:49 schrieb Namjae Jeon:
Quoted 23 lines
2021-10-01 21:04 GMT+09:00, Ralph Boehme <[email protected]>:
Quoted 22 lines
Cc Namjae Jeon <[email protected]>Cc Tom Talpey <[email protected]>Cc Ronnie Sahlberg <[email protected]>Cc Steve French <[email protected]>Cc Hyunchul Lee <[email protected]>Signed-off-by Ralph Boehme <[email protected]>--- fs/ksmbd/smb2misc.c | 25 +++++++++++++++++++++++++ fs/ksmbd/smb2pdu.h | 1 + 2 files changed, 26 insertions(+)fs/ksmbd/smb2misc.c +3
-0@@ -427,3 +427,28 @@ int smb2_negotiate_request(struct ksmbd_work *work) {return ksmbd_smb_negotiate_common (work,SMB2_NEGOTIATE_HE ); } + +/** +* ksmbd_smb2_cur_pdu_buflen() - Get len of current SMB2 PDU buffer
Quoted 8 lines
fs/ksmbd/smb2misc.c int smb2_negotiate_request(struct ksmbd_work *work) · line 437
Quoted 5 lines
fs/ksmbd/smb2misc.c +5
-0+* This returns the lenght including any possible padding. +* @work: smb work containing request buffer +*/ +unsigned int ksmbd_smb2_cur_pdu_buflen (struct ksmbd_work *work) +{This patch will cause unused function build warning. so need to combine it with "ksmbd: use
ksmbd_smb2_cur_pdu_buflen()inksmbd_smb2_check_message()"
ok, going to squash this into another commit that uses the function.
-slow
Signature · 2 lines
Ralph Boehme, Samba Team https://samba.org/ SerNet Samba Team Lead https://sernet.de/en/team-samba
PATCH v5 15/20 ksmbd: use ksmbd_smb2_cur_pdu_buflen() in ksmbd_smb2_check_message()
In reply to Ralph BoehmeNo change in behaviour.
--- fs/ksmbd/smb2misc.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
fs/ksmbd/smb2misc.c +2 -9
@@ -333,14 +333,7 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)struct smb2_hdr *hdr = &pdu->hdr;int command;__u32 clc_len;/* calculated length */ -__u32 len =get_rfc1002_len (pdu); - -if (le32_to_cpu (hdr->NextCommand) >0 ) { - len =le32_to_cpu (hdr->NextCommand); - }else if (work->next_smb2_rcv_hdr_off) { - len -= work->next_smb2_rcv_hdr_off; - len =round_up (len,8 ); - } +__u32 len =ksmbd_smb2_cur_pdu_buflen (work);if (check_smb2_hdr (hdr))return 1 ;
@@ -395,7 +388,7 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)* Some windows servers (win2016) will pad also the final * PDU in a compound to 8 bytes. */ -if (ALIGN (clc_len,8 ) == len) +if (ALIGN (clc_len,8 ) ==ALIGN (len,8 ))return 0 ;/*
Signature · 1 line
2.31.1
PATCH v5 16/20 ksmbd: check PDU len is at least header plus body size in ksmbd_smb2_check_message()
In reply to Ralph BoehmeNote: we already have the same check in is_chained_smb2_message(), but there it only applies to compound requests, so we have to repeat the check here to cover both cases.
--- fs/ksmbd/smb2misc.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ksmbd/smb2misc.c +3 -0
@@ -338,6 +338,9 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)if (check_smb2_hdr (hdr))return 1 ; +if (len <sizeof (struct smb2_pdu ) -4 ) +return 1 ; +if (hdr->StructureSize !=SMB2_HEADER_STRUCTURE_SIZE ) {ksmbd_debug (SMB ,"Illegal structure size %u\n" ,le16_to_cpu (hdr->StructureSize));
Signature · 1 line
2.31.1
Namjae Jeon
maintainerRe: [PATCH v5 16/20] ksmbd: check PDU len is at least header plus body size in ksmbd_smb2_check_message()
2021-10-01 21:04 GMT+09:00, Ralph Boehme <[email protected]>:
Quoted 21 lines
Note: we already have the same check in
is_chained_smb2_message(), but there it
only applies to compound requests, so we have to repeat the check here to cover
both cases.Cc Namjae Jeon <[email protected]>Cc Tom Talpey <[email protected]>Cc Ronnie Sahlberg <[email protected]>Cc Steve French <[email protected]>Cc Hyunchul Lee <[email protected]>Signed-off-by Ralph Boehme <[email protected]>--- fs/ksmbd/smb2misc.c | 3 +++ 1 file changed, 3 insertions(+)fs/ksmbd/smb2misc.c +0
-0
fs/ksmbd/smb2misc.c int ksmbd_smb2_check_message(struct ksmbd_work *work) · line 342
Quoted 5 lines
fs/ksmbd/smb2misc.c +2
-0@@ -338,6 +338,9 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)if (check_smb2_hdr (hdr))return 1 ; +if (len <sizeof (struct smb2_pdu ) -4 ) +return 1 ;
when only this patch is applied, how can you guarantee that session id and tree id of smb2 header are vaild ?
Quoted 8 lines
fs/ksmbd/smb2misc.c +1
-1+if (hdr->StructureSize !=SMB2_HEADER_STRUCTURE_SIZE ) {ksmbd_debug (SMB ,"Illegal structure size %u\n" ,le16_to_cpu (hdr->StructureSize)); --2.31.1
Re: [PATCH v5 16/20] ksmbd: check PDU len is at least header plus body size in ksmbd_smb2_check_message()
Am 02.10.21 um 07:55 schrieb Namjae Jeon:
Quoted 25 lines
2021-10-01 21:04 GMT+09:00, Ralph Boehme <[email protected]>:
Quoted 24 lines
Note: we already have the same check in
is_chained_smb2_message(), but there it
only applies to compound requests, so we have to repeat the check here to cover
both cases.Cc Namjae Jeon <[email protected]>Cc Tom Talpey <[email protected]>Cc Ronnie Sahlberg <[email protected]>Cc Steve French <[email protected]>Cc Hyunchul Lee <[email protected]>Signed-off-by Ralph Boehme <[email protected]>--- fs/ksmbd/smb2misc.c | 3 +++ 1 file changed, 3 insertions(+)fs/ksmbd/smb2misc.c +0
-0@@ -338,6 +338,9 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)if (check_smb2_hdr (hdr))return 1 ;
Quoted 4 lines
fs/ksmbd/smb2misc.c int ksmbd_smb2_check_message(struct ksmbd_work *work) · line 342
Quoted 2 lines
fs/ksmbd/smb2misc.c +2
-0+if (len <sizeof (struct smb2_pdu ) -4 ) +return 1 ;when only this patch is applied, how can you guarantee that session id and tree id of smb2 header are vaild ?
what do you mean? This just checks the actual packet lenght is large enough to access the header and the body lenght field.
-slow
Signature · 2 lines
Ralph Boehme, Samba Team https://samba.org/ SerNet Samba Team Lead https://sernet.de/en/team-samba
Re: [PATCH v5 16/20] ksmbd: check PDU len is at least header plus body size in ksmbd_smb2_check_message()
In reply to Ralph BoehmeHi Ralph,
2021년 10월 1일 (금) 오후 9:25, Ralph Boehme <[email protected]>님이 작성:
Quoted 20 lines
Note: we already have the same check in
is_chained_smb2_message(), but there it only applies to compound requests, so we have to repeat the check here to cover both cases.Cc Namjae Jeon <[email protected]>Cc Tom Talpey <[email protected]>Cc Ronnie Sahlberg <[email protected]>Cc Steve French <[email protected]>Cc Hyunchul Lee <[email protected]>Signed-off-by Ralph Boehme <[email protected]>--- fs/ksmbd/smb2misc.c | 3 +++ 1 file changed, 3 insertions(+)fs/ksmbd/smb2misc.c +0
-0
fs/ksmbd/smb2misc.c int ksmbd_smb2_check_message(struct ksmbd_work *work) · line 343
Quoted 6 lines
fs/ksmbd/smb2misc.c +3
-0@@ -338,6 +338,9 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)if (check_smb2_hdr (hdr))return 1 ; +if (len <sizeof (struct smb2_pdu ) -4 ) +return 1 ; +
Do we need this check before accessing any fields of smb2_hdr in ksmbd_verify_smb_message()?
Quoted 6 lines
fs/ksmbd/smb2misc.c +0
-1if (hdr->StructureSize !=SMB2_HEADER_STRUCTURE_SIZE ) {ksmbd_debug (SMB ,"Illegal structure size %u\n" ,le16_to_cpu (hdr->StructureSize)); --2.31.1
Signature · 2 lines
Thanks, Hyunchul
Re: [PATCH v5 16/20] ksmbd: check PDU len is at least header plus body size in ksmbd_smb2_check_message()
Am 02.10.21 um 14:45 schrieb Hyunchul Lee:
Quoted 26 lines
Hi Ralph,
2021년 10월 1일 (금) 오후 9:25, Ralph Boehme <[email protected]>님이 작성:
Quoted 23 lines
Note: we already have the same check in
is_chained_smb2_message(), but there it only applies to compound requests, so we have to repeat the check here to cover both cases.Cc Namjae Jeon <[email protected]>Cc Tom Talpey <[email protected]>Cc Ronnie Sahlberg <[email protected]>Cc Steve French <[email protected]>Cc Hyunchul Lee <[email protected]>Signed-off-by Ralph Boehme <[email protected]>--- fs/ksmbd/smb2misc.c | 3 +++ 1 file changed, 3 insertions(+)fs/ksmbd/smb2misc.c +0
-0@@ -338,6 +338,9 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)if (check_smb2_hdr (hdr))return 1 ;
Quoted 6 lines
fs/ksmbd/smb2misc.c int ksmbd_smb2_check_message(struct ksmbd_work *work) · line 343
Quoted 3 lines
fs/ksmbd/smb2misc.c +3
-0+if (len <sizeof (struct smb2_pdu ) -4 ) +return 1 ; +Do we need this check before accessing any fields of
smb2_hdrinksmbd_verify_smb_message()?
well, my idea was to have the core PDU size checking logic in ksmbd_smb2_check_message() and ksmbd_verify_smb_message() merely switches between SMB1/SMB2.
-slow
Signature · 2 lines
Ralph Boehme, Samba Team https://samba.org/ SerNet Samba Team Lead https://sernet.de/en/team-samba
Namjae Jeon
maintainerRe: [PATCH v5 16/20] ksmbd: check PDU len is at least header plus body size in ksmbd_smb2_check_message()
2021-10-02 21:49 GMT+09:00, Ralph Boehme <[email protected]>:
Quoted 37 lines
Am 02.10.21 um 14:45 schrieb Hyunchul Lee:
Quoted 29 lines
Hi Ralph,
2021년 10월 1일 (금) 오후 9:25, Ralph Boehme <[email protected]>님이 작성:
Quoted 26 lines
Note: we already have the same check in
is_chained_smb2_message(), but there it
only applies to compound requests, so we have to repeat the check here to cover
both cases.Cc Namjae Jeon <[email protected]>Cc Tom Talpey <[email protected]>Cc Ronnie Sahlberg <[email protected]>Cc Steve French <[email protected]>Cc Hyunchul Lee <[email protected]>Signed-off-by Ralph Boehme <[email protected]>--- fs/ksmbd/smb2misc.c | 3 +++ 1 file changed, 3 insertions(+)fs/ksmbd/smb2misc.c +0
-0@@ -338,6 +338,9 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)if (check_smb2_hdr (hdr))return 1 ;Quoted 6 lines
fs/ksmbd/smb2misc.c int ksmbd_smb2_check_message(struct ksmbd_work *work) · line 343
Quoted 3 lines
fs/ksmbd/smb2misc.c +3
-0+if (len <sizeof (struct smb2_pdu ) -4 ) +return 1 ; +Do we need this check before accessing any fields of
smb2_hdrinksmbd_verify_smb_message()?
Quoted 3 lines
well, my idea was to have the core PDU size checking logic in
ksmbd_smb2_check_message()andksmbd_verify_smb_message()merely switches between SMB1/SMB2.
Hyunchul pointed out that this header buffer check should be moved to the above check_smb2_hdr(). I think that it should be move to the above ksmbd_smb2_cur_pdu_buflen().
Quoted 7 lines
-slow
--
Ralph Boehme, Samba Team https://samba.org/
SerNet Samba Team Lead https://sernet.de/en/team-samba
PATCH v5 17/20 ksmdb: use cmd helper variable in smb2_get_ksmbd_tcon()
In reply to Ralph BoehmeNo change in behaviour.
--- fs/ksmbd/smb2pdu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
fs/ksmbd/smb2pdu.c +4 -3
@@ -94,12 +94,13 @@ struct channel *lookup_chann_list(struct ksmbd_session *sess, struct ksmbd_connint smb2_get_ksmbd_tcon (struct ksmbd_work *work) {struct smb2_hdr *req_hdr = work->request_buf; +unsigned int cmd =le16_to_cpu (req_hdr->Command);int tree_id; work->tcon =NULL ; -if (work->conn->ops->get_cmd_val (work) ==SMB2_TREE_CONNECT_HE || - work->conn->ops->get_cmd_val (work) ==SMB2_CANCEL_HE || - work->conn->ops->get_cmd_val (work) ==SMB2_LOGOFF_HE ) { +if (cmd ==SMB2_TREE_CONNECT_HE || + cmd ==SMB2_CANCEL_HE || + cmd ==SMB2_LOGOFF_HE ) {ksmbd_debug (SMB ,"skip to check tree connect request\n" );return 0 ; }
Signature · 1 line
2.31.1
PATCH v5 18/20 ksmdb: make smb2_get_ksmbd_tcon() callable with chained PDUs
In reply to Ralph BoehmeAlso track the tcon id of compound requests.
--- fs/ksmbd/ksmbd_work.h | 1 + fs/ksmbd/smb2pdu.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
fs/ksmbd/ksmbd_work.h +1 -0
@@ -46,6 +46,7 @@ struct ksmbd_work {u64 compound_fid;u64 compound_pfid;u64 compound_sid; +u32 compound_tid;const struct cred *saved_cred;
fs/ksmbd/smb2pdu.c +8 -1
@@ -98,6 +98,8 @@ int smb2_get_ksmbd_tcon(struct ksmbd_work *work)int tree_id; work->tcon =NULL ; + work->compound_tid =0 ; +if (cmd ==SMB2_TREE_CONNECT_HE || cmd ==SMB2_CANCEL_HE || cmd ==SMB2_LOGOFF_HE ) {
@@ -110,13 +112,18 @@ int smb2_get_ksmbd_tcon(struct ksmbd_work *work)return -ENOENT ; } - tree_id =le32_to_cpu (req_hdr->Id.SyncId.TreeId); +if (req_hdr->Flags &SMB2_FLAGS_RELATED_OPERATIONS ) + tree_id = work->compound_tid; +else + tree_id =le32_to_cpu (req_hdr->Id.SyncId.TreeId); + work->tcon =ksmbd_tree_conn_lookup (work->sess, tree_id);if (!work->tcon) {pr_err ("Invalid tid %d\n" , tree_id);return -EINVAL ; } + work->compound_tid = tree_id;return 1 ; }
Signature · 1 line
2.31.1
Namjae Jeon
maintainerRe: [PATCH v5 18/20] ksmdb: make smb2_get_ksmbd_tcon() callable with chained PDUs
2021-10-01 21:04 GMT+09:00, Ralph Boehme <[email protected]>:
Quoted 39 lines
Also track the tcon id of compound requests.
Cc Namjae Jeon <[email protected]>Cc Tom Talpey <[email protected]>Cc Ronnie Sahlberg <[email protected]>Cc Steve French <[email protected]>Cc Hyunchul Lee <[email protected]>Signed-off-by Ralph Boehme <[email protected]>--- fs/ksmbd/ksmbd_work.h | 1 + fs/ksmbd/smb2pdu.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-)fs/ksmbd/ksmbd_work.h +1
-0@@ -46,6 +46,7 @@ struct ksmbd_work {u64 compound_fid;u64 compound_pfid;u64 compound_sid; +u32 compound_tid;const struct cred *saved_cred;fs/ksmbd/smb2pdu.c +2
-0@@ -98,6 +98,8 @@ int smb2_get_ksmbd_tcon(struct ksmbd_work *work)int tree_id; work->tcon =NULL ; + work->compound_tid =0 ; +if (cmd ==SMB2_TREE_CONNECT_HE || cmd ==SMB2_CANCEL_HE || cmd ==SMB2_LOGOFF_HE ) {
fs/ksmbd/smb2pdu.c int smb2_get_ksmbd_tcon(struct ksmbd_work *work) · line 116
Quoted 6 lines
fs/ksmbd/smb2pdu.c +2
-1@@ -110,13 +112,18 @@ int smb2_get_ksmbd_tcon(struct ksmbd_work *work)return -ENOENT ; } - tree_id =le32_to_cpu (req_hdr->Id.SyncId.TreeId); +if (req_hdr->Flags &SMB2_FLAGS_RELATED_OPERATIONS ) + tree_id = work->compound_tid;
Well, Isn't that a performance degradation due to unneeded lookups?
Quoted 17 lines
fs/ksmbd/smb2pdu.c +4
-1+else + tree_id =le32_to_cpu (req_hdr->Id.SyncId.TreeId); + work->tcon =ksmbd_tree_conn_lookup (work->sess, tree_id);if (!work->tcon) {pr_err ("Invalid tid %d\n" , tree_id);return -EINVAL ; } + work->compound_tid = tree_id;return 1 ; } --2.31.1
Re: [PATCH v5 18/20] ksmdb: make smb2_get_ksmbd_tcon() callable with chained PDUs
Am 02.10.21 um 08:00 schrieb Namjae Jeon:
Quoted 43 lines
2021-10-01 21:04 GMT+09:00, Ralph Boehme <[email protected]>:
Quoted 42 lines
Also track the tcon id of compound requests.
Cc Namjae Jeon <[email protected]>Cc Tom Talpey <[email protected]>Cc Ronnie Sahlberg <[email protected]>Cc Steve French <[email protected]>Cc Hyunchul Lee <[email protected]>Signed-off-by Ralph Boehme <[email protected]>--- fs/ksmbd/ksmbd_work.h | 1 + fs/ksmbd/smb2pdu.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-)fs/ksmbd/ksmbd_work.h +1
-0@@ -46,6 +46,7 @@ struct ksmbd_work {u64 compound_fid;u64 compound_pfid;u64 compound_sid; +u32 compound_tid;const struct cred *saved_cred;fs/ksmbd/smb2pdu.c +2
-0@@ -98,6 +98,8 @@ int smb2_get_ksmbd_tcon(struct ksmbd_work *work)int tree_id; work->tcon =NULL ; + work->compound_tid =0 ; +if (cmd ==SMB2_TREE_CONNECT_HE || cmd ==SMB2_CANCEL_HE || cmd ==SMB2_LOGOFF_HE ) {@@ -110,13 +112,18 @@ int smb2_get_ksmbd_tcon(struct ksmbd_work *work)return -ENOENT ; }
Quoted 4 lines
fs/ksmbd/smb2pdu.c int smb2_get_ksmbd_tcon(struct ksmbd_work *work) · line 116
Quoted 3 lines
fs/ksmbd/smb2pdu.c +2
-1- tree_id =le32_to_cpu (req_hdr->Id.SyncId.TreeId); +if (req_hdr->Flags &SMB2_FLAGS_RELATED_OPERATIONS ) + tree_id = work->compound_tid;Well, Isn't that a performance degradation due to unneeded lookups?
I wouldn't think that this has any noticable performance impact, has it? This way the logic is easy to follow, but I'll rewrite to avoid the lookup for related operations.
-slow
Signature · 2 lines
Ralph Boehme, Samba Team https://samba.org/ SerNet Samba Team Lead https://sernet.de/en/team-samba
PATCH v5 19/20 ksmbd: make smb2_check_user_session() callabe for compound PDUs
In reply to Ralph Boehme--- fs/ksmbd/smb2pdu.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
fs/ksmbd/smb2pdu.c +10 -3
@@ -411,7 +411,6 @@ static void init_chained_smb2_rsp(struct ksmbd_work *work) work->compound_pfid =le64_to_cpu (((struct smb2_create_rsp *)rsp)-> PersistentFileId); - work->compound_sid =le64_to_cpu (rsp->SessionId); } len =get_rfc1002_len (work->response_buf) - work->next_smb2_rsp_hdr_off;
@@ -592,6 +591,8 @@ int smb2_check_user_session(struct ksmbd_work *work)unsigned long long sess_id; work->sess =NULL ; + work->compound_sid =0 ; +/* * SMB2_ECHO, SMB2_NEGOTIATE, SMB2_SESSION_SETUP command do not * require a session id, so no need to validate user session's for
@@ -604,11 +605,17 @@ int smb2_check_user_session(struct ksmbd_work *work)if (!ksmbd_conn_good (work))return -EINVAL ; - sess_id =le64_to_cpu (req_hdr->SessionId); +if (req_hdr->Flags &SMB2_FLAGS_RELATED_OPERATIONS ) + sess_id = work->compound_sid; +else + sess_id =le64_to_cpu (req_hdr->SessionId); +/* Check for validity of user session */ work->sess =ksmbd_session_lookup_all (conn, sess_id); -if (work->sess) +if (work->sess) { + work->compound_sid = sess_id;return 1 ; + }ksmbd_debug (SMB ,"Invalid user session, Uid %llu\n" , sess_id);return -EINVAL ; }
Signature · 1 line
2.31.1
Namjae Jeon
maintainerRe: [PATCH v5 19/20] ksmbd: make smb2_check_user_session() callabe for compound PDUs
2021-10-01 21:04 GMT+09:00, Ralph Boehme <[email protected]>:
Quoted 33 lines
Cc Namjae Jeon <[email protected]>Cc Tom Talpey <[email protected]>Cc Ronnie Sahlberg <[email protected]>Cc Steve French <[email protected]>Cc Hyunchul Lee <[email protected]>Signed-off-by Ralph Boehme <[email protected]>--- fs/ksmbd/smb2pdu.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)fs/ksmbd/smb2pdu.c +0
-1@@ -411,7 +411,6 @@ static void init_chained_smb2_rsp(struct ksmbd_work *work) work->compound_pfid =le64_to_cpu (((struct smb2_create_rsp *)rsp)-> PersistentFileId); - work->compound_sid =le64_to_cpu (rsp->SessionId); }fs/ksmbd/smb2pdu.c +2
-0len =get_rfc1002_len (work->response_buf) - work->next_smb2_rsp_hdr_off;@@ -592,6 +591,8 @@ int smb2_check_user_session(struct ksmbd_work *work)unsigned long long sess_id; work->sess =NULL ; + work->compound_sid =0 ; +/* * SMB2_ECHO, SMB2_NEGOTIATE, SMB2_SESSION_SETUP command do not * require a session id, so no need to validate user session's for
fs/ksmbd/smb2pdu.c int smb2_check_user_session(struct ksmbd_work *work) · line 609
Quoted 6 lines
fs/ksmbd/smb2pdu.c +2
-1@@ -604,11 +605,17 @@ int smb2_check_user_session(struct ksmbd_work *work)if (!ksmbd_conn_good (work))return -EINVAL ; - sess_id =le64_to_cpu (req_hdr->SessionId); +if (req_hdr->Flags &SMB2_FLAGS_RELATED_OPERATIONS ) + sess_id = work->compound_sid;
same comment with previous tree id patch.
Quoted 17 lines
fs/ksmbd/smb2pdu.c +6
-2+else + sess_id =le64_to_cpu (req_hdr->SessionId); +/* Check for validity of user session */ work->sess =ksmbd_session_lookup_all (conn, sess_id); -if (work->sess) +if (work->sess) { + work->compound_sid = sess_id;return 1 ; + }ksmbd_debug (SMB ,"Invalid user session, Uid %llu\n" , sess_id);return -EINVAL ; } --2.31.1
Re: [PATCH v5 19/20] ksmbd: make smb2_check_user_session() callabe for compound PDUs
Am 02.10.21 um 08:01 schrieb Namjae Jeon:
Quoted 37 lines
2021-10-01 21:04 GMT+09:00, Ralph Boehme <[email protected]>:
Quoted 36 lines
Cc Namjae Jeon <[email protected]>Cc Tom Talpey <[email protected]>Cc Ronnie Sahlberg <[email protected]>Cc Steve French <[email protected]>Cc Hyunchul Lee <[email protected]>Signed-off-by Ralph Boehme <[email protected]>--- fs/ksmbd/smb2pdu.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)fs/ksmbd/smb2pdu.c +0
-1@@ -411,7 +411,6 @@ static void init_chained_smb2_rsp(struct ksmbd_work *work) work->compound_pfid =le64_to_cpu (((struct smb2_create_rsp *)rsp)-> PersistentFileId); - work->compound_sid =le64_to_cpu (rsp->SessionId); }len = get_rfc1002_len(work->response_buf) - work->next_smb2_rsp_hdr_off;fs/ksmbd/smb2pdu.c +2
-0@@ -592,6 +591,8 @@ int smb2_check_user_session(struct ksmbd_work *work)unsigned long long sess_id; work->sess =NULL ; + work->compound_sid =0 ; +/* * SMB2_ECHO, SMB2_NEGOTIATE, SMB2_SESSION_SETUP command do not * require a session id, so no need to validate user session's for @@ -604,11 +605,17 @@ int smb2_check_user_session(struct ksmbd_work *work)if (!ksmbd_conn_good (work))return -EINVAL ;
Quoted 4 lines
fs/ksmbd/smb2pdu.c int smb2_check_user_session(struct ksmbd_work *work) · line 609
Quoted 3 lines
fs/ksmbd/smb2pdu.c +2
-1- sess_id =le64_to_cpu (req_hdr->SessionId); +if (req_hdr->Flags &SMB2_FLAGS_RELATED_OPERATIONS ) + sess_id = work->compound_sid;same comment with previous tree id patch.
same answer. :)
-slow
Signature · 2 lines
Ralph Boehme, Samba Team https://samba.org/ SerNet Samba Team Lead https://sernet.de/en/team-samba
PATCH v5 20/20 ksmdb: move session and tcon validation to ksmbd_smb2_check_message()
In reply to Ralph BoehmeFor compound non-related operations session id and tree id must be taken from earch PDU.
--- fs/ksmbd/server.c | 17 ----------------- fs/ksmbd/smb2misc.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 17 deletions(-)
fs/ksmbd/server.c +0 -17
@@ -184,23 +184,6 @@ static void __handle_ksmbd_work(struct ksmbd_work *work, goto send; } -if (conn->ops->check_user_session) { - rc = conn->ops->check_user_session (work); -if (rc <0 ) { - command = conn->ops->get_cmd_val (work); - conn->ops->set_rsp_status (work, -STATUS_USER_SESSION_DELETED ); - goto send; - }else if (rc >0 ) { - rc = conn->ops->get_ksmbd_tcon (work); -if (rc <0 ) { - conn->ops->set_rsp_status (work, -STATUS_NETWORK_NAME_DELETED ); - goto send; - } - } - } - do { rc = __process_request(work, conn, &command); if (rc == SERVER_HANDLER_ABORT)
fs/ksmbd/smb2misc.c +20 -0
@@ -334,6 +334,7 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)int command;__u32 clc_len;/* calculated length */ __u32 len =ksmbd_smb2_cur_pdu_buflen (work); +int rc;if (check_smb2_hdr (hdr))return 1 ;
@@ -416,6 +417,25 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)return 1 ; } +if (work->conn->ops->check_user_session ==NULL ) +return 0 ; + + rc = work->conn->ops->check_user_session (work); +if (rc <0 ) { + work->conn->ops->set_rsp_status (work, +STATUS_USER_SESSION_DELETED ); +return 1 ; + } +if (rc ==0 ) +return 0 ; + + rc = work->conn->ops->get_ksmbd_tcon (work); +if (rc <0 ) { + work->conn->ops->set_rsp_status (work, +STATUS_NETWORK_NAME_DELETED ); +return 1 ; + } +return 0 ; }
Signature · 1 line
2.31.1
Namjae Jeon
maintainer2021-10-01 21:04 GMT+09:00, Ralph Boehme <[email protected]>:
Quoted 24 lines
v2:
- update comments ofsmb2_get_data_area_len().
- fix wrong buffer size check infsctl_query_iface_info_ioctl().
- fix 32bit overflow insmb2_set_info.v3:
- add buffer check for ByteCount of smb negotiate request.
- Moved buffer check of to the top of loop to avoid unneeded behavior
when
out_buf_lenis smaller thannetwork_interface_info_ioctl_rsp.
- get correctout_buf_lenwhich doesn't exceed max stream protocol
length.
- subtract singlesmb2_lock_elementfor correct buffer size check inksmbd_smb2_check_message().v4:
- usework->response_szforout_buf_lencalculation insmb2_ioctl.
- movesmb2_negsize check to above to validate NegotiateContextOffset field.
- remove unneeded dialect checks insmb2_sess_setup()andsmb2_handle_negotiate().
- splitsmb2_set_infopatch into twopatches(declaring smb2_file_basic_info and buffer check)
Quoted 4 lines
v5:
- remove PDU size validation fromksmbd_conn_handler_loop()
- add PDU size validation toksmbd_smb2_check_message()
- fix compound non-related request handling
Hi Ralph,
Have you tested this patch-set ? When I tried to run xfstests test, kernel oops happen.
Can you run xfstests and check kernel oops ?
These are my xfstests command and tests.
sudo ./check cifs/001 generic/001 generic/002 generic/005 generic/006 generic/007 generic/008 generic/011 generic/013 generic/014 generic/020 generic/023 generic/024 generic/028 generic/029 generic/030 generic/032 generic/033 generic/036 generic/037 generic/069 generic/070 generic/071 generic/074 generic/080 generic/084 generic/086 generic/095 generic/098 generic/100 generic/103 generic/109 generic/113 generic/117 generic/124 generic/125 generic/129 generic/130 generic/132 generic/133 generic/135 generic/141 generic/169 generic/198 generic/207 generic/208 generic/210 generic/211 generic/212 generic/214 generic/215 generic/221 generic/225 generic/228 generic/236 generic/239 generic/241 generic/245 generic/246 generic/247 generic/248 generic/249 generic/257 generic/258 generic/286 generic/308 generic/309 generic/310 generic/313 generic/315 generic/316 generic/337 generic/339 generic/340 generic/344 generic/345 generic/346 generic/349 generic/350 generic/354 generic/360 generic/377 generic/391 generic/393 generic/394 generic/406 generic/412 generic/420 generic/422 generic/432 generic/433 generic/436 generic/437 generic/438 generic/439 generic/443 generic/445 generic/446 generic/448 generic/451 generic/452 generic/454 generic/460 generic/464 generic/465 generic/490 generic/504 generic/523 generic/524 generic/533 generic/539 generic/567 generic/568 generic/590 generic/591
Thanks!
Quoted 51 lines
Hyunchul Lee (1):
ksmbd: add buffer validation forSMB2_CREATE_CONTEXTNamjae Jeon (9):
ksmbd: add the check to vaildate if stream protocol length exceeds
maximum value
ksmbd: add validation insmb2_ioctl
ksmbd: use correct basic info level inset_file_basic_info()
ksmbd: add request buffer validation insmb2_set_info
ksmbd: check strictly data area inksmbd_smb2_check_message()
ksmbd: add validation in smb2 negotiate
ksmbd: remove the leftover of smb2.0 dialect support
ksmbd: remove NTLMv1 authentication
ksmbd: fix transform header validationRalph Boehme (10):
ksmbd: useksmbd_req_buf_next()inksmbd_smb2_check_message()
ksmbd: useksmbd_req_buf_next()inksmbd_verify_smb_message()
ksmbd: removeksmbd_verify_smb_message()
ksmbd: addksmbd_smb2_cur_pdu_buflen()
ksmbd: useksmbd_smb2_cur_pdu_buflen()inksmbd_smb2_check_message()
ksmbd: check PDU len is at least header plus body size in
ksmbd_smb2_check_message()
ksmdb: use cmd helper variable insmb2_get_ksmbd_tcon()
ksmdb: makesmb2_get_ksmbd_tcon()callable with chained PDUs
ksmbd: makesmb2_check_user_session()callabe for compound PDUs
ksmdb: move session and tcon validation toksmbd_smb2_check_message()fs/ksmbd/auth.c | 205 --------------------- fs/ksmbd/connection.c | 9 +- fs/ksmbd/crypto_ctx.c | 16 -- fs/ksmbd/crypto_ctx.h | 8 - fs/ksmbd/ksmbd_work.h | 1 + fs/ksmbd/oplock.c | 41 ++++- fs/ksmbd/server.c | 19 +- fs/ksmbd/smb2misc.c | 164 ++++++++++------- fs/ksmbd/smb2ops.c | 5 - fs/ksmbd/smb2pdu.c | 411 ++++++++++++++++++++++++++++++------------ fs/ksmbd/smb2pdu.h | 11 +- fs/ksmbd/smb_common.c | 68 +++---- fs/ksmbd/smb_common.h | 5 +- fs/ksmbd/smbacl.c | 21 ++- fs/ksmbd/vfs.c | 2 +- fs/ksmbd/vfs.h | 2 +- 16 files changed, 496 insertions(+), 492 deletions(-)--
2.31.1