Skip to contentSkip to conversation

ntlm authentication and signing - Correct response length for ntlmv2 authentication without extended security

PATCH In review [email protected] 2 participants 5 messages Sep 29, 2010 – Oct 4, 2010 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/7 ntlm authentication and signing - Correct response length for ntlmv2 authentication without extended security

From: Shirish Pargaonkar <[email protected]>

Fix incorrect calculation of case sensitive response length in the ntlmv2 (without extended security) response.

---
 fs/cifs/sess.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
fs/cifs/sess.c +7 -4
index af18a50..9148fd8 100644
@@ -739,9 +739,6 @@ ssetup_ntlmssp_authenticate:
 		pSMB->req_no_secext.CaseInsensitivePasswordLength = 0;
 		/*	cpu_to_le16(LM2_SESS_KEY_SIZE); */
 
-		pSMB->req_no_secext.CaseSensitivePasswordLength =
-			cpu_to_le16(sizeof(struct ntlmv2_resp));
-
 		/* calculate session key */
 		rc = setup_ntlmv2_rsp(ses, v2_sess_key, nls_cp);
 		if (rc) {
@@ -756,11 +753,17 @@ ssetup_ntlmssp_authenticate:
 		if (ses->tilen > 0) {
 			memcpy(bcc_ptr, ses->tiblob, ses->tilen);
 			bcc_ptr += ses->tilen;
+			pSMB->req_no_secext.CaseSensitivePasswordLength =
+				cpu_to_le16(sizeof(struct ntlmv2_resp) +
+						ses->tilen);
 			/* we never did allocate ses->domainName to free */
 			kfree(ses->tiblob);
 			ses->tiblob = NULL;
 			ses->tilen = 0;
-		}
+		} else
+			pSMB->req_no_secext.CaseSensitivePasswordLength =
+				cpu_to_le16(sizeof(struct ntlmv2_resp));
+
 		if (ses->capabilities & CAP_UNICODE) {
 			if (iov[0].iov_len % 2) {
 				*bcc_ptr = 0;
Signature · 1 line
1.6.0.2

A message that is not in the archive (sent off-list or not yet received): 1285771128-23075-1-git-send-email-shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 35 lines · On Wed, 29 Sep 2010 09:38:48 -0500 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Fix incorrect calculation of case sensitive response length in the ntlmv2 (without extended security) response.

---
 fs/cifs/sess.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
fs/cifs/sess.c +3 -3
index af18a50..9148fd8 100644
@@ -739,9 +739,6 @@ ssetup_ntlmssp_authenticate:
 		pSMB->req_no_secext.CaseInsensitivePasswordLength = 0;
 		/*	cpu_to_le16(LM2_SESS_KEY_SIZE); */
 
-		pSMB->req_no_secext.CaseSensitivePasswordLength =
-			cpu_to_le16(sizeof(struct ntlmv2_resp));
-
 		/* calculate session key */
 		rc = setup_ntlmv2_rsp(ses, v2_sess_key, nls_cp);
 		if (rc) {
@@ -756,11 +753,17 @@ ssetup_ntlmssp_authenticate:
 		if (ses->tilen > 0) {
 			memcpy(bcc_ptr, ses->tiblob, ses->tilen);
 			bcc_ptr += ses->tilen;
+			pSMB->req_no_secext.CaseSensitivePasswordLength =
+				cpu_to_le16(sizeof(struct ntlmv2_resp) +
+						ses->tilen);
 			/* we never did allocate ses->domainName to free */
 			kfree(ses->tiblob);

fs/cifs/sess.c ssetup_ntlmssp_authenticate: · line 769

Quoted 10 lines
fs/cifs/sess.c +4 -1
 			ses->tiblob = NULL;
 			ses->tilen = 0;
-		}
+		} else
+			pSMB->req_no_secext.CaseSensitivePasswordLength =
+				cpu_to_le16(sizeof(struct ntlmv2_resp));
+
 		if (ses->capabilities & CAP_UNICODE) {
 			if (iov[0].iov_len % 2) {
 				*bcc_ptr = 0;

Looks reasonable, but I think it would be clearer to just have a single place that sets CaseSensitivePasswordLength. If ses->tilen > 0, then you add the tilen to it...but tilen will never be less than 0, so there's no need to have this inside that if block, right?

Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20101004064130.04e0d1bb-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org

#4 lore raw
Quoted 54 lines · Jeff Layton
Quoted 35 lines · On Wed, 29 Sep 2010 09:38:48 -0500 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Fix incorrect calculation of case sensitive response length in the ntlmv2 (without extended security) response.

---
 fs/cifs/sess.c |   11 +++++++----

 1 files changed, 7 insertions(+), 4 deletions(-)
fs/cifs/sess.c +3 -3
index af18a50..9148fd8 100644
@@ -739,9 +739,6 @@ ssetup_ntlmssp_authenticate:
               pSMB->req_no_secext.CaseInsensitivePasswordLength = 0;
               /*      cpu_to_le16(LM2_SESS_KEY_SIZE); */
 
-             pSMB->req_no_secext.CaseSensitivePasswordLength =
-                     cpu_to_le16(sizeof(struct ntlmv2_resp));
-
               /* calculate session key */
               rc = setup_ntlmv2_rsp(ses, v2_sess_key, nls_cp);
               if (rc) {
@@ -756,11 +753,17 @@ ssetup_ntlmssp_authenticate:
               if (ses->tilen > 0) {
                       memcpy(bcc_ptr, ses->tiblob, ses->tilen);
                       bcc_ptr += ses->tilen;
+                     pSMB->req_no_secext.CaseSensitivePasswordLength =
+                             cpu_to_le16(sizeof(struct ntlmv2_resp) +
+                                             ses->tilen);
                       /* we never did allocate ses->domainName to free */
                       kfree(ses->tiblob);

fs/cifs/sess.c ssetup_ntlmssp_authenticate: · line 769

Quoted 10 lines
fs/cifs/sess.c +4 -1
                       ses->tiblob = NULL;
                       ses->tilen = 0;
-             }
+             } else
+                     pSMB->req_no_secext.CaseSensitivePasswordLength =
+                             cpu_to_le16(sizeof(struct ntlmv2_resp));
+
               if (ses->capabilities & CAP_UNICODE) {
                       if (iov[0].iov_len % 2) {
                               *bcc_ptr = 0;

Looks reasonable, but I think it would be clearer to just have a single place that sets CaseSensitivePasswordLength. If ses->tilen > 0, then you add the tilen to it...but tilen will never be less than 0, so there's no need to have this inside that if block, right?

Quoted 3 lines

--
Jeff Layton <[email protected]>

Jeff, yes, I can do that. Thanks.

#5 lore raw
In reply to a message not in the archive
Quoted 54 lines · Jeff Layton
Quoted 35 lines · On Wed, 29 Sep 2010 09:38:48 -0500 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Fix incorrect calculation of case sensitive response length in the ntlmv2 (without extended security) response.

---
 fs/cifs/sess.c |   11 +++++++----

 1 files changed, 7 insertions(+), 4 deletions(-)
fs/cifs/sess.c +3 -3
index af18a50..9148fd8 100644
@@ -739,9 +739,6 @@ ssetup_ntlmssp_authenticate:
               pSMB->req_no_secext.CaseInsensitivePasswordLength = 0;
               /*      cpu_to_le16(LM2_SESS_KEY_SIZE); */
 
-             pSMB->req_no_secext.CaseSensitivePasswordLength =
-                     cpu_to_le16(sizeof(struct ntlmv2_resp));
-
               /* calculate session key */
               rc = setup_ntlmv2_rsp(ses, v2_sess_key, nls_cp);
               if (rc) {
@@ -756,11 +753,17 @@ ssetup_ntlmssp_authenticate:
               if (ses->tilen > 0) {
                       memcpy(bcc_ptr, ses->tiblob, ses->tilen);
                       bcc_ptr += ses->tilen;
+                     pSMB->req_no_secext.CaseSensitivePasswordLength =
+                             cpu_to_le16(sizeof(struct ntlmv2_resp) +
+                                             ses->tilen);
                       /* we never did allocate ses->domainName to free */
                       kfree(ses->tiblob);

fs/cifs/sess.c ssetup_ntlmssp_authenticate: · line 769

Quoted 10 lines
fs/cifs/sess.c +4 -1
                       ses->tiblob = NULL;
                       ses->tilen = 0;
-             }
+             } else
+                     pSMB->req_no_secext.CaseSensitivePasswordLength =
+                             cpu_to_le16(sizeof(struct ntlmv2_resp));
+
               if (ses->capabilities & CAP_UNICODE) {
                       if (iov[0].iov_len % 2) {
                               *bcc_ptr = 0;

Looks reasonable, but I think it would be clearer to just have a single place that sets CaseSensitivePasswordLength. If ses->tilen > 0, then you add the tilen to it...but tilen will never be less than 0, so there's no need to have this inside that if block, right?

Quoted 3 lines

--
Jeff Layton <[email protected]>

I think the patch may be fine just the way it is. If the field already has little endian value,
it may be an extra code to convert exiting value, add tilen, and store back little endian
encoded value. That was my original thought behind this code.

A message that is not in the archive (sent off-list or not yet received): AANLkTimKnOy1fiXkALOf7rthiR4YHYjGg+iaswg=kSaO-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#7 lore raw
Quoted 59 lines · On Mon, 4 Oct 2010 18:08:24 -0500 Shirish Pargaonkar…
Quoted 54 lines · Jeff Layton
Quoted 35 lines · On Wed, 29 Sep 2010 09:38:48 -0500 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Fix incorrect calculation of case sensitive response length in the ntlmv2 (without extended security) response.

---
 fs/cifs/sess.c |   11 +++++++----

 1 files changed, 7 insertions(+), 4 deletions(-)
fs/cifs/sess.c +3 -3
index af18a50..9148fd8 100644
@@ -739,9 +739,6 @@ ssetup_ntlmssp_authenticate:
               pSMB->req_no_secext.CaseInsensitivePasswordLength = 0;
               /*      cpu_to_le16(LM2_SESS_KEY_SIZE); */
 
-             pSMB->req_no_secext.CaseSensitivePasswordLength =
-                     cpu_to_le16(sizeof(struct ntlmv2_resp));
-
               /* calculate session key */
               rc = setup_ntlmv2_rsp(ses, v2_sess_key, nls_cp);
               if (rc) {
@@ -756,11 +753,17 @@ ssetup_ntlmssp_authenticate:
               if (ses->tilen > 0) {
                       memcpy(bcc_ptr, ses->tiblob, ses->tilen);
                       bcc_ptr += ses->tilen;
+                     pSMB->req_no_secext.CaseSensitivePasswordLength =
+                             cpu_to_le16(sizeof(struct ntlmv2_resp) +
+                                             ses->tilen);
                       /* we never did allocate ses->domainName to free */
                       kfree(ses->tiblob);

fs/cifs/sess.c ssetup_ntlmssp_authenticate: · line 769

Quoted 10 lines
fs/cifs/sess.c +4 -1
                       ses->tiblob = NULL;
                       ses->tilen = 0;
-             }
+             } else
+                     pSMB->req_no_secext.CaseSensitivePasswordLength =
+                             cpu_to_le16(sizeof(struct ntlmv2_resp));
+
               if (ses->capabilities & CAP_UNICODE) {
                       if (iov[0].iov_len % 2) {
                               *bcc_ptr = 0;

Looks reasonable, but I think it would be clearer to just have a single place that sets CaseSensitivePasswordLength. If ses->tilen > 0, then you add the tilen to it...but tilen will never be less than 0, so there's no need to have this inside that if block, right?

Quoted 3 lines

--
Jeff Layton <[email protected]>

Quoted 5 lines

I think the patch may be fine just the way it is. If the field already has little endian value,
it may be an extra code to convert exiting value, add tilen, and store back little endian
encoded value. That was my original thought behind this code.

I'm not sure I follow your logic. I was just saying that you could move the setting of CaseSensitivePasswordLength outside of that if block altogether and eliminate the else clause. That makes the code more compact and readable.

For instance:

	pSMB->req_no_secext.CaseSensitivePasswordLength =
			cpu_to_le16(sizeof(struct ntlmv2_resp) + ses->tilen);
	if (ses->tilen > 0) {
		...etc...
	}

The else clause just exists for when ses->tilen == 0, so there's no need for an else clause there.

Signature · 1 line
Jeff Layton <[email protected]>