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()
95 if (!(ses->server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) { in cifs_try_adding_channels()
96 cifs_dbg(VFS, "server %s does not support multichannel\n", ses->server->hostname); in cifs_try_adding_channels()
97 ses->chan_max = 1; in cifs_try_adding_channels()
106 spin_lock(&ses->iface_lock); in cifs_try_adding_channels()
107 iface_count = ses->iface_count; in cifs_try_adding_channels()
109 spin_unlock(&ses->iface_lock); in cifs_try_adding_channels()
113 ifaces = kmemdup(ses->iface_list, iface_count*sizeof(*ifaces), in cifs_try_adding_channels()
116 spin_unlock(&ses->iface_lock); in cifs_try_adding_channels()
119 spin_unlock(&ses->iface_lock); in cifs_try_adding_channels()
130 if (tries > 3*ses->chan_max) { in cifs_try_adding_channels()
137 if (is_ses_using_iface(ses, iface) && !iface->rss_capable) { in cifs_try_adding_channels()
142 rc = cifs_ses_add_channel(ses, iface); in cifs_try_adding_channels()
156 return ses->chan_count - old_chan_count; in cifs_try_adding_channels()
164 cifs_ses_find_chan(struct cifs_ses *ses, struct TCP_Server_Info *server) in cifs_ses_find_chan() argument
168 for (i = 0; i < ses->chan_count; i++) { in cifs_ses_find_chan()
169 if (ses->chans[i].server == server) in cifs_ses_find_chan()
170 return &ses->chans[i]; in cifs_ses_find_chan()
176 cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface) in cifs_ses_add_channel() argument
189 ses, iface->speed, iface->rdma_capable ? "yes" : "no", in cifs_ses_add_channel()
193 ses, iface->speed, iface->rdma_capable ? "yes" : "no", in cifs_ses_add_channel()
212 vol.domainauto = ses->domainAuto; in cifs_ses_add_channel()
213 vol.domainname = ses->domainName; in cifs_ses_add_channel()
214 vol.username = ses->user_name; in cifs_ses_add_channel()
215 vol.password = ses->password; in cifs_ses_add_channel()
216 vol.sectype = ses->sectype; in cifs_ses_add_channel()
217 vol.sign = ses->sign; in cifs_ses_add_channel()
221 sprintf(unc, unc_fmt, ses->serverName); in cifs_ses_add_channel()
226 vol.vals = ses->server->vals; in cifs_ses_add_channel()
227 vol.ops = ses->server->ops; in cifs_ses_add_channel()
229 vol.noblocksnd = ses->server->noblocksnd; in cifs_ses_add_channel()
230 vol.noautotune = ses->server->noautotune; in cifs_ses_add_channel()
231 vol.sockopt_tcp_nodelay = ses->server->tcp_nodelay; in cifs_ses_add_channel()
232 vol.echo_interval = ses->server->echo_interval / HZ; in cifs_ses_add_channel()
233 vol.max_credits = ses->server->max_credits; in cifs_ses_add_channel()
251 memcpy(&vol.client_guid, ses->server->client_guid, in cifs_ses_add_channel()
255 mutex_lock(&ses->session_mutex); in cifs_ses_add_channel()
257 chan = ses->binding_chan = &ses->chans[ses->chan_count]; in cifs_ses_add_channel()
279 ses->binding = true; in cifs_ses_add_channel()
280 rc = cifs_negotiate_protocol(xid, ses); in cifs_ses_add_channel()
284 rc = cifs_setup_session(xid, ses, vol.local_nls); in cifs_ses_add_channel()
298 ses->chan_count++; in cifs_ses_add_channel()
299 atomic_set(&ses->chan_seq, 0); in cifs_ses_add_channel()
301 ses->binding = false; in cifs_ses_add_channel()
302 ses->binding_chan = NULL; in cifs_ses_add_channel()
303 mutex_unlock(&ses->session_mutex); in cifs_ses_add_channel()
313 static __u32 cifs_ssetup_hdr(struct cifs_ses *ses, SESSION_SETUP_ANDX *pSMB) in cifs_ssetup_hdr() argument
326 pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); in cifs_ssetup_hdr()
337 if (ses->server->sign) in cifs_ssetup_hdr()
340 if (ses->capabilities & CAP_UNICODE) { in cifs_ssetup_hdr()
344 if (ses->capabilities & CAP_STATUS32) { in cifs_ssetup_hdr()
348 if (ses->capabilities & CAP_DFS) { in cifs_ssetup_hdr()
352 if (ses->capabilities & CAP_UNIX) in cifs_ssetup_hdr()
381 static void unicode_domain_string(char **pbcc_area, struct cifs_ses *ses, in unicode_domain_string() argument
388 if (ses->domainName == NULL) { in unicode_domain_string()
395 bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->domainName, in unicode_domain_string()
404 static void unicode_ssetup_strings(char **pbcc_area, struct cifs_ses *ses, in unicode_ssetup_strings() argument
419 if (ses->user_name == NULL) { in unicode_ssetup_strings()
424 bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->user_name, in unicode_ssetup_strings()
430 unicode_domain_string(&bcc_ptr, ses, nls_cp); in unicode_ssetup_strings()
436 static void ascii_ssetup_strings(char **pbcc_area, struct cifs_ses *ses, in ascii_ssetup_strings() argument
445 if (ses->user_name != NULL) { in ascii_ssetup_strings()
446 len = strscpy(bcc_ptr, ses->user_name, CIFS_MAX_USERNAME_LEN); in ascii_ssetup_strings()
456 if (ses->domainName != NULL) { in ascii_ssetup_strings()
457 len = strscpy(bcc_ptr, ses->domainName, CIFS_MAX_DOMAINNAME_LEN); in ascii_ssetup_strings()
480 decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifs_ses *ses, in decode_unicode_ssetup() argument
488 kfree(ses->serverOS); in decode_unicode_ssetup()
489 ses->serverOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp); in decode_unicode_ssetup()
490 cifs_dbg(FYI, "serverOS=%s\n", ses->serverOS); in decode_unicode_ssetup()
497 kfree(ses->serverNOS); in decode_unicode_ssetup()
498 ses->serverNOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp); in decode_unicode_ssetup()
499 cifs_dbg(FYI, "serverNOS=%s\n", ses->serverNOS); in decode_unicode_ssetup()
506 kfree(ses->serverDomain); in decode_unicode_ssetup()
507 ses->serverDomain = cifs_strndup_from_utf16(data, bleft, true, nls_cp); in decode_unicode_ssetup()
508 cifs_dbg(FYI, "serverDomain=%s\n", ses->serverDomain); in decode_unicode_ssetup()
514 struct cifs_ses *ses, in decode_ascii_ssetup() argument
526 kfree(ses->serverOS); in decode_ascii_ssetup()
528 ses->serverOS = kmalloc(len + 1, GFP_KERNEL); in decode_ascii_ssetup()
529 if (ses->serverOS) { in decode_ascii_ssetup()
530 memcpy(ses->serverOS, bcc_ptr, len); in decode_ascii_ssetup()
531 ses->serverOS[len] = 0; in decode_ascii_ssetup()
532 if (strncmp(ses->serverOS, "OS/2", 4) == 0) in decode_ascii_ssetup()
543 kfree(ses->serverNOS); in decode_ascii_ssetup()
545 ses->serverNOS = kmalloc(len + 1, GFP_KERNEL); in decode_ascii_ssetup()
546 if (ses->serverNOS) { in decode_ascii_ssetup()
547 memcpy(ses->serverNOS, bcc_ptr, len); in decode_ascii_ssetup()
548 ses->serverNOS[len] = 0; in decode_ascii_ssetup()
567 struct cifs_ses *ses) in decode_ntlmssp_challenge() argument
590 memcpy(ses->ntlmssp->cryptkey, pblob->Challenge, CIFS_CRYPTO_KEY_SIZE); in decode_ntlmssp_challenge()
595 ses->ntlmssp->server_flags = le32_to_cpu(pblob->NegotiateFlags); in decode_ntlmssp_challenge()
604 ses->auth_key.response = kmemdup(bcc_ptr + tioffset, tilen, in decode_ntlmssp_challenge()
606 if (!ses->auth_key.response) { in decode_ntlmssp_challenge()
610 ses->auth_key.len = tilen; in decode_ntlmssp_challenge()
621 struct cifs_ses *ses) in build_ntlmssp_negotiate_blob() argument
623 struct TCP_Server_Info *server = cifs_ses_server(ses); in build_ntlmssp_negotiate_blob()
638 if (!server->session_estab || ses->ntlmssp->sesskey_per_smbsess) in build_ntlmssp_negotiate_blob()
653 static int size_of_ntlmssp_blob(struct cifs_ses *ses) in size_of_ntlmssp_blob() argument
655 int sz = sizeof(AUTHENTICATE_MESSAGE) + ses->auth_key.len in size_of_ntlmssp_blob()
658 if (ses->domainName) in size_of_ntlmssp_blob()
659 sz += 2 * strnlen(ses->domainName, CIFS_MAX_DOMAINNAME_LEN); in size_of_ntlmssp_blob()
663 if (ses->user_name) in size_of_ntlmssp_blob()
664 sz += 2 * strnlen(ses->user_name, CIFS_MAX_USERNAME_LEN); in size_of_ntlmssp_blob()
673 struct cifs_ses *ses, in build_ntlmssp_auth_blob() argument
681 rc = setup_ntlmv2_rsp(ses, nls_cp); in build_ntlmssp_auth_blob()
687 *pbuffer = kmalloc(size_of_ntlmssp_blob(ses), GFP_KERNEL); in build_ntlmssp_auth_blob()
704 if (ses->server->sign) in build_ntlmssp_auth_blob()
706 if (!ses->server->session_estab || ses->ntlmssp->sesskey_per_smbsess) in build_ntlmssp_auth_blob()
719 if (ses->user_name != NULL) { in build_ntlmssp_auth_blob()
720 memcpy(tmp, ses->auth_key.response + CIFS_SESS_KEY_SIZE, in build_ntlmssp_auth_blob()
721 ses->auth_key.len - CIFS_SESS_KEY_SIZE); in build_ntlmssp_auth_blob()
722 tmp += ses->auth_key.len - CIFS_SESS_KEY_SIZE; in build_ntlmssp_auth_blob()
725 cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); in build_ntlmssp_auth_blob()
727 cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); in build_ntlmssp_auth_blob()
736 if (ses->domainName == NULL) { in build_ntlmssp_auth_blob()
743 len = cifs_strtoUTF16((__le16 *)tmp, ses->domainName, in build_ntlmssp_auth_blob()
752 if (ses->user_name == NULL) { in build_ntlmssp_auth_blob()
759 len = cifs_strtoUTF16((__le16 *)tmp, ses->user_name, in build_ntlmssp_auth_blob()
773 if (((ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_KEY_XCH) || in build_ntlmssp_auth_blob()
774 (ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_EXTENDED_SEC)) in build_ntlmssp_auth_blob()
775 && !calc_seckey(ses)) { in build_ntlmssp_auth_blob()
776 memcpy(tmp, ses->ntlmssp->ciphertext, CIFS_CPHTXT_SIZE); in build_ntlmssp_auth_blob()
845 struct cifs_ses *ses; member
865 struct cifs_ses *ses = sess_data->ses; in sess_alloc_buffer() local
868 rc = small_smb_init_no_tc(SMB_COM_SESSION_SETUP_ANDX, wct, ses, in sess_alloc_buffer()
911 struct cifs_ses *ses = sess_data->ses; in sess_establish_session() local
913 mutex_lock(&ses->server->srv_mutex); in sess_establish_session()
914 if (!ses->server->session_estab) { in sess_establish_session()
915 if (ses->server->sign) { in sess_establish_session()
916 ses->server->session_key.response = in sess_establish_session()
917 kmemdup(ses->auth_key.response, in sess_establish_session()
918 ses->auth_key.len, GFP_KERNEL); in sess_establish_session()
919 if (!ses->server->session_key.response) { in sess_establish_session()
920 mutex_unlock(&ses->server->srv_mutex); in sess_establish_session()
923 ses->server->session_key.len = in sess_establish_session()
924 ses->auth_key.len; in sess_establish_session()
926 ses->server->sequence_number = 0x2; in sess_establish_session()
927 ses->server->session_estab = true; in sess_establish_session()
929 mutex_unlock(&ses->server->srv_mutex); in sess_establish_session()
933 ses->status = CifsGood; in sess_establish_session()
934 ses->need_reconnect = false; in sess_establish_session()
952 rc = SendReceive2(sess_data->xid, sess_data->ses, in sess_sendreceive()
977 struct cifs_ses *ses = sess_data->ses; in sess_auth_lanman() local
989 (void)cifs_ssetup_hdr(ses, pSMB); in sess_auth_lanman()
993 if (ses->user_name != NULL) { in sess_auth_lanman()
1002 rc = calc_lanman_hash(ses->password, ses->server->cryptkey, in sess_auth_lanman()
1003 ses->server->sec_mode & SECMODE_PW_ENCRYPT ? in sess_auth_lanman()
1023 ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_lanman()
1045 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_lanman()
1046 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_lanman()
1060 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_lanman()
1063 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_lanman()
1083 struct cifs_ses *ses = sess_data->ses; in sess_auth_ntlm() local
1095 capabilities = cifs_ssetup_hdr(ses, pSMB); in sess_auth_ntlm()
1098 if (ses->user_name != NULL) { in sess_auth_ntlm()
1105 rc = setup_ntlm_response(ses, sess_data->nls_cp); in sess_auth_ntlm()
1113 memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE, in sess_auth_ntlm()
1116 memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE, in sess_auth_ntlm()
1124 if (ses->capabilities & CAP_UNICODE) { in sess_auth_ntlm()
1130 unicode_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_ntlm()
1132 ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_ntlm()
1155 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_ntlm()
1156 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_ntlm()
1170 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_ntlm()
1173 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_ntlm()
1182 kfree(ses->auth_key.response); in sess_auth_ntlm()
1183 ses->auth_key.response = NULL; in sess_auth_ntlm()
1193 struct cifs_ses *ses = sess_data->ses; in sess_auth_ntlmv2() local
1205 capabilities = cifs_ssetup_hdr(ses, pSMB); in sess_auth_ntlmv2()
1212 if (ses->user_name != NULL) { in sess_auth_ntlmv2()
1214 rc = setup_ntlmv2_rsp(ses, sess_data->nls_cp); in sess_auth_ntlmv2()
1220 memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE, in sess_auth_ntlmv2()
1221 ses->auth_key.len - CIFS_SESS_KEY_SIZE); in sess_auth_ntlmv2()
1222 bcc_ptr += ses->auth_key.len - CIFS_SESS_KEY_SIZE; in sess_auth_ntlmv2()
1228 cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); in sess_auth_ntlmv2()
1233 if (ses->capabilities & CAP_UNICODE) { in sess_auth_ntlmv2()
1238 unicode_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_ntlmv2()
1240 ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_ntlmv2()
1263 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_ntlmv2()
1264 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_ntlmv2()
1278 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_ntlmv2()
1281 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_ntlmv2()
1290 kfree(ses->auth_key.response); in sess_auth_ntlmv2()
1291 ses->auth_key.response = NULL; in sess_auth_ntlmv2()
1302 struct cifs_ses *ses = sess_data->ses; in sess_auth_kerberos() local
1317 capabilities = cifs_ssetup_hdr(ses, pSMB); in sess_auth_kerberos()
1319 spnego_key = cifs_get_spnego_key(ses); in sess_auth_kerberos()
1338 ses->auth_key.response = kmemdup(msg->data, msg->sesskey_len, in sess_auth_kerberos()
1340 if (!ses->auth_key.response) { in sess_auth_kerberos()
1346 ses->auth_key.len = msg->sesskey_len; in sess_auth_kerberos()
1355 if (ses->capabilities & CAP_UNICODE) { in sess_auth_kerberos()
1363 unicode_domain_string(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_kerberos()
1366 ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); in sess_auth_kerberos()
1388 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_kerberos()
1389 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_kerberos()
1413 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_kerberos()
1416 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_kerberos()
1428 kfree(ses->auth_key.response); in sess_auth_kerberos()
1429 ses->auth_key.response = NULL; in sess_auth_kerberos()
1442 struct cifs_ses *ses = sess_data->ses; in _sess_auth_rawntlmssp_assemble_req() local
1448 capabilities = cifs_ssetup_hdr(ses, pSMB); in _sess_auth_rawntlmssp_assemble_req()
1481 struct cifs_ses *ses = sess_data->ses; in sess_auth_rawntlmssp_negotiate() local
1492 ses->ntlmssp = kmalloc(sizeof(struct ntlmssp_auth), GFP_KERNEL); in sess_auth_rawntlmssp_negotiate()
1493 if (!ses->ntlmssp) { in sess_auth_rawntlmssp_negotiate()
1497 ses->ntlmssp->sesskey_per_smbsess = false; in sess_auth_rawntlmssp_negotiate()
1507 build_ntlmssp_negotiate_blob(pSMB->req.SecurityBlob, ses); in sess_auth_rawntlmssp_negotiate()
1538 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ in sess_auth_rawntlmssp_negotiate()
1539 cifs_dbg(FYI, "UID = %llu\n", ses->Suid); in sess_auth_rawntlmssp_negotiate()
1552 rc = decode_ntlmssp_challenge(bcc_ptr, blob_len, ses); in sess_auth_rawntlmssp_negotiate()
1562 kfree(ses->auth_key.response); in sess_auth_rawntlmssp_negotiate()
1563 ses->auth_key.response = NULL; in sess_auth_rawntlmssp_negotiate()
1564 kfree(ses->ntlmssp); in sess_auth_rawntlmssp_negotiate()
1565 ses->ntlmssp = NULL; in sess_auth_rawntlmssp_negotiate()
1577 struct cifs_ses *ses = sess_data->ses; in sess_auth_rawntlmssp_authenticate() local
1594 &blob_len, ses, sess_data->nls_cp); in sess_auth_rawntlmssp_authenticate()
1605 smb_buf->Uid = ses->Suid; in sess_auth_rawntlmssp_authenticate()
1626 if (ses->Suid != smb_buf->Uid) { in sess_auth_rawntlmssp_authenticate()
1627 ses->Suid = smb_buf->Uid; in sess_auth_rawntlmssp_authenticate()
1628 cifs_dbg(FYI, "UID changed! new UID = %llu\n", ses->Suid); in sess_auth_rawntlmssp_authenticate()
1653 decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_rawntlmssp_authenticate()
1656 decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, in sess_auth_rawntlmssp_authenticate()
1669 kfree(ses->auth_key.response); in sess_auth_rawntlmssp_authenticate()
1670 ses->auth_key.response = NULL; in sess_auth_rawntlmssp_authenticate()
1671 kfree(ses->ntlmssp); in sess_auth_rawntlmssp_authenticate()
1672 ses->ntlmssp = NULL; in sess_auth_rawntlmssp_authenticate()
1678 static int select_sec(struct cifs_ses *ses, struct sess_data *sess_data) in select_sec() argument
1682 type = cifs_select_sectype(ses->server, ses->sectype); in select_sec()
1727 int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses, in CIFS_SessSetup() argument
1733 if (ses == NULL) { in CIFS_SessSetup()
1742 rc = select_sec(ses, sess_data); in CIFS_SessSetup()
1747 sess_data->ses = ses; in CIFS_SessSetup()