@@ -121,8 +121,8 @@ static int ksmbd_gen_sess_key(struct ksmbd_session *sess, char *hash,
121
121
return rc ;
122
122
}
123
123
124
- static int calc_ntlmv2_hash (struct ksmbd_session * sess , char * ntlmv2_hash ,
125
- char * dname )
124
+ static int calc_ntlmv2_hash (struct ksmbd_conn * conn , struct ksmbd_session * sess ,
125
+ char * ntlmv2_hash , char * dname )
126
126
{
127
127
int ret , len , conv_len ;
128
128
wchar_t * domain = NULL ;
@@ -158,7 +158,7 @@ static int calc_ntlmv2_hash(struct ksmbd_session *sess, char *ntlmv2_hash,
158
158
}
159
159
160
160
conv_len = smb_strtoUTF16 (uniname , user_name (sess -> user ), len ,
161
- sess -> conn -> local_nls );
161
+ conn -> local_nls );
162
162
if (conv_len < 0 || conv_len > len ) {
163
163
ret = - EINVAL ;
164
164
goto out ;
@@ -182,7 +182,7 @@ static int calc_ntlmv2_hash(struct ksmbd_session *sess, char *ntlmv2_hash,
182
182
}
183
183
184
184
conv_len = smb_strtoUTF16 ((__le16 * )domain , dname , len ,
185
- sess -> conn -> local_nls );
185
+ conn -> local_nls );
186
186
if (conv_len < 0 || conv_len > len ) {
187
187
ret = - EINVAL ;
188
188
goto out ;
@@ -215,8 +215,9 @@ static int calc_ntlmv2_hash(struct ksmbd_session *sess, char *ntlmv2_hash,
215
215
*
216
216
* Return: 0 on success, error number on error
217
217
*/
218
- int ksmbd_auth_ntlmv2 (struct ksmbd_session * sess , struct ntlmv2_resp * ntlmv2 ,
219
- int blen , char * domain_name , char * cryptkey )
218
+ int ksmbd_auth_ntlmv2 (struct ksmbd_conn * conn , struct ksmbd_session * sess ,
219
+ struct ntlmv2_resp * ntlmv2 , int blen , char * domain_name ,
220
+ char * cryptkey )
220
221
{
221
222
char ntlmv2_hash [CIFS_ENCPWD_SIZE ];
222
223
char ntlmv2_rsp [CIFS_HMAC_MD5_HASH_SIZE ];
@@ -230,7 +231,7 @@ int ksmbd_auth_ntlmv2(struct ksmbd_session *sess, struct ntlmv2_resp *ntlmv2,
230
231
return - ENOMEM ;
231
232
}
232
233
233
- rc = calc_ntlmv2_hash (sess , ntlmv2_hash , domain_name );
234
+ rc = calc_ntlmv2_hash (conn , sess , ntlmv2_hash , domain_name );
234
235
if (rc ) {
235
236
ksmbd_debug (AUTH , "could not get v2 hash rc %d\n" , rc );
236
237
goto out ;
@@ -333,7 +334,8 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob,
333
334
/* process NTLMv2 authentication */
334
335
ksmbd_debug (AUTH , "decode_ntlmssp_authenticate_blob dname%s\n" ,
335
336
domain_name );
336
- ret = ksmbd_auth_ntlmv2 (sess , (struct ntlmv2_resp * )((char * )authblob + nt_off ),
337
+ ret = ksmbd_auth_ntlmv2 (conn , sess ,
338
+ (struct ntlmv2_resp * )((char * )authblob + nt_off ),
337
339
nt_len - CIFS_ENCPWD_SIZE ,
338
340
domain_name , conn -> ntlmssp .cryptkey );
339
341
kfree (domain_name );
@@ -659,8 +661,9 @@ struct derivation {
659
661
bool binding ;
660
662
};
661
663
662
- static int generate_key (struct ksmbd_session * sess , struct kvec label ,
663
- struct kvec context , __u8 * key , unsigned int key_size )
664
+ static int generate_key (struct ksmbd_conn * conn , struct ksmbd_session * sess ,
665
+ struct kvec label , struct kvec context , __u8 * key ,
666
+ unsigned int key_size )
664
667
{
665
668
unsigned char zero = 0x0 ;
666
669
__u8 i [4 ] = {0 , 0 , 0 , 1 };
@@ -720,8 +723,8 @@ static int generate_key(struct ksmbd_session *sess, struct kvec label,
720
723
goto smb3signkey_ret ;
721
724
}
722
725
723
- if (sess -> conn -> cipher_type == SMB2_ENCRYPTION_AES256_CCM ||
724
- sess -> conn -> cipher_type == SMB2_ENCRYPTION_AES256_GCM )
726
+ if (conn -> cipher_type == SMB2_ENCRYPTION_AES256_CCM ||
727
+ conn -> cipher_type == SMB2_ENCRYPTION_AES256_GCM )
725
728
rc = crypto_shash_update (CRYPTO_HMACSHA256 (ctx ), L256 , 4 );
726
729
else
727
730
rc = crypto_shash_update (CRYPTO_HMACSHA256 (ctx ), L128 , 4 );
@@ -756,17 +759,17 @@ static int generate_smb3signingkey(struct ksmbd_session *sess,
756
759
if (!chann )
757
760
return 0 ;
758
761
759
- if (sess -> conn -> dialect >= SMB30_PROT_ID && signing -> binding )
762
+ if (conn -> dialect >= SMB30_PROT_ID && signing -> binding )
760
763
key = chann -> smb3signingkey ;
761
764
else
762
765
key = sess -> smb3signingkey ;
763
766
764
- rc = generate_key (sess , signing -> label , signing -> context , key ,
767
+ rc = generate_key (conn , sess , signing -> label , signing -> context , key ,
765
768
SMB3_SIGN_KEY_SIZE );
766
769
if (rc )
767
770
return rc ;
768
771
769
- if (!(sess -> conn -> dialect >= SMB30_PROT_ID && signing -> binding ))
772
+ if (!(conn -> dialect >= SMB30_PROT_ID && signing -> binding ))
770
773
memcpy (chann -> smb3signingkey , key , SMB3_SIGN_KEY_SIZE );
771
774
772
775
ksmbd_debug (AUTH , "dumping generated AES signing keys\n" );
@@ -820,30 +823,31 @@ struct derivation_twin {
820
823
struct derivation decryption ;
821
824
};
822
825
823
- static int generate_smb3encryptionkey (struct ksmbd_session * sess ,
826
+ static int generate_smb3encryptionkey (struct ksmbd_conn * conn ,
827
+ struct ksmbd_session * sess ,
824
828
const struct derivation_twin * ptwin )
825
829
{
826
830
int rc ;
827
831
828
- rc = generate_key (sess , ptwin -> encryption .label ,
832
+ rc = generate_key (conn , sess , ptwin -> encryption .label ,
829
833
ptwin -> encryption .context , sess -> smb3encryptionkey ,
830
834
SMB3_ENC_DEC_KEY_SIZE );
831
835
if (rc )
832
836
return rc ;
833
837
834
- rc = generate_key (sess , ptwin -> decryption .label ,
838
+ rc = generate_key (conn , sess , ptwin -> decryption .label ,
835
839
ptwin -> decryption .context ,
836
840
sess -> smb3decryptionkey , SMB3_ENC_DEC_KEY_SIZE );
837
841
if (rc )
838
842
return rc ;
839
843
840
844
ksmbd_debug (AUTH , "dumping generated AES encryption keys\n" );
841
- ksmbd_debug (AUTH , "Cipher type %d\n" , sess -> conn -> cipher_type );
845
+ ksmbd_debug (AUTH , "Cipher type %d\n" , conn -> cipher_type );
842
846
ksmbd_debug (AUTH , "Session Id %llu\n" , sess -> id );
843
847
ksmbd_debug (AUTH , "Session Key %*ph\n" ,
844
848
SMB2_NTLMV2_SESSKEY_SIZE , sess -> sess_key );
845
- if (sess -> conn -> cipher_type == SMB2_ENCRYPTION_AES256_CCM ||
846
- sess -> conn -> cipher_type == SMB2_ENCRYPTION_AES256_GCM ) {
849
+ if (conn -> cipher_type == SMB2_ENCRYPTION_AES256_CCM ||
850
+ conn -> cipher_type == SMB2_ENCRYPTION_AES256_GCM ) {
847
851
ksmbd_debug (AUTH , "ServerIn Key %*ph\n" ,
848
852
SMB3_GCM256_CRYPTKEY_SIZE , sess -> smb3encryptionkey );
849
853
ksmbd_debug (AUTH , "ServerOut Key %*ph\n" ,
@@ -857,7 +861,8 @@ static int generate_smb3encryptionkey(struct ksmbd_session *sess,
857
861
return 0 ;
858
862
}
859
863
860
- int ksmbd_gen_smb30_encryptionkey (struct ksmbd_session * sess )
864
+ int ksmbd_gen_smb30_encryptionkey (struct ksmbd_conn * conn ,
865
+ struct ksmbd_session * sess )
861
866
{
862
867
struct derivation_twin twin ;
863
868
struct derivation * d ;
@@ -874,10 +879,11 @@ int ksmbd_gen_smb30_encryptionkey(struct ksmbd_session *sess)
874
879
d -> context .iov_base = "ServerIn " ;
875
880
d -> context .iov_len = 10 ;
876
881
877
- return generate_smb3encryptionkey (sess , & twin );
882
+ return generate_smb3encryptionkey (conn , sess , & twin );
878
883
}
879
884
880
- int ksmbd_gen_smb311_encryptionkey (struct ksmbd_session * sess )
885
+ int ksmbd_gen_smb311_encryptionkey (struct ksmbd_conn * conn ,
886
+ struct ksmbd_session * sess )
881
887
{
882
888
struct derivation_twin twin ;
883
889
struct derivation * d ;
@@ -894,7 +900,7 @@ int ksmbd_gen_smb311_encryptionkey(struct ksmbd_session *sess)
894
900
d -> context .iov_base = sess -> Preauth_HashValue ;
895
901
d -> context .iov_len = 64 ;
896
902
897
- return generate_smb3encryptionkey (sess , & twin );
903
+ return generate_smb3encryptionkey (conn , sess , & twin );
898
904
}
899
905
900
906
int ksmbd_gen_preauth_integrity_hash (struct ksmbd_conn * conn , char * buf ,
0 commit comments