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
348 if (ses->server->sign) { in build_ntlmssp_negotiate_blob()
350 if (!ses->server->session_estab || in build_ntlmssp_negotiate_blob()
351 ses->ntlmssp->sesskey_per_smbsess) in build_ntlmssp_negotiate_blob()
372 struct cifs_ses *ses, in build_ntlmssp_auth_blob() argument
387 if (ses->server->sign) { in build_ntlmssp_auth_blob()
389 if (!ses->server->session_estab || in build_ntlmssp_auth_blob()
390 ses->ntlmssp->sesskey_per_smbsess) in build_ntlmssp_auth_blob()
403 if (ses->user_name != NULL) { in build_ntlmssp_auth_blob()
404 rc = setup_ntlmv2_rsp(ses, nls_cp); in build_ntlmssp_auth_blob()
409 memcpy(tmp, ses->auth_key.response + CIFS_SESS_KEY_SIZE, in build_ntlmssp_auth_blob()
410 ses->auth_key.len - CIFS_SESS_KEY_SIZE); in build_ntlmssp_auth_blob()
411 tmp += ses->auth_key.len - CIFS_SESS_KEY_SIZE; in build_ntlmssp_auth_blob()
414 cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); in build_ntlmssp_auth_blob()
416 cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); in build_ntlmssp_auth_blob()
425 if (ses->domainName == NULL) { in build_ntlmssp_auth_blob()
432 len = cifs_strtoUTF16((__le16 *)tmp, ses->domainName, in build_ntlmssp_auth_blob()
441 if (ses->user_name == NULL) { in build_ntlmssp_auth_blob()
448 len = cifs_strtoUTF16((__le16 *)tmp, ses->user_name, in build_ntlmssp_auth_blob()
462 if (((ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_KEY_XCH) || in build_ntlmssp_auth_blob()
463 (ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_EXTENDED_SEC)) in build_ntlmssp_auth_blob()
464 && !calc_seckey(ses)) { in build_ntlmssp_auth_blob()
465 memcpy(tmp, ses->ntlmssp->ciphertext, CIFS_CPHTXT_SIZE); in build_ntlmssp_auth_blob()
534 struct cifs_ses *ses; member
554 struct cifs_ses *ses = sess_data->ses; in sess_alloc_buffer() local
557 rc = small_smb_init_no_tc(SMB_COM_SESSION_SETUP_ANDX, wct, ses, in sess_alloc_buffer()
600 struct cifs_ses *ses = sess_data->ses; in sess_establish_session() local
602 mutex_lock(&ses->server->srv_mutex); in sess_establish_session()
603 if (!ses->server->session_estab) { in sess_establish_session()
604 if (ses->server->sign) { in sess_establish_session()
605 ses->server->session_key.response = in sess_establish_session()
606 kmemdup(ses->auth_key.response, in sess_establish_session()
607 ses->auth_key.len, GFP_KERNEL); in sess_establish_session()
608 if (!ses->server->session_key.response) { in sess_establish_session()
609 mutex_unlock(&ses->server->srv_mutex); in sess_establish_session()
612 ses->server->session_key.len = in sess_establish_session()
613 ses->auth_key.len; in sess_establish_session()
615 ses->server->sequence_number = 0x2; in sess_establish_session()
616 ses->server->session_estab = true; in sess_establish_session()
618 mutex_unlock(&ses->server->srv_mutex); in sess_establish_session()
622 ses->status = CifsGood; in sess_establish_session()
623 ses->need_reconnect = false; in sess_establish_session()
641 rc = SendReceive2(sess_data->xid, sess_data->ses, in sess_sendreceive()
664 struct cifs_ses *ses = sess_data->ses; in sess_auth_lanman() local
677 capabilities = cifs_ssetup_hdr(ses, pSMB); in sess_auth_lanman()
681 if (ses->user_name != NULL) { in sess_auth_lanman()
690 rc = calc_lanman_hash(ses->password, ses->server->cryptkey, in sess_auth_lanman()
691 ses->server->sec_mode & SECMODE_PW_ENCRYPT ? in sess_auth_lanman()
709 ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_lanman()
731 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_lanman()
732 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_lanman()
746 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_lanman()
749 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_lanman()
769 struct cifs_ses *ses = sess_data->ses; in sess_auth_ntlm() local
781 capabilities = cifs_ssetup_hdr(ses, pSMB); in sess_auth_ntlm()
784 if (ses->user_name != NULL) { in sess_auth_ntlm()
791 rc = setup_ntlm_response(ses, sess_data->nls_cp); in sess_auth_ntlm()
799 memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE, in sess_auth_ntlm()
802 memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE, in sess_auth_ntlm()
810 if (ses->capabilities & CAP_UNICODE) { in sess_auth_ntlm()
816 unicode_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_ntlm()
818 ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_ntlm()
841 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_ntlm()
842 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_ntlm()
856 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_ntlm()
859 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_ntlm()
868 kfree(ses->auth_key.response); in sess_auth_ntlm()
869 ses->auth_key.response = NULL; in sess_auth_ntlm()
879 struct cifs_ses *ses = sess_data->ses; in sess_auth_ntlmv2() local
891 capabilities = cifs_ssetup_hdr(ses, pSMB); in sess_auth_ntlmv2()
898 if (ses->user_name != NULL) { in sess_auth_ntlmv2()
900 rc = setup_ntlmv2_rsp(ses, sess_data->nls_cp); in sess_auth_ntlmv2()
906 memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE, in sess_auth_ntlmv2()
907 ses->auth_key.len - CIFS_SESS_KEY_SIZE); in sess_auth_ntlmv2()
908 bcc_ptr += ses->auth_key.len - CIFS_SESS_KEY_SIZE; in sess_auth_ntlmv2()
914 cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); in sess_auth_ntlmv2()
919 if (ses->capabilities & CAP_UNICODE) { in sess_auth_ntlmv2()
924 unicode_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_ntlmv2()
926 ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_ntlmv2()
949 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_ntlmv2()
950 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_ntlmv2()
964 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_ntlmv2()
967 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_ntlmv2()
976 kfree(ses->auth_key.response); in sess_auth_ntlmv2()
977 ses->auth_key.response = NULL; in sess_auth_ntlmv2()
988 struct cifs_ses *ses = sess_data->ses; in sess_auth_kerberos() local
1003 capabilities = cifs_ssetup_hdr(ses, pSMB); in sess_auth_kerberos()
1005 spnego_key = cifs_get_spnego_key(ses); in sess_auth_kerberos()
1025 ses->auth_key.response = kmemdup(msg->data, msg->sesskey_len, in sess_auth_kerberos()
1027 if (!ses->auth_key.response) { in sess_auth_kerberos()
1033 ses->auth_key.len = msg->sesskey_len; in sess_auth_kerberos()
1042 if (ses->capabilities & CAP_UNICODE) { in sess_auth_kerberos()
1050 unicode_domain_string(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_kerberos()
1053 ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_kerberos()
1075 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_kerberos()
1076 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_kerberos()
1100 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_kerberos()
1103 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_kerberos()
1115 kfree(ses->auth_key.response); in sess_auth_kerberos()
1116 ses->auth_key.response = NULL; in sess_auth_kerberos()
1130 struct cifs_ses *ses = sess_data->ses; in _sess_auth_rawntlmssp_assemble_req() local
1137 capabilities = cifs_ssetup_hdr(ses, pSMB); in _sess_auth_rawntlmssp_assemble_req()
1170 struct cifs_ses *ses = sess_data->ses; in sess_auth_rawntlmssp_negotiate() local
1181 ses->ntlmssp = kmalloc(sizeof(struct ntlmssp_auth), GFP_KERNEL); in sess_auth_rawntlmssp_negotiate()
1182 if (!ses->ntlmssp) { in sess_auth_rawntlmssp_negotiate()
1186 ses->ntlmssp->sesskey_per_smbsess = false; in sess_auth_rawntlmssp_negotiate()
1196 build_ntlmssp_negotiate_blob(pSMB->req.SecurityBlob, ses); in sess_auth_rawntlmssp_negotiate()
1227 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_rawntlmssp_negotiate()
1228 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_rawntlmssp_negotiate()
1241 rc = decode_ntlmssp_challenge(bcc_ptr, blob_len, ses); in sess_auth_rawntlmssp_negotiate()
1251 kfree(ses->auth_key.response); in sess_auth_rawntlmssp_negotiate()
1252 ses->auth_key.response = NULL; in sess_auth_rawntlmssp_negotiate()
1253 kfree(ses->ntlmssp); in sess_auth_rawntlmssp_negotiate()
1254 ses->ntlmssp = NULL; in sess_auth_rawntlmssp_negotiate()
1266 struct cifs_ses *ses = sess_data->ses; in sess_auth_rawntlmssp_authenticate() local
1295 &blob_len, ses, sess_data->nls_cp); in sess_auth_rawntlmssp_authenticate()
1306 smb_buf->Uid = ses->Suid; in sess_auth_rawntlmssp_authenticate()
1327 if (ses->Suid != smb_buf->Uid) { in sess_auth_rawntlmssp_authenticate()
1328 ses->Suid = smb_buf->Uid; in sess_auth_rawntlmssp_authenticate()
1329 cifs_dbg(FYI, "UID changed! new UID = %llu\n", ses->Suid); in sess_auth_rawntlmssp_authenticate()
1354 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_rawntlmssp_authenticate()
1357 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_rawntlmssp_authenticate()
1370 kfree(ses->auth_key.response); in sess_auth_rawntlmssp_authenticate()
1371 ses->auth_key.response = NULL; in sess_auth_rawntlmssp_authenticate()
1372 kfree(ses->ntlmssp); in sess_auth_rawntlmssp_authenticate()
1373 ses->ntlmssp = NULL; in sess_auth_rawntlmssp_authenticate()
1379 static int select_sec(struct cifs_ses *ses, struct sess_data *sess_data) in select_sec() argument
1383 type = select_sectype(ses->server, ses->sectype); in select_sec()
1430 int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses, in CIFS_SessSetup() argument
1436 if (ses == NULL) { in CIFS_SessSetup()
1445 rc = select_sec(ses, sess_data); in CIFS_SessSetup()
1450 sess_data->ses = ses; in CIFS_SessSetup()