aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/sess.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /fs/cifs/sess.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'fs/cifs/sess.c')
-rw-r--r--fs/cifs/sess.c66
1 files changed, 30 insertions, 36 deletions
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index 76809f4d342..d3e619692ee 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -124,9 +124,7 @@ static __u32 cifs_ssetup_hdr(struct cifs_ses *ses, SESSION_SETUP_ANDX *pSMB)
124 /* that we use in next few lines */ 124 /* that we use in next few lines */
125 /* Note that header is initialized to zero in header_assemble */ 125 /* Note that header is initialized to zero in header_assemble */
126 pSMB->req.AndXCommand = 0xFF; 126 pSMB->req.AndXCommand = 0xFF;
127 pSMB->req.MaxBufferSize = cpu_to_le16(min_t(u32, 127 pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf);
128 CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4,
129 USHRT_MAX));
130 pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); 128 pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq);
131 pSMB->req.VcNumber = get_next_vcnum(ses); 129 pSMB->req.VcNumber = get_next_vcnum(ses);
132 130
@@ -167,16 +165,16 @@ unicode_oslm_strings(char **pbcc_area, const struct nls_table *nls_cp)
167 int bytes_ret = 0; 165 int bytes_ret = 0;
168 166
169 /* Copy OS version */ 167 /* Copy OS version */
170 bytes_ret = cifs_strtoUTF16((__le16 *)bcc_ptr, "Linux version ", 32, 168 bytes_ret = cifs_strtoUCS((__le16 *)bcc_ptr, "Linux version ", 32,
171 nls_cp); 169 nls_cp);
172 bcc_ptr += 2 * bytes_ret; 170 bcc_ptr += 2 * bytes_ret;
173 bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, init_utsname()->release, 171 bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, init_utsname()->release,
174 32, nls_cp); 172 32, nls_cp);
175 bcc_ptr += 2 * bytes_ret; 173 bcc_ptr += 2 * bytes_ret;
176 bcc_ptr += 2; /* trailing null */ 174 bcc_ptr += 2; /* trailing null */
177 175
178 bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS, 176 bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS,
179 32, nls_cp); 177 32, nls_cp);
180 bcc_ptr += 2 * bytes_ret; 178 bcc_ptr += 2 * bytes_ret;
181 bcc_ptr += 2; /* trailing null */ 179 bcc_ptr += 2; /* trailing null */
182 180
@@ -197,8 +195,8 @@ static void unicode_domain_string(char **pbcc_area, struct cifs_ses *ses,
197 *(bcc_ptr+1) = 0; 195 *(bcc_ptr+1) = 0;
198 bytes_ret = 0; 196 bytes_ret = 0;
199 } else 197 } else
200 bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->domainName, 198 bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, ses->domainName,
201 256, nls_cp); 199 256, nls_cp);
202 bcc_ptr += 2 * bytes_ret; 200 bcc_ptr += 2 * bytes_ret;
203 bcc_ptr += 2; /* account for null terminator */ 201 bcc_ptr += 2; /* account for null terminator */
204 202
@@ -226,8 +224,8 @@ static void unicode_ssetup_strings(char **pbcc_area, struct cifs_ses *ses,
226 *bcc_ptr = 0; 224 *bcc_ptr = 0;
227 *(bcc_ptr+1) = 0; 225 *(bcc_ptr+1) = 0;
228 } else { 226 } else {
229 bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->user_name, 227 bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, ses->user_name,
230 MAX_USERNAME_SIZE, nls_cp); 228 MAX_USERNAME_SIZE, nls_cp);
231 } 229 }
232 bcc_ptr += 2 * bytes_ret; 230 bcc_ptr += 2 * bytes_ret;
233 bcc_ptr += 2; /* account for null termination */ 231 bcc_ptr += 2; /* account for null termination */
@@ -246,15 +244,16 @@ static void ascii_ssetup_strings(char **pbcc_area, struct cifs_ses *ses,
246 /* copy user */ 244 /* copy user */
247 /* BB what about null user mounts - check that we do this BB */ 245 /* BB what about null user mounts - check that we do this BB */
248 /* copy user */ 246 /* copy user */
249 if (ses->user_name != NULL) { 247 if (ses->user_name != NULL)
250 strncpy(bcc_ptr, ses->user_name, MAX_USERNAME_SIZE); 248 strncpy(bcc_ptr, ses->user_name, MAX_USERNAME_SIZE);
251 bcc_ptr += strnlen(ses->user_name, MAX_USERNAME_SIZE);
252 }
253 /* else null user mount */ 249 /* else null user mount */
250
251 bcc_ptr += strnlen(ses->user_name, MAX_USERNAME_SIZE);
254 *bcc_ptr = 0; 252 *bcc_ptr = 0;
255 bcc_ptr++; /* account for null termination */ 253 bcc_ptr++; /* account for null termination */
256 254
257 /* copy domain */ 255 /* copy domain */
256
258 if (ses->domainName != NULL) { 257 if (ses->domainName != NULL) {
259 strncpy(bcc_ptr, ses->domainName, 256); 258 strncpy(bcc_ptr, ses->domainName, 256);
260 bcc_ptr += strnlen(ses->domainName, 256); 259 bcc_ptr += strnlen(ses->domainName, 256);
@@ -286,7 +285,7 @@ decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifs_ses *ses,
286 cFYI(1, "bleft %d", bleft); 285 cFYI(1, "bleft %d", bleft);
287 286
288 kfree(ses->serverOS); 287 kfree(ses->serverOS);
289 ses->serverOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp); 288 ses->serverOS = cifs_strndup_from_ucs(data, bleft, true, nls_cp);
290 cFYI(1, "serverOS=%s", ses->serverOS); 289 cFYI(1, "serverOS=%s", ses->serverOS);
291 len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2; 290 len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2;
292 data += len; 291 data += len;
@@ -295,7 +294,7 @@ decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifs_ses *ses,
295 return; 294 return;
296 295
297 kfree(ses->serverNOS); 296 kfree(ses->serverNOS);
298 ses->serverNOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp); 297 ses->serverNOS = cifs_strndup_from_ucs(data, bleft, true, nls_cp);
299 cFYI(1, "serverNOS=%s", ses->serverNOS); 298 cFYI(1, "serverNOS=%s", ses->serverNOS);
300 len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2; 299 len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2;
301 data += len; 300 data += len;
@@ -304,7 +303,7 @@ decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifs_ses *ses,
304 return; 303 return;
305 304
306 kfree(ses->serverDomain); 305 kfree(ses->serverDomain);
307 ses->serverDomain = cifs_strndup_from_utf16(data, bleft, true, nls_cp); 306 ses->serverDomain = cifs_strndup_from_ucs(data, bleft, true, nls_cp);
308 cFYI(1, "serverDomain=%s", ses->serverDomain); 307 cFYI(1, "serverDomain=%s", ses->serverDomain);
309 308
310 return; 309 return;
@@ -364,7 +363,7 @@ static int decode_ascii_ssetup(char **pbcc_area, __u16 bleft,
364 return rc; 363 return rc;
365} 364}
366 365
367int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len, 366static int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len,
368 struct cifs_ses *ses) 367 struct cifs_ses *ses)
369{ 368{
370 unsigned int tioffset; /* challenge message target info area */ 369 unsigned int tioffset; /* challenge message target info area */
@@ -394,10 +393,6 @@ int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len,
394 ses->ntlmssp->server_flags = le32_to_cpu(pblob->NegotiateFlags); 393 ses->ntlmssp->server_flags = le32_to_cpu(pblob->NegotiateFlags);
395 tioffset = le32_to_cpu(pblob->TargetInfoArray.BufferOffset); 394 tioffset = le32_to_cpu(pblob->TargetInfoArray.BufferOffset);
396 tilen = le16_to_cpu(pblob->TargetInfoArray.Length); 395 tilen = le16_to_cpu(pblob->TargetInfoArray.Length);
397 if (tioffset > blob_len || tioffset + tilen > blob_len) {
398 cERROR(1, "tioffset + tilen too high %u + %u", tioffset, tilen);
399 return -EINVAL;
400 }
401 if (tilen) { 396 if (tilen) {
402 ses->auth_key.response = kmalloc(tilen, GFP_KERNEL); 397 ses->auth_key.response = kmalloc(tilen, GFP_KERNEL);
403 if (!ses->auth_key.response) { 398 if (!ses->auth_key.response) {
@@ -415,7 +410,7 @@ int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len,
415 410
416/* We do not malloc the blob, it is passed in pbuffer, because 411/* We do not malloc the blob, it is passed in pbuffer, because
417 it is fixed size, and small, making this approach cleaner */ 412 it is fixed size, and small, making this approach cleaner */
418void build_ntlmssp_negotiate_blob(unsigned char *pbuffer, 413static void build_ntlmssp_negotiate_blob(unsigned char *pbuffer,
419 struct cifs_ses *ses) 414 struct cifs_ses *ses)
420{ 415{
421 NEGOTIATE_MESSAGE *sec_blob = (NEGOTIATE_MESSAGE *)pbuffer; 416 NEGOTIATE_MESSAGE *sec_blob = (NEGOTIATE_MESSAGE *)pbuffer;
@@ -451,7 +446,7 @@ void build_ntlmssp_negotiate_blob(unsigned char *pbuffer,
451/* We do not malloc the blob, it is passed in pbuffer, because its 446/* We do not malloc the blob, it is passed in pbuffer, because its
452 maximum possible size is fixed and small, making this approach cleaner. 447 maximum possible size is fixed and small, making this approach cleaner.
453 This function returns the length of the data in the blob */ 448 This function returns the length of the data in the blob */
454int build_ntlmssp_auth_blob(unsigned char *pbuffer, 449static int build_ntlmssp_auth_blob(unsigned char *pbuffer,
455 u16 *buflen, 450 u16 *buflen,
456 struct cifs_ses *ses, 451 struct cifs_ses *ses,
457 const struct nls_table *nls_cp) 452 const struct nls_table *nls_cp)
@@ -505,8 +500,8 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer,
505 tmp += 2; 500 tmp += 2;
506 } else { 501 } else {
507 int len; 502 int len;
508 len = cifs_strtoUTF16((__le16 *)tmp, ses->domainName, 503 len = cifs_strtoUCS((__le16 *)tmp, ses->domainName,
509 MAX_USERNAME_SIZE, nls_cp); 504 MAX_USERNAME_SIZE, nls_cp);
510 len *= 2; /* unicode is 2 bytes each */ 505 len *= 2; /* unicode is 2 bytes each */
511 sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - pbuffer); 506 sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - pbuffer);
512 sec_blob->DomainName.Length = cpu_to_le16(len); 507 sec_blob->DomainName.Length = cpu_to_le16(len);
@@ -521,8 +516,8 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer,
521 tmp += 2; 516 tmp += 2;
522 } else { 517 } else {
523 int len; 518 int len;
524 len = cifs_strtoUTF16((__le16 *)tmp, ses->user_name, 519 len = cifs_strtoUCS((__le16 *)tmp, ses->user_name,
525 MAX_USERNAME_SIZE, nls_cp); 520 MAX_USERNAME_SIZE, nls_cp);
526 len *= 2; /* unicode is 2 bytes each */ 521 len *= 2; /* unicode is 2 bytes each */
527 sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer); 522 sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer);
528 sec_blob->UserName.Length = cpu_to_le16(len); 523 sec_blob->UserName.Length = cpu_to_le16(len);
@@ -556,7 +551,7 @@ setup_ntlmv2_ret:
556} 551}
557 552
558int 553int
559CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses, 554CIFS_SessSetup(unsigned int xid, struct cifs_ses *ses,
560 const struct nls_table *nls_cp) 555 const struct nls_table *nls_cp)
561{ 556{
562 int rc = 0; 557 int rc = 0;
@@ -686,7 +681,7 @@ ssetup_ntlmssp_authenticate:
686 cpu_to_le16(CIFS_AUTH_RESP_SIZE); 681 cpu_to_le16(CIFS_AUTH_RESP_SIZE);
687 682
688 /* calculate ntlm response and session key */ 683 /* calculate ntlm response and session key */
689 rc = setup_ntlm_response(ses, nls_cp); 684 rc = setup_ntlm_response(ses);
690 if (rc) { 685 if (rc) {
691 cERROR(1, "Error %d during NTLM authentication", rc); 686 cERROR(1, "Error %d during NTLM authentication", rc);
692 goto ssetup_exit; 687 goto ssetup_exit;
@@ -876,8 +871,7 @@ ssetup_ntlmssp_authenticate:
876 pSMB = (SESSION_SETUP_ANDX *)iov[0].iov_base; 871 pSMB = (SESSION_SETUP_ANDX *)iov[0].iov_base;
877 smb_buf = (struct smb_hdr *)iov[0].iov_base; 872 smb_buf = (struct smb_hdr *)iov[0].iov_base;
878 873
879 if ((type == RawNTLMSSP) && (resp_buf_type != CIFS_NO_BUFFER) && 874 if ((type == RawNTLMSSP) && (smb_buf->Status.CifsError ==
880 (smb_buf->Status.CifsError ==
881 cpu_to_le32(NT_STATUS_MORE_PROCESSING_REQUIRED))) { 875 cpu_to_le32(NT_STATUS_MORE_PROCESSING_REQUIRED))) {
882 if (phase != NtLmNegotiate) { 876 if (phase != NtLmNegotiate) {
883 cERROR(1, "Unexpected more processing error"); 877 cERROR(1, "Unexpected more processing error");
@@ -899,7 +893,7 @@ ssetup_ntlmssp_authenticate:
899 if (action & GUEST_LOGIN) 893 if (action & GUEST_LOGIN)
900 cFYI(1, "Guest login"); /* BB mark SesInfo struct? */ 894 cFYI(1, "Guest login"); /* BB mark SesInfo struct? */
901 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ 895 ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */
902 cFYI(1, "UID = %llu ", ses->Suid); 896 cFYI(1, "UID = %d ", ses->Suid);
903 /* response can have either 3 or 4 word count - Samba sends 3 */ 897 /* response can have either 3 or 4 word count - Samba sends 3 */
904 /* and lanman response is 3 */ 898 /* and lanman response is 3 */
905 bytes_remaining = get_bcc(smb_buf); 899 bytes_remaining = get_bcc(smb_buf);
@@ -939,7 +933,7 @@ ssetup_ntlmssp_authenticate:
939 933
940ssetup_exit: 934ssetup_exit:
941 if (spnego_key) { 935 if (spnego_key) {
942 key_invalidate(spnego_key); 936 key_revoke(spnego_key);
943 key_put(spnego_key); 937 key_put(spnego_key);
944 } 938 }
945 kfree(str_area); 939 kfree(str_area);