Lines Matching refs:ses

35 static __u32 cifs_ssetup_hdr(struct cifs_ses *ses, SESSION_SETUP_ANDX *pSMB)  in cifs_ssetup_hdr()  argument
48 pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); in cifs_ssetup_hdr()
59 if (ses->server->sign) in cifs_ssetup_hdr()
62 if (ses->capabilities & CAP_UNICODE) { in cifs_ssetup_hdr()
66 if (ses->capabilities & CAP_STATUS32) { in cifs_ssetup_hdr()
70 if (ses->capabilities & CAP_DFS) { in cifs_ssetup_hdr()
74 if (ses->capabilities & CAP_UNIX) in cifs_ssetup_hdr()
103 static void unicode_domain_string(char **pbcc_area, struct cifs_ses *ses, in unicode_domain_string() argument
110 if (ses->domainName == NULL) { in unicode_domain_string()
117 bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->domainName, in unicode_domain_string()
126 static void unicode_ssetup_strings(char **pbcc_area, struct cifs_ses *ses, in unicode_ssetup_strings() argument
141 if (ses->user_name == NULL) { in unicode_ssetup_strings()
146 bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->user_name, in unicode_ssetup_strings()
152 unicode_domain_string(&bcc_ptr, ses, nls_cp); in unicode_ssetup_strings()
158 static void ascii_ssetup_strings(char **pbcc_area, struct cifs_ses *ses, in ascii_ssetup_strings() argument
166 if (ses->user_name != NULL) { in ascii_ssetup_strings()
167 strncpy(bcc_ptr, ses->user_name, CIFS_MAX_USERNAME_LEN); in ascii_ssetup_strings()
168 bcc_ptr += strnlen(ses->user_name, CIFS_MAX_USERNAME_LEN); in ascii_ssetup_strings()
175 if (ses->domainName != NULL) { in ascii_ssetup_strings()
176 strncpy(bcc_ptr, ses->domainName, CIFS_MAX_DOMAINNAME_LEN); in ascii_ssetup_strings()
177 bcc_ptr += strnlen(ses->domainName, CIFS_MAX_DOMAINNAME_LEN); in ascii_ssetup_strings()
197 decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifs_ses *ses, in decode_unicode_ssetup() argument
205 kfree(ses->serverOS); in decode_unicode_ssetup()
206 ses->serverOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp); in decode_unicode_ssetup()
207 cifs_dbg(FYI, "serverOS=%s\n", ses->serverOS); in decode_unicode_ssetup()
214 kfree(ses->serverNOS); in decode_unicode_ssetup()
215 ses->serverNOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp); in decode_unicode_ssetup()
216 cifs_dbg(FYI, "serverNOS=%s\n", ses->serverNOS); in decode_unicode_ssetup()
223 kfree(ses->serverDomain); in decode_unicode_ssetup()
224 ses->serverDomain = cifs_strndup_from_utf16(data, bleft, true, nls_cp); in decode_unicode_ssetup()
225 cifs_dbg(FYI, "serverDomain=%s\n", ses->serverDomain); in decode_unicode_ssetup()
231 struct cifs_ses *ses, in decode_ascii_ssetup() argument
243 kfree(ses->serverOS); in decode_ascii_ssetup()
245 ses->serverOS = kzalloc(len + 1, GFP_KERNEL); in decode_ascii_ssetup()
246 if (ses->serverOS) { in decode_ascii_ssetup()
247 strncpy(ses->serverOS, bcc_ptr, len); in decode_ascii_ssetup()
248 if (strncmp(ses->serverOS, "OS/2", 4) == 0) in decode_ascii_ssetup()
259 kfree(ses->serverNOS); in decode_ascii_ssetup()
261 ses->serverNOS = kzalloc(len + 1, GFP_KERNEL); in decode_ascii_ssetup()
262 if (ses->serverNOS) in decode_ascii_ssetup()
263 strncpy(ses->serverNOS, bcc_ptr, len); in decode_ascii_ssetup()
281 struct cifs_ses *ses) in decode_ntlmssp_challenge() argument
304 memcpy(ses->ntlmssp->cryptkey, pblob->Challenge, CIFS_CRYPTO_KEY_SIZE); in decode_ntlmssp_challenge()
309 ses->ntlmssp->server_flags = le32_to_cpu(pblob->NegotiateFlags); in decode_ntlmssp_challenge()
318 ses->auth_key.response = kmemdup(bcc_ptr + tioffset, tilen, in decode_ntlmssp_challenge()
320 if (!ses->auth_key.response) { in decode_ntlmssp_challenge()
324 ses->auth_key.len = tilen; in decode_ntlmssp_challenge()
335 struct cifs_ses *ses) in build_ntlmssp_negotiate_blob() argument
349 if (ses->server->sign) in build_ntlmssp_negotiate_blob()
351 if (!ses->server->session_estab || ses->ntlmssp->sesskey_per_smbsess) in build_ntlmssp_negotiate_blob()
366 static int size_of_ntlmssp_blob(struct cifs_ses *ses) in size_of_ntlmssp_blob() argument
368 int sz = sizeof(AUTHENTICATE_MESSAGE) + ses->auth_key.len in size_of_ntlmssp_blob()
371 if (ses->domainName) in size_of_ntlmssp_blob()
372 sz += 2 * strnlen(ses->domainName, CIFS_MAX_DOMAINNAME_LEN); in size_of_ntlmssp_blob()
376 if (ses->user_name) in size_of_ntlmssp_blob()
377 sz += 2 * strnlen(ses->user_name, CIFS_MAX_USERNAME_LEN); in size_of_ntlmssp_blob()
386 struct cifs_ses *ses, in build_ntlmssp_auth_blob() argument
394 rc = setup_ntlmv2_rsp(ses, nls_cp); in build_ntlmssp_auth_blob()
400 *pbuffer = kmalloc(size_of_ntlmssp_blob(ses), GFP_KERNEL); in build_ntlmssp_auth_blob()
417 if (ses->server->sign) in build_ntlmssp_auth_blob()
419 if (!ses->server->session_estab || ses->ntlmssp->sesskey_per_smbsess) in build_ntlmssp_auth_blob()
432 if (ses->user_name != NULL) { in build_ntlmssp_auth_blob()
433 memcpy(tmp, ses->auth_key.response + CIFS_SESS_KEY_SIZE, in build_ntlmssp_auth_blob()
434 ses->auth_key.len - CIFS_SESS_KEY_SIZE); in build_ntlmssp_auth_blob()
435 tmp += ses->auth_key.len - CIFS_SESS_KEY_SIZE; in build_ntlmssp_auth_blob()
438 cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); in build_ntlmssp_auth_blob()
440 cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); in build_ntlmssp_auth_blob()
449 if (ses->domainName == NULL) { in build_ntlmssp_auth_blob()
456 len = cifs_strtoUTF16((__le16 *)tmp, ses->domainName, in build_ntlmssp_auth_blob()
465 if (ses->user_name == NULL) { in build_ntlmssp_auth_blob()
472 len = cifs_strtoUTF16((__le16 *)tmp, ses->user_name, in build_ntlmssp_auth_blob()
486 if (((ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_KEY_XCH) || in build_ntlmssp_auth_blob()
487 (ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_EXTENDED_SEC)) in build_ntlmssp_auth_blob()
488 && !calc_seckey(ses)) { in build_ntlmssp_auth_blob()
489 memcpy(tmp, ses->ntlmssp->ciphertext, CIFS_CPHTXT_SIZE); in build_ntlmssp_auth_blob()
558 struct cifs_ses *ses; member
578 struct cifs_ses *ses = sess_data->ses; in sess_alloc_buffer() local
581 rc = small_smb_init_no_tc(SMB_COM_SESSION_SETUP_ANDX, wct, ses, in sess_alloc_buffer()
624 struct cifs_ses *ses = sess_data->ses; in sess_establish_session() local
626 mutex_lock(&ses->server->srv_mutex); in sess_establish_session()
627 if (!ses->server->session_estab) { in sess_establish_session()
628 if (ses->server->sign) { in sess_establish_session()
629 ses->server->session_key.response = in sess_establish_session()
630 kmemdup(ses->auth_key.response, in sess_establish_session()
631 ses->auth_key.len, GFP_KERNEL); in sess_establish_session()
632 if (!ses->server->session_key.response) { in sess_establish_session()
633 mutex_unlock(&ses->server->srv_mutex); in sess_establish_session()
636 ses->server->session_key.len = in sess_establish_session()
637 ses->auth_key.len; in sess_establish_session()
639 ses->server->sequence_number = 0x2; in sess_establish_session()
640 ses->server->session_estab = true; in sess_establish_session()
642 mutex_unlock(&ses->server->srv_mutex); in sess_establish_session()
646 ses->status = CifsGood; in sess_establish_session()
647 ses->need_reconnect = false; in sess_establish_session()
666 rc = SendReceive2(sess_data->xid, sess_data->ses, in sess_sendreceive()
691 struct cifs_ses *ses = sess_data->ses; in sess_auth_lanman() local
704 capabilities = cifs_ssetup_hdr(ses, pSMB); in sess_auth_lanman()
708 if (ses->user_name != NULL) { in sess_auth_lanman()
717 rc = calc_lanman_hash(ses->password, ses->server->cryptkey, in sess_auth_lanman()
718 ses->server->sec_mode & SECMODE_PW_ENCRYPT ? in sess_auth_lanman()
738 ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_lanman()
760 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_lanman()
761 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_lanman()
775 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_lanman()
778 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_lanman()
798 struct cifs_ses *ses = sess_data->ses; in sess_auth_ntlm() local
810 capabilities = cifs_ssetup_hdr(ses, pSMB); in sess_auth_ntlm()
813 if (ses->user_name != NULL) { in sess_auth_ntlm()
820 rc = setup_ntlm_response(ses, sess_data->nls_cp); in sess_auth_ntlm()
828 memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE, in sess_auth_ntlm()
831 memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE, in sess_auth_ntlm()
839 if (ses->capabilities & CAP_UNICODE) { in sess_auth_ntlm()
845 unicode_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_ntlm()
847 ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_ntlm()
870 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_ntlm()
871 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_ntlm()
885 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_ntlm()
888 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_ntlm()
897 kfree(ses->auth_key.response); in sess_auth_ntlm()
898 ses->auth_key.response = NULL; in sess_auth_ntlm()
908 struct cifs_ses *ses = sess_data->ses; in sess_auth_ntlmv2() local
920 capabilities = cifs_ssetup_hdr(ses, pSMB); in sess_auth_ntlmv2()
927 if (ses->user_name != NULL) { in sess_auth_ntlmv2()
929 rc = setup_ntlmv2_rsp(ses, sess_data->nls_cp); in sess_auth_ntlmv2()
935 memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE, in sess_auth_ntlmv2()
936 ses->auth_key.len - CIFS_SESS_KEY_SIZE); in sess_auth_ntlmv2()
937 bcc_ptr += ses->auth_key.len - CIFS_SESS_KEY_SIZE; in sess_auth_ntlmv2()
943 cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); in sess_auth_ntlmv2()
948 if (ses->capabilities & CAP_UNICODE) { in sess_auth_ntlmv2()
953 unicode_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_ntlmv2()
955 ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_ntlmv2()
978 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_ntlmv2()
979 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_ntlmv2()
993 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_ntlmv2()
996 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_ntlmv2()
1005 kfree(ses->auth_key.response); in sess_auth_ntlmv2()
1006 ses->auth_key.response = NULL; in sess_auth_ntlmv2()
1017 struct cifs_ses *ses = sess_data->ses; in sess_auth_kerberos() local
1032 capabilities = cifs_ssetup_hdr(ses, pSMB); in sess_auth_kerberos()
1034 spnego_key = cifs_get_spnego_key(ses); in sess_auth_kerberos()
1054 ses->auth_key.response = kmemdup(msg->data, msg->sesskey_len, in sess_auth_kerberos()
1056 if (!ses->auth_key.response) { in sess_auth_kerberos()
1062 ses->auth_key.len = msg->sesskey_len; in sess_auth_kerberos()
1071 if (ses->capabilities & CAP_UNICODE) { in sess_auth_kerberos()
1079 unicode_domain_string(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_kerberos()
1082 ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_kerberos()
1104 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_kerberos()
1105 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_kerberos()
1129 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_kerberos()
1132 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_kerberos()
1144 kfree(ses->auth_key.response); in sess_auth_kerberos()
1145 ses->auth_key.response = NULL; in sess_auth_kerberos()
1159 struct cifs_ses *ses = sess_data->ses; in _sess_auth_rawntlmssp_assemble_req() local
1166 capabilities = cifs_ssetup_hdr(ses, pSMB); in _sess_auth_rawntlmssp_assemble_req()
1199 struct cifs_ses *ses = sess_data->ses; in sess_auth_rawntlmssp_negotiate() local
1210 ses->ntlmssp = kmalloc(sizeof(struct ntlmssp_auth), GFP_KERNEL); in sess_auth_rawntlmssp_negotiate()
1211 if (!ses->ntlmssp) { in sess_auth_rawntlmssp_negotiate()
1215 ses->ntlmssp->sesskey_per_smbsess = false; in sess_auth_rawntlmssp_negotiate()
1225 build_ntlmssp_negotiate_blob(pSMB->req.SecurityBlob, ses); in sess_auth_rawntlmssp_negotiate()
1256 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_rawntlmssp_negotiate()
1257 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_rawntlmssp_negotiate()
1270 rc = decode_ntlmssp_challenge(bcc_ptr, blob_len, ses); in sess_auth_rawntlmssp_negotiate()
1280 kfree(ses->auth_key.response); in sess_auth_rawntlmssp_negotiate()
1281 ses->auth_key.response = NULL; in sess_auth_rawntlmssp_negotiate()
1282 kfree(ses->ntlmssp); in sess_auth_rawntlmssp_negotiate()
1283 ses->ntlmssp = NULL; in sess_auth_rawntlmssp_negotiate()
1295 struct cifs_ses *ses = sess_data->ses; in sess_auth_rawntlmssp_authenticate() local
1312 &blob_len, ses, sess_data->nls_cp); in sess_auth_rawntlmssp_authenticate()
1323 smb_buf->Uid = ses->Suid; in sess_auth_rawntlmssp_authenticate()
1344 if (ses->Suid != smb_buf->Uid) { in sess_auth_rawntlmssp_authenticate()
1345 ses->Suid = smb_buf->Uid; in sess_auth_rawntlmssp_authenticate()
1346 cifs_dbg(FYI, "UID changed! new UID = %llu\n", ses->Suid); in sess_auth_rawntlmssp_authenticate()
1371 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_rawntlmssp_authenticate()
1374 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_rawntlmssp_authenticate()
1387 kfree(ses->auth_key.response); in sess_auth_rawntlmssp_authenticate()
1388 ses->auth_key.response = NULL; in sess_auth_rawntlmssp_authenticate()
1389 kfree(ses->ntlmssp); in sess_auth_rawntlmssp_authenticate()
1390 ses->ntlmssp = NULL; in sess_auth_rawntlmssp_authenticate()
1396 static int select_sec(struct cifs_ses *ses, struct sess_data *sess_data) in select_sec() argument
1400 type = cifs_select_sectype(ses->server, ses->sectype); in select_sec()
1447 int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses, in CIFS_SessSetup() argument
1453 if (ses == NULL) { in CIFS_SessSetup()
1462 rc = select_sec(ses, sess_data); in CIFS_SessSetup()
1467 sess_data->ses = ses; in CIFS_SessSetup()