Lines Matching refs:ses

61 bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface)  in is_ses_using_iface()  argument
65 for (i = 0; i < ses->chan_count; i++) { in is_ses_using_iface()
66 if (is_server_using_iface(ses->chans[i].server, iface)) in is_ses_using_iface()
73 int cifs_try_adding_channels(struct cifs_ses *ses) in cifs_try_adding_channels() argument
75 int old_chan_count = ses->chan_count; in cifs_try_adding_channels()
76 int left = ses->chan_max - ses->chan_count; in cifs_try_adding_channels()
86 ses->chan_max); in cifs_try_adding_channels()
90 if (ses->server->dialect < SMB30_PROT_ID) { in cifs_try_adding_channels()
100 spin_lock(&ses->iface_lock); in cifs_try_adding_channels()
101 iface_count = ses->iface_count; in cifs_try_adding_channels()
103 spin_unlock(&ses->iface_lock); in cifs_try_adding_channels()
107 ifaces = kmemdup(ses->iface_list, iface_count*sizeof(*ifaces), in cifs_try_adding_channels()
110 spin_unlock(&ses->iface_lock); in cifs_try_adding_channels()
113 spin_unlock(&ses->iface_lock); in cifs_try_adding_channels()
124 if (tries > 3*ses->chan_max) { in cifs_try_adding_channels()
131 if (is_ses_using_iface(ses, iface) && !iface->rss_capable) { in cifs_try_adding_channels()
136 rc = cifs_ses_add_channel(ses, iface); in cifs_try_adding_channels()
150 return ses->chan_count - old_chan_count; in cifs_try_adding_channels()
158 cifs_ses_find_chan(struct cifs_ses *ses, struct TCP_Server_Info *server) in cifs_ses_find_chan() argument
162 for (i = 0; i < ses->chan_count; i++) { in cifs_ses_find_chan()
163 if (ses->chans[i].server == server) in cifs_ses_find_chan()
164 return &ses->chans[i]; in cifs_ses_find_chan()
170 cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface) in cifs_ses_add_channel() argument
183 ses, iface->speed, iface->rdma_capable ? "yes" : "no", in cifs_ses_add_channel()
187 ses, iface->speed, iface->rdma_capable ? "yes" : "no", in cifs_ses_add_channel()
206 vol.domainauto = ses->domainAuto; in cifs_ses_add_channel()
207 vol.domainname = ses->domainName; in cifs_ses_add_channel()
208 vol.username = ses->user_name; in cifs_ses_add_channel()
209 vol.password = ses->password; in cifs_ses_add_channel()
210 vol.sectype = ses->sectype; in cifs_ses_add_channel()
211 vol.sign = ses->sign; in cifs_ses_add_channel()
215 sprintf(unc, unc_fmt, ses->serverName); in cifs_ses_add_channel()
220 vol.vals = ses->server->vals; in cifs_ses_add_channel()
221 vol.ops = ses->server->ops; in cifs_ses_add_channel()
223 vol.noblocksnd = ses->server->noblocksnd; in cifs_ses_add_channel()
224 vol.noautotune = ses->server->noautotune; in cifs_ses_add_channel()
225 vol.sockopt_tcp_nodelay = ses->server->tcp_nodelay; in cifs_ses_add_channel()
226 vol.echo_interval = ses->server->echo_interval / HZ; in cifs_ses_add_channel()
244 memcpy(&vol.client_guid, ses->server->client_guid, in cifs_ses_add_channel()
248 mutex_lock(&ses->session_mutex); in cifs_ses_add_channel()
250 chan = ses->binding_chan = &ses->chans[ses->chan_count]; in cifs_ses_add_channel()
272 ses->binding = true; in cifs_ses_add_channel()
273 rc = cifs_negotiate_protocol(xid, ses); in cifs_ses_add_channel()
277 rc = cifs_setup_session(xid, ses, vol.local_nls); in cifs_ses_add_channel()
291 ses->chan_count++; in cifs_ses_add_channel()
292 atomic_set(&ses->chan_seq, 0); in cifs_ses_add_channel()
294 ses->binding = false; in cifs_ses_add_channel()
295 ses->binding_chan = NULL; in cifs_ses_add_channel()
296 mutex_unlock(&ses->session_mutex); in cifs_ses_add_channel()
305 static __u32 cifs_ssetup_hdr(struct cifs_ses *ses, SESSION_SETUP_ANDX *pSMB) in cifs_ssetup_hdr() argument
318 pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); in cifs_ssetup_hdr()
329 if (ses->server->sign) in cifs_ssetup_hdr()
332 if (ses->capabilities & CAP_UNICODE) { in cifs_ssetup_hdr()
336 if (ses->capabilities & CAP_STATUS32) { in cifs_ssetup_hdr()
340 if (ses->capabilities & CAP_DFS) { in cifs_ssetup_hdr()
344 if (ses->capabilities & CAP_UNIX) in cifs_ssetup_hdr()
373 static void unicode_domain_string(char **pbcc_area, struct cifs_ses *ses, in unicode_domain_string() argument
380 if (ses->domainName == NULL) { in unicode_domain_string()
387 bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->domainName, in unicode_domain_string()
396 static void unicode_ssetup_strings(char **pbcc_area, struct cifs_ses *ses, in unicode_ssetup_strings() argument
411 if (ses->user_name == NULL) { in unicode_ssetup_strings()
416 bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->user_name, in unicode_ssetup_strings()
422 unicode_domain_string(&bcc_ptr, ses, nls_cp); in unicode_ssetup_strings()
428 static void ascii_ssetup_strings(char **pbcc_area, struct cifs_ses *ses, in ascii_ssetup_strings() argument
437 if (ses->user_name != NULL) { in ascii_ssetup_strings()
438 len = strscpy(bcc_ptr, ses->user_name, CIFS_MAX_USERNAME_LEN); in ascii_ssetup_strings()
448 if (ses->domainName != NULL) { in ascii_ssetup_strings()
449 len = strscpy(bcc_ptr, ses->domainName, CIFS_MAX_DOMAINNAME_LEN); in ascii_ssetup_strings()
472 decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifs_ses *ses, in decode_unicode_ssetup() argument
480 kfree(ses->serverOS); in decode_unicode_ssetup()
481 ses->serverOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp); in decode_unicode_ssetup()
482 cifs_dbg(FYI, "serverOS=%s\n", ses->serverOS); in decode_unicode_ssetup()
489 kfree(ses->serverNOS); in decode_unicode_ssetup()
490 ses->serverNOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp); in decode_unicode_ssetup()
491 cifs_dbg(FYI, "serverNOS=%s\n", ses->serverNOS); in decode_unicode_ssetup()
498 kfree(ses->serverDomain); in decode_unicode_ssetup()
499 ses->serverDomain = cifs_strndup_from_utf16(data, bleft, true, nls_cp); in decode_unicode_ssetup()
500 cifs_dbg(FYI, "serverDomain=%s\n", ses->serverDomain); in decode_unicode_ssetup()
506 struct cifs_ses *ses, in decode_ascii_ssetup() argument
518 kfree(ses->serverOS); in decode_ascii_ssetup()
520 ses->serverOS = kmalloc(len + 1, GFP_KERNEL); in decode_ascii_ssetup()
521 if (ses->serverOS) { in decode_ascii_ssetup()
522 memcpy(ses->serverOS, bcc_ptr, len); in decode_ascii_ssetup()
523 ses->serverOS[len] = 0; in decode_ascii_ssetup()
524 if (strncmp(ses->serverOS, "OS/2", 4) == 0) in decode_ascii_ssetup()
535 kfree(ses->serverNOS); in decode_ascii_ssetup()
537 ses->serverNOS = kmalloc(len + 1, GFP_KERNEL); in decode_ascii_ssetup()
538 if (ses->serverNOS) { in decode_ascii_ssetup()
539 memcpy(ses->serverNOS, bcc_ptr, len); in decode_ascii_ssetup()
540 ses->serverNOS[len] = 0; in decode_ascii_ssetup()
559 struct cifs_ses *ses) in decode_ntlmssp_challenge() argument
582 memcpy(ses->ntlmssp->cryptkey, pblob->Challenge, CIFS_CRYPTO_KEY_SIZE); in decode_ntlmssp_challenge()
587 ses->ntlmssp->server_flags = le32_to_cpu(pblob->NegotiateFlags); in decode_ntlmssp_challenge()
596 ses->auth_key.response = kmemdup(bcc_ptr + tioffset, tilen, in decode_ntlmssp_challenge()
598 if (!ses->auth_key.response) { in decode_ntlmssp_challenge()
602 ses->auth_key.len = tilen; in decode_ntlmssp_challenge()
613 struct cifs_ses *ses) in build_ntlmssp_negotiate_blob() argument
615 struct TCP_Server_Info *server = cifs_ses_server(ses); in build_ntlmssp_negotiate_blob()
630 if (!server->session_estab || ses->ntlmssp->sesskey_per_smbsess) in build_ntlmssp_negotiate_blob()
645 static int size_of_ntlmssp_blob(struct cifs_ses *ses) in size_of_ntlmssp_blob() argument
647 int sz = sizeof(AUTHENTICATE_MESSAGE) + ses->auth_key.len in size_of_ntlmssp_blob()
650 if (ses->domainName) in size_of_ntlmssp_blob()
651 sz += 2 * strnlen(ses->domainName, CIFS_MAX_DOMAINNAME_LEN); in size_of_ntlmssp_blob()
655 if (ses->user_name) in size_of_ntlmssp_blob()
656 sz += 2 * strnlen(ses->user_name, CIFS_MAX_USERNAME_LEN); in size_of_ntlmssp_blob()
665 struct cifs_ses *ses, in build_ntlmssp_auth_blob() argument
673 rc = setup_ntlmv2_rsp(ses, nls_cp); in build_ntlmssp_auth_blob()
679 *pbuffer = kmalloc(size_of_ntlmssp_blob(ses), GFP_KERNEL); in build_ntlmssp_auth_blob()
696 if (ses->server->sign) in build_ntlmssp_auth_blob()
698 if (!ses->server->session_estab || ses->ntlmssp->sesskey_per_smbsess) in build_ntlmssp_auth_blob()
711 if (ses->user_name != NULL) { in build_ntlmssp_auth_blob()
712 memcpy(tmp, ses->auth_key.response + CIFS_SESS_KEY_SIZE, in build_ntlmssp_auth_blob()
713 ses->auth_key.len - CIFS_SESS_KEY_SIZE); in build_ntlmssp_auth_blob()
714 tmp += ses->auth_key.len - CIFS_SESS_KEY_SIZE; in build_ntlmssp_auth_blob()
717 cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); in build_ntlmssp_auth_blob()
719 cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); in build_ntlmssp_auth_blob()
728 if (ses->domainName == NULL) { in build_ntlmssp_auth_blob()
735 len = cifs_strtoUTF16((__le16 *)tmp, ses->domainName, in build_ntlmssp_auth_blob()
744 if (ses->user_name == NULL) { in build_ntlmssp_auth_blob()
751 len = cifs_strtoUTF16((__le16 *)tmp, ses->user_name, in build_ntlmssp_auth_blob()
765 if (((ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_KEY_XCH) || in build_ntlmssp_auth_blob()
766 (ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_EXTENDED_SEC)) in build_ntlmssp_auth_blob()
767 && !calc_seckey(ses)) { in build_ntlmssp_auth_blob()
768 memcpy(tmp, ses->ntlmssp->ciphertext, CIFS_CPHTXT_SIZE); in build_ntlmssp_auth_blob()
837 struct cifs_ses *ses; member
857 struct cifs_ses *ses = sess_data->ses; in sess_alloc_buffer() local
860 rc = small_smb_init_no_tc(SMB_COM_SESSION_SETUP_ANDX, wct, ses, in sess_alloc_buffer()
903 struct cifs_ses *ses = sess_data->ses; in sess_establish_session() local
905 mutex_lock(&ses->server->srv_mutex); in sess_establish_session()
906 if (!ses->server->session_estab) { in sess_establish_session()
907 if (ses->server->sign) { in sess_establish_session()
908 ses->server->session_key.response = in sess_establish_session()
909 kmemdup(ses->auth_key.response, in sess_establish_session()
910 ses->auth_key.len, GFP_KERNEL); in sess_establish_session()
911 if (!ses->server->session_key.response) { in sess_establish_session()
912 mutex_unlock(&ses->server->srv_mutex); in sess_establish_session()
915 ses->server->session_key.len = in sess_establish_session()
916 ses->auth_key.len; in sess_establish_session()
918 ses->server->sequence_number = 0x2; in sess_establish_session()
919 ses->server->session_estab = true; in sess_establish_session()
921 mutex_unlock(&ses->server->srv_mutex); in sess_establish_session()
925 ses->status = CifsGood; in sess_establish_session()
926 ses->need_reconnect = false; in sess_establish_session()
944 rc = SendReceive2(sess_data->xid, sess_data->ses, in sess_sendreceive()
969 struct cifs_ses *ses = sess_data->ses; in sess_auth_lanman() local
981 (void)cifs_ssetup_hdr(ses, pSMB); in sess_auth_lanman()
985 if (ses->user_name != NULL) { in sess_auth_lanman()
994 rc = calc_lanman_hash(ses->password, ses->server->cryptkey, in sess_auth_lanman()
995 ses->server->sec_mode & SECMODE_PW_ENCRYPT ? in sess_auth_lanman()
1015 ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_lanman()
1037 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_lanman()
1038 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_lanman()
1052 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_lanman()
1055 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_lanman()
1075 struct cifs_ses *ses = sess_data->ses; in sess_auth_ntlm() local
1087 capabilities = cifs_ssetup_hdr(ses, pSMB); in sess_auth_ntlm()
1090 if (ses->user_name != NULL) { in sess_auth_ntlm()
1097 rc = setup_ntlm_response(ses, sess_data->nls_cp); in sess_auth_ntlm()
1105 memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE, in sess_auth_ntlm()
1108 memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE, in sess_auth_ntlm()
1116 if (ses->capabilities & CAP_UNICODE) { in sess_auth_ntlm()
1122 unicode_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_ntlm()
1124 ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_ntlm()
1147 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_ntlm()
1148 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_ntlm()
1162 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_ntlm()
1165 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_ntlm()
1174 kfree(ses->auth_key.response); in sess_auth_ntlm()
1175 ses->auth_key.response = NULL; in sess_auth_ntlm()
1185 struct cifs_ses *ses = sess_data->ses; in sess_auth_ntlmv2() local
1197 capabilities = cifs_ssetup_hdr(ses, pSMB); in sess_auth_ntlmv2()
1204 if (ses->user_name != NULL) { in sess_auth_ntlmv2()
1206 rc = setup_ntlmv2_rsp(ses, sess_data->nls_cp); in sess_auth_ntlmv2()
1212 memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE, in sess_auth_ntlmv2()
1213 ses->auth_key.len - CIFS_SESS_KEY_SIZE); in sess_auth_ntlmv2()
1214 bcc_ptr += ses->auth_key.len - CIFS_SESS_KEY_SIZE; in sess_auth_ntlmv2()
1220 cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); in sess_auth_ntlmv2()
1225 if (ses->capabilities & CAP_UNICODE) { in sess_auth_ntlmv2()
1230 unicode_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_ntlmv2()
1232 ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_ntlmv2()
1255 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_ntlmv2()
1256 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_ntlmv2()
1270 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_ntlmv2()
1273 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_ntlmv2()
1282 kfree(ses->auth_key.response); in sess_auth_ntlmv2()
1283 ses->auth_key.response = NULL; in sess_auth_ntlmv2()
1294 struct cifs_ses *ses = sess_data->ses; in sess_auth_kerberos() local
1309 capabilities = cifs_ssetup_hdr(ses, pSMB); in sess_auth_kerberos()
1311 spnego_key = cifs_get_spnego_key(ses); in sess_auth_kerberos()
1330 ses->auth_key.response = kmemdup(msg->data, msg->sesskey_len, in sess_auth_kerberos()
1332 if (!ses->auth_key.response) { in sess_auth_kerberos()
1338 ses->auth_key.len = msg->sesskey_len; in sess_auth_kerberos()
1347 if (ses->capabilities & CAP_UNICODE) { in sess_auth_kerberos()
1355 unicode_domain_string(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_kerberos()
1358 ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_kerberos()
1380 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_kerberos()
1381 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_kerberos()
1405 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_kerberos()
1408 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_kerberos()
1420 kfree(ses->auth_key.response); in sess_auth_kerberos()
1421 ses->auth_key.response = NULL; in sess_auth_kerberos()
1434 struct cifs_ses *ses = sess_data->ses; in _sess_auth_rawntlmssp_assemble_req() local
1440 capabilities = cifs_ssetup_hdr(ses, pSMB); in _sess_auth_rawntlmssp_assemble_req()
1473 struct cifs_ses *ses = sess_data->ses; in sess_auth_rawntlmssp_negotiate() local
1484 ses->ntlmssp = kmalloc(sizeof(struct ntlmssp_auth), GFP_KERNEL); in sess_auth_rawntlmssp_negotiate()
1485 if (!ses->ntlmssp) { in sess_auth_rawntlmssp_negotiate()
1489 ses->ntlmssp->sesskey_per_smbsess = false; in sess_auth_rawntlmssp_negotiate()
1499 build_ntlmssp_negotiate_blob(pSMB->req.SecurityBlob, ses); in sess_auth_rawntlmssp_negotiate()
1530 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_rawntlmssp_negotiate()
1531 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_rawntlmssp_negotiate()
1544 rc = decode_ntlmssp_challenge(bcc_ptr, blob_len, ses); in sess_auth_rawntlmssp_negotiate()
1554 kfree(ses->auth_key.response); in sess_auth_rawntlmssp_negotiate()
1555 ses->auth_key.response = NULL; in sess_auth_rawntlmssp_negotiate()
1556 kfree(ses->ntlmssp); in sess_auth_rawntlmssp_negotiate()
1557 ses->ntlmssp = NULL; in sess_auth_rawntlmssp_negotiate()
1569 struct cifs_ses *ses = sess_data->ses; in sess_auth_rawntlmssp_authenticate() local
1586 &blob_len, ses, sess_data->nls_cp); in sess_auth_rawntlmssp_authenticate()
1597 smb_buf->Uid = ses->Suid; in sess_auth_rawntlmssp_authenticate()
1618 if (ses->Suid != smb_buf->Uid) { in sess_auth_rawntlmssp_authenticate()
1619 ses->Suid = smb_buf->Uid; in sess_auth_rawntlmssp_authenticate()
1620 cifs_dbg(FYI, "UID changed! new UID = %llu\n", ses->Suid); in sess_auth_rawntlmssp_authenticate()
1645 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_rawntlmssp_authenticate()
1648 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_rawntlmssp_authenticate()
1661 kfree(ses->auth_key.response); in sess_auth_rawntlmssp_authenticate()
1662 ses->auth_key.response = NULL; in sess_auth_rawntlmssp_authenticate()
1663 kfree(ses->ntlmssp); in sess_auth_rawntlmssp_authenticate()
1664 ses->ntlmssp = NULL; in sess_auth_rawntlmssp_authenticate()
1670 static int select_sec(struct cifs_ses *ses, struct sess_data *sess_data) in select_sec() argument
1674 type = cifs_select_sectype(ses->server, ses->sectype); in select_sec()
1719 int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses, in CIFS_SessSetup() argument
1725 if (ses == NULL) { in CIFS_SessSetup()
1734 rc = select_sec(ses, sess_data); in CIFS_SessSetup()
1739 sess_data->ses = ses; in CIFS_SessSetup()