@@ -87,9 +87,9 @@ struct channel *lookup_chann_list(struct ksmbd_session *sess, struct ksmbd_conn
8787 */
8888int smb2_get_ksmbd_tcon (struct ksmbd_work * work )
8989{
90- struct smb2_hdr * req_hdr = smb2_get_msg (work -> request_buf );
90+ struct smb2_hdr * req_hdr = ksmbd_req_buf_next (work );
9191 unsigned int cmd = le16_to_cpu (req_hdr -> Command );
92- int tree_id ;
92+ unsigned int tree_id ;
9393
9494 if (cmd == SMB2_TREE_CONNECT_HE ||
9595 cmd == SMB2_CANCEL_HE ||
@@ -114,7 +114,7 @@ int smb2_get_ksmbd_tcon(struct ksmbd_work *work)
114114 pr_err ("The first operation in the compound does not have tcon\n" );
115115 return - EINVAL ;
116116 }
117- if (work -> tcon -> id != tree_id ) {
117+ if (tree_id != UINT_MAX && work -> tcon -> id != tree_id ) {
118118 pr_err ("tree id(%u) is different with id(%u) in first operation\n" ,
119119 tree_id , work -> tcon -> id );
120120 return - EINVAL ;
@@ -559,9 +559,9 @@ int smb2_allocate_rsp_buf(struct ksmbd_work *work)
559559 */
560560int smb2_check_user_session (struct ksmbd_work * work )
561561{
562- struct smb2_hdr * req_hdr = smb2_get_msg (work -> request_buf );
562+ struct smb2_hdr * req_hdr = ksmbd_req_buf_next (work );
563563 struct ksmbd_conn * conn = work -> conn ;
564- unsigned int cmd = conn -> ops -> get_cmd_val ( work );
564+ unsigned int cmd = le16_to_cpu ( req_hdr -> Command );
565565 unsigned long long sess_id ;
566566
567567 /*
@@ -587,7 +587,7 @@ int smb2_check_user_session(struct ksmbd_work *work)
587587 pr_err ("The first operation in the compound does not have sess\n" );
588588 return - EINVAL ;
589589 }
590- if (work -> sess -> id != sess_id ) {
590+ if (sess_id != ULLONG_MAX && work -> sess -> id != sess_id ) {
591591 pr_err ("session id(%llu) is different with the first operation(%lld)\n" ,
592592 sess_id , work -> sess -> id );
593593 return - EINVAL ;
@@ -2467,8 +2467,9 @@ static void smb2_update_xattrs(struct ksmbd_tree_connect *tcon,
24672467 }
24682468}
24692469
2470- static int smb2_creat (struct ksmbd_work * work , struct path * path , char * name ,
2471- int open_flags , umode_t posix_mode , bool is_dir )
2470+ static int smb2_creat (struct ksmbd_work * work , struct path * parent_path ,
2471+ struct path * path , char * name , int open_flags ,
2472+ umode_t posix_mode , bool is_dir )
24722473{
24732474 struct ksmbd_tree_connect * tcon = work -> tcon ;
24742475 struct ksmbd_share_config * share = tcon -> share_conf ;
@@ -2495,7 +2496,7 @@ static int smb2_creat(struct ksmbd_work *work, struct path *path, char *name,
24952496 return rc ;
24962497 }
24972498
2498- rc = ksmbd_vfs_kern_path_locked (work , name , 0 , path , 0 );
2499+ rc = ksmbd_vfs_kern_path_locked (work , name , 0 , parent_path , path , 0 );
24992500 if (rc ) {
25002501 pr_err ("cannot get linux path (%s), err = %d\n" ,
25012502 name , rc );
@@ -2565,7 +2566,7 @@ int smb2_open(struct ksmbd_work *work)
25652566 struct ksmbd_tree_connect * tcon = work -> tcon ;
25662567 struct smb2_create_req * req ;
25672568 struct smb2_create_rsp * rsp ;
2568- struct path path ;
2569+ struct path path , parent_path ;
25692570 struct ksmbd_share_config * share = tcon -> share_conf ;
25702571 struct ksmbd_file * fp = NULL ;
25712572 struct file * filp = NULL ;
@@ -2786,7 +2787,8 @@ int smb2_open(struct ksmbd_work *work)
27862787 goto err_out1 ;
27872788 }
27882789
2789- rc = ksmbd_vfs_kern_path_locked (work , name , LOOKUP_NO_SYMLINKS , & path , 1 );
2790+ rc = ksmbd_vfs_kern_path_locked (work , name , LOOKUP_NO_SYMLINKS ,
2791+ & parent_path , & path , 1 );
27902792 if (!rc ) {
27912793 file_present = true;
27922794
@@ -2906,7 +2908,8 @@ int smb2_open(struct ksmbd_work *work)
29062908
29072909 /*create file if not present */
29082910 if (!file_present ) {
2909- rc = smb2_creat (work , & path , name , open_flags , posix_mode ,
2911+ rc = smb2_creat (work , & parent_path , & path , name , open_flags ,
2912+ posix_mode ,
29102913 req -> CreateOptions & FILE_DIRECTORY_FILE_LE );
29112914 if (rc ) {
29122915 if (rc == - ENOENT ) {
@@ -3321,8 +3324,9 @@ int smb2_open(struct ksmbd_work *work)
33213324
33223325err_out :
33233326 if (file_present || created ) {
3324- inode_unlock (d_inode (path .dentry -> d_parent ));
3325- dput (path .dentry );
3327+ inode_unlock (d_inode (parent_path .dentry ));
3328+ path_put (& path );
3329+ path_put (& parent_path );
33263330 }
33273331 ksmbd_revert_fsids (work );
33283332err_out1 :
@@ -5545,7 +5549,7 @@ static int smb2_create_link(struct ksmbd_work *work,
55455549 struct nls_table * local_nls )
55465550{
55475551 char * link_name = NULL , * target_name = NULL , * pathname = NULL ;
5548- struct path path ;
5552+ struct path path , parent_path ;
55495553 bool file_present = false;
55505554 int rc ;
55515555
@@ -5575,7 +5579,7 @@ static int smb2_create_link(struct ksmbd_work *work,
55755579
55765580 ksmbd_debug (SMB , "target name is %s\n" , target_name );
55775581 rc = ksmbd_vfs_kern_path_locked (work , link_name , LOOKUP_NO_SYMLINKS ,
5578- & path , 0 );
5582+ & parent_path , & path , 0 );
55795583 if (rc ) {
55805584 if (rc != - ENOENT )
55815585 goto out ;
@@ -5605,8 +5609,9 @@ static int smb2_create_link(struct ksmbd_work *work,
56055609 rc = - EINVAL ;
56065610out :
56075611 if (file_present ) {
5608- inode_unlock (d_inode (path .dentry -> d_parent ));
5612+ inode_unlock (d_inode (parent_path .dentry ));
56095613 path_put (& path );
5614+ path_put (& parent_path );
56105615 }
56115616 if (!IS_ERR (link_name ))
56125617 kfree (link_name );
@@ -6209,6 +6214,11 @@ int smb2_read(struct ksmbd_work *work)
62096214 unsigned int max_read_size = conn -> vals -> max_read_size ;
62106215
62116216 WORK_BUFFERS (work , req , rsp );
6217+ if (work -> next_smb2_rcv_hdr_off ) {
6218+ work -> send_no_response = 1 ;
6219+ err = - EOPNOTSUPP ;
6220+ goto out ;
6221+ }
62126222
62136223 if (test_share_config_flag (work -> tcon -> share_conf ,
62146224 KSMBD_SHARE_FLAG_PIPE )) {
@@ -8609,7 +8619,8 @@ int smb3_decrypt_req(struct ksmbd_work *work)
86098619 struct smb2_transform_hdr * tr_hdr = smb2_get_msg (buf );
86108620 int rc = 0 ;
86118621
8612- if (buf_data_size < sizeof (struct smb2_hdr )) {
8622+ if (pdu_length < sizeof (struct smb2_transform_hdr ) ||
8623+ buf_data_size < sizeof (struct smb2_hdr )) {
86138624 pr_err ("Transform message is too small (%u)\n" ,
86148625 pdu_length );
86158626 return - ECONNABORTED ;
0 commit comments