@@ -91,7 +91,6 @@ int smb2_get_ksmbd_tcon(struct ksmbd_work *work)
91
91
unsigned int cmd = le16_to_cpu (req_hdr -> Command );
92
92
int tree_id ;
93
93
94
- work -> tcon = NULL ;
95
94
if (cmd == SMB2_TREE_CONNECT_HE ||
96
95
cmd == SMB2_CANCEL_HE ||
97
96
cmd == SMB2_LOGOFF_HE ) {
@@ -105,10 +104,28 @@ int smb2_get_ksmbd_tcon(struct ksmbd_work *work)
105
104
}
106
105
107
106
tree_id = le32_to_cpu (req_hdr -> Id .SyncId .TreeId );
107
+
108
+ /*
109
+ * If request is not the first in Compound request,
110
+ * Just validate tree id in header with work->tcon->id.
111
+ */
112
+ if (work -> next_smb2_rcv_hdr_off ) {
113
+ if (!work -> tcon ) {
114
+ pr_err ("The first operation in the compound does not have tcon\n" );
115
+ return - EINVAL ;
116
+ }
117
+ if (work -> tcon -> id != tree_id ) {
118
+ pr_err ("tree id(%u) is different with id(%u) in first operation\n" ,
119
+ tree_id , work -> tcon -> id );
120
+ return - EINVAL ;
121
+ }
122
+ return 1 ;
123
+ }
124
+
108
125
work -> tcon = ksmbd_tree_conn_lookup (work -> sess , tree_id );
109
126
if (!work -> tcon ) {
110
127
pr_err ("Invalid tid %d\n" , tree_id );
111
- return - EINVAL ;
128
+ return - ENOENT ;
112
129
}
113
130
114
131
return 1 ;
@@ -547,7 +564,6 @@ int smb2_check_user_session(struct ksmbd_work *work)
547
564
unsigned int cmd = conn -> ops -> get_cmd_val (work );
548
565
unsigned long long sess_id ;
549
566
550
- work -> sess = NULL ;
551
567
/*
552
568
* SMB2_ECHO, SMB2_NEGOTIATE, SMB2_SESSION_SETUP command do not
553
569
* require a session id, so no need to validate user session's for
@@ -558,15 +574,33 @@ int smb2_check_user_session(struct ksmbd_work *work)
558
574
return 0 ;
559
575
560
576
if (!ksmbd_conn_good (conn ))
561
- return - EINVAL ;
577
+ return - EIO ;
562
578
563
579
sess_id = le64_to_cpu (req_hdr -> SessionId );
580
+
581
+ /*
582
+ * If request is not the first in Compound request,
583
+ * Just validate session id in header with work->sess->id.
584
+ */
585
+ if (work -> next_smb2_rcv_hdr_off ) {
586
+ if (!work -> sess ) {
587
+ pr_err ("The first operation in the compound does not have sess\n" );
588
+ return - EINVAL ;
589
+ }
590
+ if (work -> sess -> id != sess_id ) {
591
+ pr_err ("session id(%llu) is different with the first operation(%lld)\n" ,
592
+ sess_id , work -> sess -> id );
593
+ return - EINVAL ;
594
+ }
595
+ return 1 ;
596
+ }
597
+
564
598
/* Check for validity of user session */
565
599
work -> sess = ksmbd_session_lookup_all (conn , sess_id );
566
600
if (work -> sess )
567
601
return 1 ;
568
602
ksmbd_debug (SMB , "Invalid user session, Uid %llu\n" , sess_id );
569
- return - EINVAL ;
603
+ return - ENOENT ;
570
604
}
571
605
572
606
static void destroy_previous_session (struct ksmbd_conn * conn ,
@@ -2249,7 +2283,7 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
2249
2283
/* delete the EA only when it exits */
2250
2284
if (rc > 0 ) {
2251
2285
rc = ksmbd_vfs_remove_xattr (idmap ,
2252
- path -> dentry ,
2286
+ path ,
2253
2287
attr_name );
2254
2288
2255
2289
if (rc < 0 ) {
@@ -2263,8 +2297,7 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
2263
2297
/* if the EA doesn't exist, just do nothing. */
2264
2298
rc = 0 ;
2265
2299
} else {
2266
- rc = ksmbd_vfs_setxattr (idmap ,
2267
- path -> dentry , attr_name , value ,
2300
+ rc = ksmbd_vfs_setxattr (idmap , path , attr_name , value ,
2268
2301
le16_to_cpu (eabuf -> EaValueLength ), 0 );
2269
2302
if (rc < 0 ) {
2270
2303
ksmbd_debug (SMB ,
@@ -2321,8 +2354,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
2321
2354
return - EBADF ;
2322
2355
}
2323
2356
2324
- rc = ksmbd_vfs_setxattr (idmap , path -> dentry ,
2325
- xattr_stream_name , NULL , 0 , 0 );
2357
+ rc = ksmbd_vfs_setxattr (idmap , path , xattr_stream_name , NULL , 0 , 0 );
2326
2358
if (rc < 0 )
2327
2359
pr_err ("Failed to store XATTR stream name :%d\n" , rc );
2328
2360
return 0 ;
@@ -2350,7 +2382,7 @@ static int smb2_remove_smb_xattrs(const struct path *path)
2350
2382
if (!strncmp (name , XATTR_USER_PREFIX , XATTR_USER_PREFIX_LEN ) &&
2351
2383
!strncmp (& name [XATTR_USER_PREFIX_LEN ], STREAM_PREFIX ,
2352
2384
STREAM_PREFIX_LEN )) {
2353
- err = ksmbd_vfs_remove_xattr (idmap , path -> dentry ,
2385
+ err = ksmbd_vfs_remove_xattr (idmap , path ,
2354
2386
name );
2355
2387
if (err )
2356
2388
ksmbd_debug (SMB , "remove xattr failed : %s\n" ,
@@ -2397,8 +2429,7 @@ static void smb2_new_xattrs(struct ksmbd_tree_connect *tcon, const struct path *
2397
2429
da .flags = XATTR_DOSINFO_ATTRIB | XATTR_DOSINFO_CREATE_TIME |
2398
2430
XATTR_DOSINFO_ITIME ;
2399
2431
2400
- rc = ksmbd_vfs_set_dos_attrib_xattr (mnt_idmap (path -> mnt ),
2401
- path -> dentry , & da );
2432
+ rc = ksmbd_vfs_set_dos_attrib_xattr (mnt_idmap (path -> mnt ), path , & da );
2402
2433
if (rc )
2403
2434
ksmbd_debug (SMB , "failed to store file attribute into xattr\n" );
2404
2435
}
@@ -2972,7 +3003,7 @@ int smb2_open(struct ksmbd_work *work)
2972
3003
struct inode * inode = d_inode (path .dentry );
2973
3004
2974
3005
posix_acl_rc = ksmbd_vfs_inherit_posix_acl (idmap ,
2975
- path . dentry ,
3006
+ & path ,
2976
3007
d_inode (path .dentry -> d_parent ));
2977
3008
if (posix_acl_rc )
2978
3009
ksmbd_debug (SMB , "inherit posix acl failed : %d\n" , posix_acl_rc );
@@ -2988,7 +3019,7 @@ int smb2_open(struct ksmbd_work *work)
2988
3019
if (rc ) {
2989
3020
if (posix_acl_rc )
2990
3021
ksmbd_vfs_set_init_posix_acl (idmap ,
2991
- path . dentry );
3022
+ & path );
2992
3023
2993
3024
if (test_share_config_flag (work -> tcon -> share_conf ,
2994
3025
KSMBD_SHARE_FLAG_ACL_XATTR )) {
@@ -3028,7 +3059,7 @@ int smb2_open(struct ksmbd_work *work)
3028
3059
3029
3060
rc = ksmbd_vfs_set_sd_xattr (conn ,
3030
3061
idmap ,
3031
- path . dentry ,
3062
+ & path ,
3032
3063
pntsd ,
3033
3064
pntsd_size );
3034
3065
kfree (pntsd );
@@ -5464,7 +5495,7 @@ static int smb2_rename(struct ksmbd_work *work,
5464
5495
goto out ;
5465
5496
5466
5497
rc = ksmbd_vfs_setxattr (file_mnt_idmap (fp -> filp ),
5467
- fp -> filp -> f_path . dentry ,
5498
+ & fp -> filp -> f_path ,
5468
5499
xattr_stream_name ,
5469
5500
NULL , 0 , 0 );
5470
5501
if (rc < 0 ) {
@@ -5629,8 +5660,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
5629
5660
da .flags = XATTR_DOSINFO_ATTRIB | XATTR_DOSINFO_CREATE_TIME |
5630
5661
XATTR_DOSINFO_ITIME ;
5631
5662
5632
- rc = ksmbd_vfs_set_dos_attrib_xattr (idmap ,
5633
- filp -> f_path .dentry , & da );
5663
+ rc = ksmbd_vfs_set_dos_attrib_xattr (idmap , & filp -> f_path , & da );
5634
5664
if (rc )
5635
5665
ksmbd_debug (SMB ,
5636
5666
"failed to restore file attribute in EA\n" );
@@ -7485,7 +7515,7 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,
7485
7515
7486
7516
da .attr = le32_to_cpu (fp -> f_ci -> m_fattr );
7487
7517
ret = ksmbd_vfs_set_dos_attrib_xattr (idmap ,
7488
- fp -> filp -> f_path . dentry , & da );
7518
+ & fp -> filp -> f_path , & da );
7489
7519
if (ret )
7490
7520
fp -> f_ci -> m_fattr = old_fattr ;
7491
7521
}
0 commit comments