aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/sess.c
diff options
context:
space:
mode:
authorShirish Pargaonkar <shirishpargaonkar@gmail.com>2010-12-11 15:19:22 -0500
committerSteve French <sfrench@us.ibm.com>2011-01-06 14:07:52 -0500
commitdf8fbc241aa3c451248b1f19fff3a3f604b107f9 (patch)
tree750d602cb5762dda52cad4a6afff0f8fedc4ab37 /fs/cifs/sess.c
parent262f86adcc0665872812a7458a5d03e19e0efe33 (diff)
cifs: Support NTLM2 session security during NTLMSSP authentication [try #5]
Indicate to the server a capability of NTLM2 session security (NTLM2 Key) during ntlmssp protocol exchange in one of the bits of the flags field. If server supports this capability, send NTLM2 key even if signing is not required on the server. If the server requires signing, the session keys exchanged for NTLMv2 and NTLM2 session security in auth packet of the nlmssp exchange are same. Send the same flags in authenticate message (type 3) that client sent in negotiate message (type 1). Remove function setup_ntlmssp_neg_req Make sure ntlmssp negotiate and authenticate messages are zero'ed before they are built. Reported-and-Tested-by: Robbert Kouprie <robbert@exx.nl> Signed-off-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com> Acked-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/sess.c')
-rw-r--r--fs/cifs/sess.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index 7b01d3f6eed6..54d9f76deff9 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -431,13 +431,14 @@ static void build_ntlmssp_negotiate_blob(unsigned char *pbuffer,
431 NEGOTIATE_MESSAGE *sec_blob = (NEGOTIATE_MESSAGE *)pbuffer; 431 NEGOTIATE_MESSAGE *sec_blob = (NEGOTIATE_MESSAGE *)pbuffer;
432 __u32 flags; 432 __u32 flags;
433 433
434 memset(pbuffer, 0, sizeof(NEGOTIATE_MESSAGE));
434 memcpy(sec_blob->Signature, NTLMSSP_SIGNATURE, 8); 435 memcpy(sec_blob->Signature, NTLMSSP_SIGNATURE, 8);
435 sec_blob->MessageType = NtLmNegotiate; 436 sec_blob->MessageType = NtLmNegotiate;
436 437
437 /* BB is NTLMV2 session security format easier to use here? */ 438 /* BB is NTLMV2 session security format easier to use here? */
438 flags = NTLMSSP_NEGOTIATE_56 | NTLMSSP_REQUEST_TARGET | 439 flags = NTLMSSP_NEGOTIATE_56 | NTLMSSP_REQUEST_TARGET |
439 NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE | 440 NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE |
440 NTLMSSP_NEGOTIATE_NTLM; 441 NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC;
441 if (ses->server->secMode & 442 if (ses->server->secMode &
442 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) { 443 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) {
443 flags |= NTLMSSP_NEGOTIATE_SIGN; 444 flags |= NTLMSSP_NEGOTIATE_SIGN;
@@ -446,7 +447,7 @@ static void build_ntlmssp_negotiate_blob(unsigned char *pbuffer,
446 NTLMSSP_NEGOTIATE_EXTENDED_SEC; 447 NTLMSSP_NEGOTIATE_EXTENDED_SEC;
447 } 448 }
448 449
449 sec_blob->NegotiateFlags |= cpu_to_le32(flags); 450 sec_blob->NegotiateFlags = cpu_to_le32(flags);
450 451
451 sec_blob->WorkstationName.BufferOffset = 0; 452 sec_blob->WorkstationName.BufferOffset = 0;
452 sec_blob->WorkstationName.Length = 0; 453 sec_blob->WorkstationName.Length = 0;
@@ -477,7 +478,7 @@ static int build_ntlmssp_auth_blob(unsigned char *pbuffer,
477 flags = NTLMSSP_NEGOTIATE_56 | 478 flags = NTLMSSP_NEGOTIATE_56 |
478 NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_TARGET_INFO | 479 NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_TARGET_INFO |
479 NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE | 480 NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE |
480 NTLMSSP_NEGOTIATE_NTLM; 481 NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC;
481 if (ses->server->secMode & 482 if (ses->server->secMode &
482 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 483 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
483 flags |= NTLMSSP_NEGOTIATE_SIGN; 484 flags |= NTLMSSP_NEGOTIATE_SIGN;
@@ -485,7 +486,7 @@ static int build_ntlmssp_auth_blob(unsigned char *pbuffer,
485 flags |= NTLMSSP_NEGOTIATE_ALWAYS_SIGN; 486 flags |= NTLMSSP_NEGOTIATE_ALWAYS_SIGN;
486 487
487 tmp = pbuffer + sizeof(AUTHENTICATE_MESSAGE); 488 tmp = pbuffer + sizeof(AUTHENTICATE_MESSAGE);
488 sec_blob->NegotiateFlags |= cpu_to_le32(flags); 489 sec_blob->NegotiateFlags = cpu_to_le32(flags);
489 490
490 sec_blob->LmChallengeResponse.BufferOffset = 491 sec_blob->LmChallengeResponse.BufferOffset =
491 cpu_to_le32(sizeof(AUTHENTICATE_MESSAGE)); 492 cpu_to_le32(sizeof(AUTHENTICATE_MESSAGE));
@@ -544,8 +545,9 @@ static int build_ntlmssp_auth_blob(unsigned char *pbuffer,
544 sec_blob->WorkstationName.MaximumLength = 0; 545 sec_blob->WorkstationName.MaximumLength = 0;
545 tmp += 2; 546 tmp += 2;
546 547
547 if ((ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_KEY_XCH) && 548 if (((ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_KEY_XCH) ||
548 !calc_seckey(ses)) { 549 (ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_EXTENDED_SEC))
550 && !calc_seckey(ses)) {
549 memcpy(tmp, ses->ntlmssp->ciphertext, CIFS_CPHTXT_SIZE); 551 memcpy(tmp, ses->ntlmssp->ciphertext, CIFS_CPHTXT_SIZE);
550 sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - pbuffer); 552 sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - pbuffer);
551 sec_blob->SessionKey.Length = cpu_to_le16(CIFS_CPHTXT_SIZE); 553 sec_blob->SessionKey.Length = cpu_to_le16(CIFS_CPHTXT_SIZE);
@@ -562,16 +564,6 @@ setup_ntlmv2_ret:
562 *buflen = tmp - pbuffer; 564 *buflen = tmp - pbuffer;
563 return rc; 565 return rc;
564} 566}
565
566
567static void setup_ntlmssp_neg_req(SESSION_SETUP_ANDX *pSMB,
568 struct cifsSesInfo *ses)
569{
570 build_ntlmssp_negotiate_blob(&pSMB->req.SecurityBlob[0], ses);
571 pSMB->req.SecurityBlobLength = cpu_to_le16(sizeof(NEGOTIATE_MESSAGE));
572
573 return;
574}
575#endif 567#endif
576 568
577int 569int
@@ -828,16 +820,19 @@ ssetup_ntlmssp_authenticate:
828 capabilities |= CAP_EXTENDED_SECURITY; 820 capabilities |= CAP_EXTENDED_SECURITY;
829 pSMB->req.Capabilities |= cpu_to_le32(capabilities); 821 pSMB->req.Capabilities |= cpu_to_le32(capabilities);
830 if (phase == NtLmNegotiate) { 822 if (phase == NtLmNegotiate) {
831 setup_ntlmssp_neg_req(pSMB, ses); 823 build_ntlmssp_negotiate_blob(
824 pSMB->req.SecurityBlob, ses);
832 iov[1].iov_len = sizeof(NEGOTIATE_MESSAGE); 825 iov[1].iov_len = sizeof(NEGOTIATE_MESSAGE);
833 iov[1].iov_base = &pSMB->req.SecurityBlob[0]; 826 iov[1].iov_base = pSMB->req.SecurityBlob;
827 pSMB->req.SecurityBlobLength =
828 cpu_to_le16(sizeof(NEGOTIATE_MESSAGE));
834 } else if (phase == NtLmAuthenticate) { 829 } else if (phase == NtLmAuthenticate) {
835 /* 5 is an empirical value, large enought to 830 /* 5 is an empirical value, large enought to
836 * hold authenticate message, max 10 of 831 * hold authenticate message, max 10 of
837 * av paris, doamin,user,workstation mames, 832 * av paris, doamin,user,workstation mames,
838 * flags etc.. 833 * flags etc..
839 */ 834 */
840 ntlmsspblob = kmalloc( 835 ntlmsspblob = kzalloc(
841 5*sizeof(struct _AUTHENTICATE_MESSAGE), 836 5*sizeof(struct _AUTHENTICATE_MESSAGE),
842 GFP_KERNEL); 837 GFP_KERNEL);
843 if (!ntlmsspblob) { 838 if (!ntlmsspblob) {