aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/sess.c
diff options
context:
space:
mode:
authorShirish Pargaonkar <shirishpargaonkar@gmail.com>2013-08-29 09:35:09 -0400
committerSteve French <smfrench@gmail.com>2013-09-08 15:47:47 -0400
commitd4e63bd6e40da30e965e8947b98ba75c6b973c62 (patch)
tree4f17bdbe75843ac578a9a9e1ee491192dd280d73 /fs/cifs/sess.c
parent31f92e9a87553d9d3044fe97b5fe0247e4314773 (diff)
cifs: Process post session setup code in respective dialect functions.
Move the post (successful) session setup code to respective dialect routines. For smb1, session key is per smb connection. For smb2/smb3, session key is per smb session. If client and server do not require signing, free session key for smb1/2/3. If client and server require signing smb1 - Copy (kmemdup) session key for the first session to connection. Free session key of that and subsequent sessions on this connection. smb2 - For every session, keep the session key and free it when the session is being shutdown. smb3 - For every session, generate the smb3 signing key using the session key and then free the session key. There are two unrelated line formatting changes as well. Reviewed-by: Jeff Layton <jlayton@samba.org> Signed-off-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/sess.c')
-rw-r--r--fs/cifs/sess.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index a0a62db0f575..acea6c4ded47 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -629,7 +629,8 @@ CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
629 type = select_sectype(ses->server, ses->sectype); 629 type = select_sectype(ses->server, ses->sectype);
630 cifs_dbg(FYI, "sess setup type %d\n", type); 630 cifs_dbg(FYI, "sess setup type %d\n", type);
631 if (type == Unspecified) { 631 if (type == Unspecified) {
632 cifs_dbg(VFS, "Unable to select appropriate authentication method!"); 632 cifs_dbg(VFS,
633 "Unable to select appropriate authentication method!");
633 return -EINVAL; 634 return -EINVAL;
634 } 635 }
635 636
@@ -815,8 +816,9 @@ ssetup_ntlmssp_authenticate:
815 ses->auth_key.response = kmemdup(msg->data, msg->sesskey_len, 816 ses->auth_key.response = kmemdup(msg->data, msg->sesskey_len,
816 GFP_KERNEL); 817 GFP_KERNEL);
817 if (!ses->auth_key.response) { 818 if (!ses->auth_key.response) {
818 cifs_dbg(VFS, "Kerberos can't allocate (%u bytes) memory", 819 cifs_dbg(VFS,
819 msg->sesskey_len); 820 "Kerberos can't allocate (%u bytes) memory",
821 msg->sesskey_len);
820 rc = -ENOMEM; 822 rc = -ENOMEM;
821 goto ssetup_exit; 823 goto ssetup_exit;
822 } 824 }
@@ -1005,5 +1007,37 @@ ssetup_exit:
1005 if ((phase == NtLmChallenge) && (rc == 0)) 1007 if ((phase == NtLmChallenge) && (rc == 0))
1006 goto ssetup_ntlmssp_authenticate; 1008 goto ssetup_ntlmssp_authenticate;
1007 1009
1010 if (!rc) {
1011 mutex_lock(&ses->server->srv_mutex);
1012 if (!ses->server->session_estab) {
1013 if (ses->server->sign) {
1014 ses->server->session_key.response =
1015 kmemdup(ses->auth_key.response,
1016 ses->auth_key.len, GFP_KERNEL);
1017 if (!ses->server->session_key.response) {
1018 rc = -ENOMEM;
1019 mutex_unlock(&ses->server->srv_mutex);
1020 goto keycp_exit;
1021 }
1022 ses->server->session_key.len =
1023 ses->auth_key.len;
1024 }
1025 ses->server->sequence_number = 0x2;
1026 ses->server->session_estab = true;
1027 }
1028 mutex_unlock(&ses->server->srv_mutex);
1029
1030 cifs_dbg(FYI, "CIFS session established successfully\n");
1031 spin_lock(&GlobalMid_Lock);
1032 ses->status = CifsGood;
1033 ses->need_reconnect = false;
1034 spin_unlock(&GlobalMid_Lock);
1035 }
1036
1037keycp_exit:
1038 kfree(ses->auth_key.response);
1039 ses->auth_key.response = NULL;
1040 kfree(ses->ntlmssp);
1041
1008 return rc; 1042 return rc;
1009} 1043}