aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorShirish Pargaonkar <shirishpargaonkar@gmail.com>2010-10-26 19:10:24 -0400
committerSteve French <sfrench@us.ibm.com>2010-10-26 22:04:30 -0400
commitf7c5445a9deecffea8a4fffc0163bf582411ac8a (patch)
treeefea64611599a034510be60077ca20bed68a48e8 /fs/cifs
parent307fbd31b61623ad1b5388b452118f8aea99f9d0 (diff)
NTLM auth and sign - minor error corrections and cleanup
Minor cleanup - Fix spelling mistake, make meaningful (goto) label In function setup_ntlmv2_rsp(), do not return 0 and leak memory, let the tiblob get freed. For function find_domain_name(), pass already available nls table pointer instead of loading and unloading the table again in this function. For ntlmv2, the case sensitive password length is the length of the response, so subtract session key length (16 bytes) from the .len. Signed-off-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/cifsencrypt.c15
-rw-r--r--fs/cifs/cifsglob.h2
-rw-r--r--fs/cifs/connect.c8
-rw-r--r--fs/cifs/sess.c2
4 files changed, 12 insertions, 15 deletions
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index 96908874a45c..17d603ad5e34 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -391,7 +391,7 @@ build_avpair_blob(struct cifsSesInfo *ses, const struct nls_table *nls_cp)
391 * about target string i.e. for some, just user name might suffice. 391 * about target string i.e. for some, just user name might suffice.
392 */ 392 */
393static int 393static int
394find_domain_name(struct cifsSesInfo *ses) 394find_domain_name(struct cifsSesInfo *ses, const struct nls_table *nls_cp)
395{ 395{
396 unsigned int attrsize; 396 unsigned int attrsize;
397 unsigned int type; 397 unsigned int type;
@@ -420,16 +420,13 @@ find_domain_name(struct cifsSesInfo *ses)
420 if (!attrsize) 420 if (!attrsize)
421 break; 421 break;
422 if (!ses->domainName) { 422 if (!ses->domainName) {
423 struct nls_table *default_nls;
424 ses->domainName = 423 ses->domainName =
425 kmalloc(attrsize + 1, GFP_KERNEL); 424 kmalloc(attrsize + 1, GFP_KERNEL);
426 if (!ses->domainName) 425 if (!ses->domainName)
427 return -ENOMEM; 426 return -ENOMEM;
428 default_nls = load_nls_default();
429 cifs_from_ucs2(ses->domainName, 427 cifs_from_ucs2(ses->domainName,
430 (__le16 *)blobptr, attrsize, attrsize, 428 (__le16 *)blobptr, attrsize, attrsize,
431 default_nls, false); 429 nls_cp, false);
432 unload_nls(default_nls);
433 break; 430 break;
434 } 431 }
435 } 432 }
@@ -561,7 +558,7 @@ setup_ntlmv2_rsp(struct cifsSesInfo *ses, const struct nls_table *nls_cp)
561 558
562 if (ses->server->secType == RawNTLMSSP) { 559 if (ses->server->secType == RawNTLMSSP) {
563 if (!ses->domainName) { 560 if (!ses->domainName) {
564 rc = find_domain_name(ses); 561 rc = find_domain_name(ses, nls_cp);
565 if (rc) { 562 if (rc) {
566 cERROR(1, "error %d finding domain name", rc); 563 cERROR(1, "error %d finding domain name", rc);
567 goto setup_ntlmv2_rsp_ret; 564 goto setup_ntlmv2_rsp_ret;
@@ -594,12 +591,14 @@ setup_ntlmv2_rsp(struct cifsSesInfo *ses, const struct nls_table *nls_cp)
594 591
595 memcpy(ses->auth_key.response + baselen, ses->tiblob, ses->tilen); 592 memcpy(ses->auth_key.response + baselen, ses->tiblob, ses->tilen);
596 593
597 /* calculate buf->ntlmv2_hash */ 594 /* calculate ntlmv2_hash */
598 rc = calc_ntlmv2_hash(ses, nls_cp); 595 rc = calc_ntlmv2_hash(ses, nls_cp);
599 if (rc) { 596 if (rc) {
600 cERROR(1, "could not get v2 hash rc %d", rc); 597 cERROR(1, "could not get v2 hash rc %d", rc);
601 goto setup_ntlmv2_rsp_ret; 598 goto setup_ntlmv2_rsp_ret;
602 } 599 }
600
601 /* calculate first part of the client response (CR1) */
603 rc = CalcNTLMv2_response(ses); 602 rc = CalcNTLMv2_response(ses);
604 if (rc) { 603 if (rc) {
605 cERROR(1, "Could not calculate CR1 rc: %d", rc); 604 cERROR(1, "Could not calculate CR1 rc: %d", rc);
@@ -623,8 +622,6 @@ setup_ntlmv2_rsp(struct cifsSesInfo *ses, const struct nls_table *nls_cp)
623 rc = crypto_shash_final(&ses->server->secmech.sdeschmacmd5->shash, 622 rc = crypto_shash_final(&ses->server->secmech.sdeschmacmd5->shash,
624 ses->auth_key.response); 623 ses->auth_key.response);
625 624
626 return 0;
627
628setup_ntlmv2_rsp_ret: 625setup_ntlmv2_rsp_ret:
629 kfree(ses->tiblob); 626 kfree(ses->tiblob);
630 ses->tiblob = NULL; 627 ses->tiblob = NULL;
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 7ca5f6d8ed80..67d6a2280a01 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -111,7 +111,7 @@ struct sdesc {
111 char ctx[]; 111 char ctx[];
112}; 112};
113 113
114/* crypto hashing related structure/fields, not speicific to a sec mech */ 114/* crypto hashing related structure/fields, not specific to a sec mech */
115struct cifs_secmech { 115struct cifs_secmech {
116 struct crypto_shash *hmacmd5; /* hmac-md5 hash function */ 116 struct crypto_shash *hmacmd5; /* hmac-md5 hash function */
117 struct crypto_shash *md5; /* md5 hash function */ 117 struct crypto_shash *md5; /* md5 hash function */
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 04239a7ff320..469c3ddba463 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1631,7 +1631,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
1631 tcp_ses->hostname = extract_hostname(volume_info->UNC); 1631 tcp_ses->hostname = extract_hostname(volume_info->UNC);
1632 if (IS_ERR(tcp_ses->hostname)) { 1632 if (IS_ERR(tcp_ses->hostname)) {
1633 rc = PTR_ERR(tcp_ses->hostname); 1633 rc = PTR_ERR(tcp_ses->hostname);
1634 goto out_err2; 1634 goto out_err_crypto_release;
1635 } 1635 }
1636 1636
1637 tcp_ses->noblocksnd = volume_info->noblocksnd; 1637 tcp_ses->noblocksnd = volume_info->noblocksnd;
@@ -1675,7 +1675,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
1675 } 1675 }
1676 if (rc < 0) { 1676 if (rc < 0) {
1677 cERROR(1, "Error connecting to socket. Aborting operation"); 1677 cERROR(1, "Error connecting to socket. Aborting operation");
1678 goto out_err2; 1678 goto out_err_crypto_release;
1679 } 1679 }
1680 1680
1681 /* 1681 /*
@@ -1689,7 +1689,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
1689 rc = PTR_ERR(tcp_ses->tsk); 1689 rc = PTR_ERR(tcp_ses->tsk);
1690 cERROR(1, "error %d create cifsd thread", rc); 1690 cERROR(1, "error %d create cifsd thread", rc);
1691 module_put(THIS_MODULE); 1691 module_put(THIS_MODULE);
1692 goto out_err2; 1692 goto out_err_crypto_release;
1693 } 1693 }
1694 1694
1695 /* thread spawned, put it on the list */ 1695 /* thread spawned, put it on the list */
@@ -1701,7 +1701,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
1701 1701
1702 return tcp_ses; 1702 return tcp_ses;
1703 1703
1704out_err2: 1704out_err_crypto_release:
1705 cifs_crypto_shash_release(tcp_ses); 1705 cifs_crypto_shash_release(tcp_ses);
1706 1706
1707out_err: 1707out_err:
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index d998c4f7aae5..e0515a62715d 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -738,7 +738,7 @@ ssetup_ntlmssp_authenticate:
738 * assigned, tilen is 0 otherwise. 738 * assigned, tilen is 0 otherwise.
739 */ 739 */
740 pSMB->req_no_secext.CaseSensitivePasswordLength = 740 pSMB->req_no_secext.CaseSensitivePasswordLength =
741 cpu_to_le16(ses->auth_key.len); 741 cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE);
742 742
743 if (ses->capabilities & CAP_UNICODE) { 743 if (ses->capabilities & CAP_UNICODE) {
744 if (iov[0].iov_len % 2) { 744 if (iov[0].iov_len % 2) {