Skip to contentSkip to conversation

cifs: fix broken lanman (lm) auth code

PATCH In review [email protected] 3 participants 11 messages Feb 15, 2011 – Feb 16, 2011 7 messages not in the archive

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

PATCH 1/1 cifs: fix broken lanman (lm) auth code

From: Shirish Pargaonkar <[email protected]>

Fix lanman (lm) authentication code.

Change lm response length back to 24 from 16.
Parse lanmani mount option.
Add code to add odd parity bit to each of the eight bytes of a DES key.

---
 fs/cifs/cifsglob.h |    3 ++-
 fs/cifs/connect.c  |    3 +++
 fs/cifs/sess.c     |    8 ++++----
 fs/cifs/smbdes.c   |   19 ++++++++++++++++++-
 4 files changed, 27 insertions(+), 6 deletions(-)
fs/cifs/cifsglob.h +2 -1
index 17afb0f..0b5c950 100644
@@ -710,7 +710,8 @@ require use of the stronger protocol */
 #define   CIFSSEC_MUST_SEAL	0x40040 /* not supported yet */
 #define   CIFSSEC_MUST_NTLMSSP	0x80080 /* raw ntlmssp with ntlmv2 */
 
-#define   CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
+#define   CIFSSEC_DEF (CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_SIGN | \
+			CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
 #define   CIFSSEC_MAX (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2)
 #define   CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5 | CIFSSEC_MAY_NTLMSSP)
 /*
fs/cifs/connect.c +3 -0
index 8d6c17a..e3494df 100644
@@ -1014,6 +1014,9 @@ cifs_parse_mount_options(char *options, const char *devname,
 				/* BB is there a better way to do this? */
 				vol->secFlg |= CIFSSEC_MAY_NTLMV2;
 #ifdef CONFIG_CIFS_WEAK_PW_HASH
+			} else if (strnicmp(value, "lanmani", 7) == 0) {
+				vol->secFlg |= CIFSSEC_MAY_LANMAN |
+					CIFSSEC_MUST_SIGN;
 			} else if (strnicmp(value, "lanman", 6) == 0) {
 				vol->secFlg |= CIFSSEC_MAY_LANMAN;
 #endif
fs/cifs/sess.c +4 -4
index 1adc962..1676570 100644
@@ -656,13 +656,13 @@ ssetup_ntlmssp_authenticate:
 
 	if (type == LANMAN) {
 #ifdef CONFIG_CIFS_WEAK_PW_HASH
-		char lnm_session_key[CIFS_SESS_KEY_SIZE];
+		char lnm_session_key[CIFS_AUTH_RESP_SIZE];
 
 		pSMB->req.hdr.Flags2 &= ~SMBFLG2_UNICODE;
 
 		/* no capabilities flags in old lanman negotiation */
 
-		pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE);
+		pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_AUTH_RESP_SIZE);
 
 		/* Calculate hash with password and copy into bcc_ptr.
 		 * Encryption Key (stored as in cryptkey) gets used if the
@@ -675,8 +675,8 @@ ssetup_ntlmssp_authenticate:
 					true : false, lnm_session_key);
 
 		ses->flags |= CIFS_SES_LANMAN;
-		memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_SESS_KEY_SIZE);
-		bcc_ptr += CIFS_SESS_KEY_SIZE;
+		memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_AUTH_RESP_SIZE);
+		bcc_ptr += CIFS_AUTH_RESP_SIZE;
 
 		/* can not sign if LANMAN negotiated so no need
 		to calculate signing key? but what if server
fs/cifs/smbdes.c +18 -1
index 0472148..dcfc379 100644
@@ -299,6 +299,20 @@ dohash(char *out, char *in, char *key, int forw)
 	kfree(ki);
 }
 
+static int
+odd_parity(unsigned char c)
+{
+	int i;
+	int val = 0x80;
+	int count = 0;
+
+	for (i = 0; i < 7; ++i)
+		if (c & (val >> i))
+			++count;
+
+	return count % 2;
+}
+
 static void
 str_to_key(unsigned char *str, unsigned char *key)
 {
@@ -312,8 +326,11 @@ str_to_key(unsigned char *str, unsigned char *key)
 	key[5] = ((str[4] & 0x1F) << 2) | (str[5] >> 6);
 	key[6] = ((str[5] & 0x3F) << 1) | (str[6] >> 7);
 	key[7] = str[6] & 0x7F;
-	for (i = 0; i < 8; i++)
+	for (i = 0; i < 8; i++) {
 		key[i] = (key[i] << 1);
+		if (!odd_parity(key[i]))
+			key[i] |= 0x1;
+	}
 }
 
 static void
Signature · 1 line
1.6.0.2

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

#2 lore raw

This is a candidate for merge late in this cycle - so any "tested-by" or "reviewed-by" would be appreciated to help decide whether to include it this late.

Quoted 119 lines · On Tue, Feb 15, 2011 at 5:10 PM, <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Fix lanman (lm) authentication code.

Change lm response length back to 24 from 16.
Parse lanmani mount option.
Add code to add odd parity bit to each of the eight bytes of a DES key.

---
 fs/cifs/cifsglob.h |    3 ++-
 fs/cifs/connect.c  |    3 +++
 fs/cifs/sess.c     |    8 ++++----
 fs/cifs/smbdes.c   |   19 ++++++++++++++++++-

 4 files changed, 27 insertions(+), 6 deletions(-)
fs/cifs/cifsglob.h +2 -1
index 17afb0f..0b5c950 100644
@@ -710,7 +710,8 @@ require use of the stronger protocol */
  #define   CIFSSEC_MUST_SEAL    0x40040 /* not supported yet */
  #define   CIFSSEC_MUST_NTLMSSP 0x80080 /* raw ntlmssp with ntlmv2 */
 
-#define   CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
+#define   CIFSSEC_DEF (CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_SIGN | \
+                       CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
  #define   CIFSSEC_MAX (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2)
  #define   CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5 | CIFSSEC_MAY_NTLMSSP)
  /*
fs/cifs/connect.c +3 -0
index 8d6c17a..e3494df 100644
@@ -1014,6 +1014,9 @@ cifs_parse_mount_options(char *options, const char *devname,
                                /* BB is there a better way to do this? */
                                vol->secFlg |= CIFSSEC_MAY_NTLMV2;
  #ifdef CONFIG_CIFS_WEAK_PW_HASH
+                       } else if (strnicmp(value, "lanmani", 7) == 0) {
+                               vol->secFlg |= CIFSSEC_MAY_LANMAN |
+                                       CIFSSEC_MUST_SIGN;
                        } else if (strnicmp(value, "lanman", 6) == 0) {
                                vol->secFlg |= CIFSSEC_MAY_LANMAN;
  #endif
fs/cifs/sess.c +4 -4
index 1adc962..1676570 100644
@@ -656,13 +656,13 @@ ssetup_ntlmssp_authenticate:
 
        if (type == LANMAN) {
  #ifdef CONFIG_CIFS_WEAK_PW_HASH
-               char lnm_session_key[CIFS_SESS_KEY_SIZE];
+               char lnm_session_key[CIFS_AUTH_RESP_SIZE];
 
                pSMB->req.hdr.Flags2 &= ~SMBFLG2_UNICODE;
 
                /* no capabilities flags in old lanman negotiation */
 
-               pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE);
+               pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_AUTH_RESP_SIZE);
 
                /* Calculate hash with password and copy into bcc_ptr.
                 * Encryption Key (stored as in cryptkey) gets used if the
@@ -675,8 +675,8 @@ ssetup_ntlmssp_authenticate:
                                        true : false, lnm_session_key);
 
                ses->flags |= CIFS_SES_LANMAN;
-               memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_SESS_KEY_SIZE);
-               bcc_ptr += CIFS_SESS_KEY_SIZE;
+               memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_AUTH_RESP_SIZE);
+               bcc_ptr += CIFS_AUTH_RESP_SIZE;
 
                /* can not sign if LANMAN negotiated so no need

               to calculate signing key? but what if server

fs/cifs/smbdes.c +14 -0
index 0472148..dcfc379 100644
@@ -299,6 +299,20 @@ dohash(char *out, char *in, char *key, int forw)
        kfree(ki);
  }
 
+static int
+odd_parity(unsigned char c)
+{
+       int i;
+       int val = 0x80;
+       int count = 0;
+
+       for (i = 0; i < 7; ++i)
+               if (c & (val >> i))
+                       ++count;
+
+       return count % 2;
+}
+

 static void
 str_to_key(unsigned char *str, unsigned char *key) {

fs/cifs/smbdes.c +4 -1
@@ -312,8 +326,11 @@ str_to_key(unsigned char *str, unsigned char *key)
        key[5] = ((str[4] & 0x1F) << 2) | (str[5] >> 6);
        key[6] = ((str[5] & 0x3F) << 1) | (str[6] >> 7);
        key[7] = str[6] & 0x7F;
-       for (i = 0; i < 8; i++)
+       for (i = 0; i < 8; i++) {
                key[i] = (key[i] << 1);
+               if (!odd_parity(key[i]))
+                       key[i] |= 0x1;
+       }
  }
 

 static void
--
1.6.0.2

Signature · 3 lines
Thanks,

Steve
#3 lore raw
In reply to a message not in the archive
Quoted 23 lines · On Tue, 15 Feb 2011 17:10:43 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Fix lanman (lm) authentication code.

Change lm response length back to 24 from 16.
Parse lanmani mount option.
Add code to add odd parity bit to each of the eight bytes of a DES key.

---
 fs/cifs/cifsglob.h |    3 ++-
 fs/cifs/connect.c  |    3 +++
 fs/cifs/sess.c     |    8 ++++----
 fs/cifs/smbdes.c   |   19 ++++++++++++++++++-
 4 files changed, 27 insertions(+), 6 deletions(-)
fs/cifs/cifsglob.h +0 -0
index 17afb0f..0b5c950 100644

fs/cifs/cifsglob.h require use of the stronger protocol */ · line 714

Quoted 6 lines
fs/cifs/cifsglob.h +2 -1
@@ -710,7 +710,8 @@ require use of the stronger protocol */
 #define   CIFSSEC_MUST_SEAL	0x40040 /* not supported yet */
 #define   CIFSSEC_MUST_NTLMSSP	0x80080 /* raw ntlmssp with ntlmv2 */
 
-#define   CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
+#define   CIFSSEC_DEF (CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_SIGN | \
+			CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
			^^^^^^^^^^^
	Won't this change enable lanman auth by default? Is that
	intended?
Quoted 86 lines
fs/cifs/cifsglob.h +0 -0
 #define   CIFSSEC_MAX (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2)
 #define   CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5 | CIFSSEC_MAY_NTLMSSP)
 /*
fs/cifs/connect.c +3 -0
index 8d6c17a..e3494df 100644
@@ -1014,6 +1014,9 @@ cifs_parse_mount_options(char *options, const char *devname,
 				/* BB is there a better way to do this? */
 				vol->secFlg |= CIFSSEC_MAY_NTLMV2;
 #ifdef CONFIG_CIFS_WEAK_PW_HASH
+			} else if (strnicmp(value, "lanmani", 7) == 0) {
+				vol->secFlg |= CIFSSEC_MAY_LANMAN |
+					CIFSSEC_MUST_SIGN;
 			} else if (strnicmp(value, "lanman", 6) == 0) {
 				vol->secFlg |= CIFSSEC_MAY_LANMAN;
 #endif
fs/cifs/sess.c +4 -4
index 1adc962..1676570 100644
@@ -656,13 +656,13 @@ ssetup_ntlmssp_authenticate:
 
 	if (type == LANMAN) {
 #ifdef CONFIG_CIFS_WEAK_PW_HASH
-		char lnm_session_key[CIFS_SESS_KEY_SIZE];
+		char lnm_session_key[CIFS_AUTH_RESP_SIZE];
 
 		pSMB->req.hdr.Flags2 &= ~SMBFLG2_UNICODE;
 
 		/* no capabilities flags in old lanman negotiation */
 
-		pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE);
+		pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_AUTH_RESP_SIZE);
 
 		/* Calculate hash with password and copy into bcc_ptr.
 		 * Encryption Key (stored as in cryptkey) gets used if the
@@ -675,8 +675,8 @@ ssetup_ntlmssp_authenticate:
 					true : false, lnm_session_key);
 
 		ses->flags |= CIFS_SES_LANMAN;
-		memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_SESS_KEY_SIZE);
-		bcc_ptr += CIFS_SESS_KEY_SIZE;
+		memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_AUTH_RESP_SIZE);
+		bcc_ptr += CIFS_AUTH_RESP_SIZE;
 
 		/* can not sign if LANMAN negotiated so no need
 		to calculate signing key? but what if server
fs/cifs/smbdes.c +18 -1
index 0472148..dcfc379 100644
@@ -299,6 +299,20 @@ dohash(char *out, char *in, char *key, int forw)
 	kfree(ki);
 }
 
+static int
+odd_parity(unsigned char c)
+{
+	int i;
+	int val = 0x80;
+	int count = 0;
+
+	for (i = 0; i < 7; ++i)
+		if (c & (val >> i))
+			++count;
+
+	return count % 2;
+}
+
 static void
 str_to_key(unsigned char *str, unsigned char *key)
 {
@@ -312,8 +326,11 @@ str_to_key(unsigned char *str, unsigned char *key)
 	key[5] = ((str[4] & 0x1F) << 2) | (str[5] >> 6);
 	key[6] = ((str[5] & 0x3F) << 1) | (str[6] >> 7);
 	key[7] = str[6] & 0x7F;
-	for (i = 0; i < 8; i++)
+	for (i = 0; i < 8; i++) {
 		key[i] = (key[i] << 1);
+		if (!odd_parity(key[i]))
+			key[i] |= 0x1;
+	}
 }
 
 static void
Signature · 1 line
Jeff Layton <[email protected]>

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

#5 lore raw
Quoted 29 lines · Jeff Layton
Quoted 26 lines · On Tue, 15 Feb 2011 17:10:43 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Fix lanman (lm) authentication code.

Change lm response length back to 24 from 16.
Parse lanmani mount option.
Add code to add odd parity bit to each of the eight bytes of a DES key.

---
 fs/cifs/cifsglob.h |    3 ++-
 fs/cifs/connect.c  |    3 +++
 fs/cifs/sess.c     |    8 ++++----
 fs/cifs/smbdes.c   |   19 ++++++++++++++++++-

 4 files changed, 27 insertions(+), 6 deletions(-)
fs/cifs/cifsglob.h +0 -0
index 17afb0f..0b5c950 100644
@@ -710,7 +710,8 @@ require use of the stronger protocol */
  #define   CIFSSEC_MUST_SEAL  0x40040 /* not supported yet */
  #define   CIFSSEC_MUST_NTLMSSP       0x80080 /* raw ntlmssp with ntlmv2 */
 
Quoted 6 lines

fs/cifs/cifsglob.h require use of the stronger protocol */ · line 714

Quoted 3 lines
fs/cifs/cifsglob.h +2 -1
-#define   CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
+#define   CIFSSEC_DEF (CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_SIGN | \
+                     CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)

                       ^^^^^^^^^^^
       Won't this change enable lanman auth by default? Is that intended?

I think it depends on what server sends in negprot response, the minimun dialect it supports.
If the dialect is greater than Lanman2.1, the default auth mech for cifs client is NTLM (ntlmv1)
if the dialect is less than or upto Lanman2.1, default auth mech for cifs client is LANMAN (lm).

Quoted 92 lines
Quoted 86 lines
fs/cifs/cifsglob.h +0 -0
  #define   CIFSSEC_MAX (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2)
  #define   CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5 | CIFSSEC_MAY_NTLMSSP)
  /*
fs/cifs/connect.c +3 -0
index 8d6c17a..e3494df 100644
@@ -1014,6 +1014,9 @@ cifs_parse_mount_options(char *options, const char *devname,
                               /* BB is there a better way to do this? */
                               vol->secFlg |= CIFSSEC_MAY_NTLMV2;
  #ifdef CONFIG_CIFS_WEAK_PW_HASH
+                     } else if (strnicmp(value, "lanmani", 7) == 0) {
+                             vol->secFlg |= CIFSSEC_MAY_LANMAN |
+                                     CIFSSEC_MUST_SIGN;
                       } else if (strnicmp(value, "lanman", 6) == 0) {
                               vol->secFlg |= CIFSSEC_MAY_LANMAN;
  #endif
fs/cifs/sess.c +4 -4
index 1adc962..1676570 100644
@@ -656,13 +656,13 @@ ssetup_ntlmssp_authenticate:
 
       if (type == LANMAN) {
  #ifdef CONFIG_CIFS_WEAK_PW_HASH
-             char lnm_session_key[CIFS_SESS_KEY_SIZE];
+             char lnm_session_key[CIFS_AUTH_RESP_SIZE];
 
               pSMB->req.hdr.Flags2 &= ~SMBFLG2_UNICODE;
 
               /* no capabilities flags in old lanman negotiation */
 
-             pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE);
+             pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_AUTH_RESP_SIZE);
 
               /* Calculate hash with password and copy into bcc_ptr.
                * Encryption Key (stored as in cryptkey) gets used if the
@@ -675,8 +675,8 @@ ssetup_ntlmssp_authenticate:
                                       true : false, lnm_session_key);
 
               ses->flags |= CIFS_SES_LANMAN;
-             memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_SESS_KEY_SIZE);
-             bcc_ptr += CIFS_SESS_KEY_SIZE;
+             memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_AUTH_RESP_SIZE);
+             bcc_ptr += CIFS_AUTH_RESP_SIZE;
 
               /* can not sign if LANMAN negotiated so no need

              to calculate signing key? but what if server

fs/cifs/smbdes.c +14 -0
index 0472148..dcfc379 100644
@@ -299,6 +299,20 @@ dohash(char *out, char *in, char *key, int forw)
       kfree(ki);
  }
 
+static int
+odd_parity(unsigned char c)
+{
+     int i;
+     int val = 0x80;
+     int count = 0;
+
+     for (i = 0; i < 7; ++i)
+             if (c & (val >> i))
+                     ++count;
+
+     return count % 2;
+}
+

 static void
 str_to_key(unsigned char *str, unsigned char *key) {

fs/cifs/smbdes.c +4 -1
@@ -312,8 +326,11 @@ str_to_key(unsigned char *str, unsigned char *key)
       key[5] = ((str[4] & 0x1F) << 2) | (str[5] >> 6);
       key[6] = ((str[5] & 0x3F) << 1) | (str[6] >> 7);
       key[7] = str[6] & 0x7F;
-     for (i = 0; i < 8; i++)
+     for (i = 0; i < 8; i++) {
               key[i] = (key[i] << 1);
+             if (!odd_parity(key[i]))
+                     key[i] |= 0x1;
+     }
  }
 
Quoted 1 line

 static void

--
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): AANLkTinVM2j9kVjreWy+Tk6VFONTo=zEj=s1k-07YViF-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#7 lore raw
Quoted 37 lines · On Wed, 16 Feb 2011 08:46:03 -0600 Shirish Pargaonkar…
Quoted 29 lines · Jeff Layton
Quoted 26 lines · On Tue, 15 Feb 2011 17:10:43 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Fix lanman (lm) authentication code.

Change lm response length back to 24 from 16.
Parse lanmani mount option.
Add code to add odd parity bit to each of the eight bytes of a DES key.

---
 fs/cifs/cifsglob.h |    3 ++-
 fs/cifs/connect.c  |    3 +++
 fs/cifs/sess.c     |    8 ++++----
 fs/cifs/smbdes.c   |   19 ++++++++++++++++++-

 4 files changed, 27 insertions(+), 6 deletions(-)
fs/cifs/cifsglob.h +0 -0
index 17afb0f..0b5c950 100644
@@ -710,7 +710,8 @@ require use of the stronger protocol */
  #define   CIFSSEC_MUST_SEAL  0x40040 /* not supported yet */
  #define   CIFSSEC_MUST_NTLMSSP       0x80080 /* raw ntlmssp with ntlmv2 */
 
Quoted 6 lines

fs/cifs/cifsglob.h require use of the stronger protocol */ · line 714

Quoted 3 lines
fs/cifs/cifsglob.h +2 -1
-#define   CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
+#define   CIFSSEC_DEF (CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_SIGN | \
+                     CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)

                       ^^^^^^^^^^^
       Won't this change enable lanman auth by default? Is that intended?

Quoted 7 lines

I think it depends on what server sends in negprot response, the minimun dialect it supports.
If the dialect is greater than Lanman2.1, the default auth mech for cifs client is NTLM (ntlmv1)
if the dialect is less than or upto Lanman2.1, default auth mech for cifs client is LANMAN (lm).

Historically we've required that the admin
set /proc/fs/cifs/SecurityFlags to allow LANMAN auth before the client will allow it to be used. I'm not opposed to changing that, but the description doesn't even mention anything about that.

I think this ought to be a separate patch with a clearly described reason, and probably doesn't belong in 2.6.38. It doesn't seem like it's necessary to fix this bug.

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

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

#9 lore raw
Quoted 53 lines · Jeff Layton
Quoted 37 lines · On Wed, 16 Feb 2011 08:46:03 -0600 Shirish Pargaonkar…
Quoted 29 lines · Jeff Layton
Quoted 26 lines · On Tue, 15 Feb 2011 17:10:43 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Fix lanman (lm) authentication code.

Change lm response length back to 24 from 16.
Parse lanmani mount option.
Add code to add odd parity bit to each of the eight bytes of a DES key.

---
 fs/cifs/cifsglob.h |    3 ++-
 fs/cifs/connect.c  |    3 +++
 fs/cifs/sess.c     |    8 ++++----
 fs/cifs/smbdes.c   |   19 ++++++++++++++++++-

 4 files changed, 27 insertions(+), 6 deletions(-)
fs/cifs/cifsglob.h +0 -0
index 17afb0f..0b5c950 100644
@@ -710,7 +710,8 @@ require use of the stronger protocol */
  #define   CIFSSEC_MUST_SEAL  0x40040 /* not supported yet */
  #define   CIFSSEC_MUST_NTLMSSP       0x80080 /* raw ntlmssp with ntlmv2 */
 
Quoted 6 lines

fs/cifs/cifsglob.h require use of the stronger protocol */ · line 714

Quoted 3 lines
fs/cifs/cifsglob.h +2 -1
-#define   CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
+#define   CIFSSEC_DEF (CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_SIGN | \
+                     CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)

                       ^^^^^^^^^^^
       Won't this change enable lanman auth by default? Is that intended?

Quoted 7 lines

I think it depends on what server sends in negprot response, the minimun dialect it supports.
If the dialect is greater than Lanman2.1, the default auth mech for cifs client is NTLM (ntlmv1)
if the dialect is less than or upto Lanman2.1, default auth mech for cifs client is LANMAN (lm).

Historically we've required that the admin
set /proc/fs/cifs/SecurityFlags to allow LANMAN auth before the client will allow it to be used. I'm not opposed to changing that, but the description doesn't even mention anything about that.

Quoted 7 lines

I think this ought to be a separate patch with a clearly described reason, and probably doesn't belong in 2.6.38. It doesn't seem like it's necessary to fix this bug.

--
Jeff Layton <[email protected]>

I think that is still the case. If we do not have the code, we will get error
CIFS VFS: mount failed weak security disabled in /proc/fs/cifs/SecurityFlags
and auth will fail even if admin did necessary to allow LANMAN.

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

#11 lore raw
Quoted 58 lines · On Wed, 16 Feb 2011 09:06:08 -0600 Shirish Pargaonkar…
Quoted 57 lines · Jeff Layton
Quoted 37 lines · On Wed, 16 Feb 2011 08:46:03 -0600 Shirish Pargaonkar…
Quoted 29 lines · Jeff Layton
Quoted 26 lines · On Tue, 15 Feb 2011 17:10:43 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Fix lanman (lm) authentication code.

Change lm response length back to 24 from 16.
Parse lanmani mount option.
Add code to add odd parity bit to each of the eight bytes of a DES key.

---
 fs/cifs/cifsglob.h |    3 ++-
 fs/cifs/connect.c  |    3 +++
 fs/cifs/sess.c     |    8 ++++----
 fs/cifs/smbdes.c   |   19 ++++++++++++++++++-

 4 files changed, 27 insertions(+), 6 deletions(-)
fs/cifs/cifsglob.h +0 -0
index 17afb0f..0b5c950 100644
@@ -710,7 +710,8 @@ require use of the stronger protocol */
  #define   CIFSSEC_MUST_SEAL  0x40040 /* not supported yet */
  #define   CIFSSEC_MUST_NTLMSSP       0x80080 /* raw ntlmssp with ntlmv2 */
 
Quoted 6 lines

fs/cifs/cifsglob.h require use of the stronger protocol */ · line 714

Quoted 3 lines
fs/cifs/cifsglob.h +2 -1
-#define   CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
+#define   CIFSSEC_DEF (CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_SIGN | \
+                     CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)

                       ^^^^^^^^^^^
       Won't this change enable lanman auth by default? Is that intended?

Quoted 7 lines

I think it depends on what server sends in negprot response, the minimun dialect it supports.
If the dialect is greater than Lanman2.1, the default auth mech for cifs client is NTLM (ntlmv1)
if the dialect is less than or upto Lanman2.1, default auth mech for cifs client is LANMAN (lm).

Historically we've required that the admin
set /proc/fs/cifs/SecurityFlags to allow LANMAN auth before the client will allow it to be used. I'm not opposed to changing that, but the description doesn't even mention anything about that.

I think this ought to be a separate patch with a clearly described reason, and probably doesn't belong in 2.6.38. It doesn't seem like it's necessary to fix this bug.

Quoted 7 lines
Quoted 3 lines

--
Jeff Layton <[email protected]>

I think that is still the case. If we do not have the code, we will get error
CIFS VFS: mount failed weak security disabled in /proc/fs/cifs/SecurityFlags
and auth will fail even if admin did necessary to allow LANMAN.

For the record, I'm of the opinion that this secFlags stuff is far too convoluted for anyone's good. It's horribly confusing. I don't think what you're saying is the case however:

...global_secflags is initialized to CIFSSEC_DEF:

	unsigned int global_secflags = CIFSSEC_DEF;

...then, if ses->overrideSecFlg is not set (which is the case if no sec= option is set):

        /* if any of auth flags (ie not sign or seal) are overriden use them */
        if (ses->overrideSecFlg & (~(CIFSSEC_MUST_SIGN | CIFSSEC_MUST_SEAL)))
                secFlags = ses->overrideSecFlg;  /* BB FIXME fix sign flags? */
        else /* if override flags set only sign/seal OR them with global auth */
                secFlags = global_secflags | ses->overrideSecFlg;

...now, secFlags ends up being global_secflags plus some optional sign/seal flags. Then later:

                if ((secFlags & CIFSSEC_MAY_LANMAN) ||
                        (secFlags & CIFSSEC_MAY_PLNTXT))
                        server->secType = LANMAN;
                else {
                        cERROR(1, "mount failed weak security disabled"
                                   " in /proc/fs/cifs/SecurityFlags");
                        rc = -EOPNOTSUPP;
                        goto neg_err_exit;
                }

...so, because CIFSSEC_MAY_LANMAN is now set by default, we'll not fall into the else condition above and the mount will work by default when it would have failed before, right? So the default behavior has changed...or am I missing something?

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

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

#13 lore raw
Quoted 100 lines · Jeff Layton
Quoted 58 lines · On Wed, 16 Feb 2011 09:06:08 -0600 Shirish Pargaonkar…
Quoted 57 lines · Jeff Layton
Quoted 37 lines · On Wed, 16 Feb 2011 08:46:03 -0600 Shirish Pargaonkar…
Quoted 29 lines · Jeff Layton
Quoted 26 lines · On Tue, 15 Feb 2011 17:10:43 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Fix lanman (lm) authentication code.

Change lm response length back to 24 from 16.
Parse lanmani mount option.
Add code to add odd parity bit to each of the eight bytes of a DES key.

---
 fs/cifs/cifsglob.h |    3 ++-
 fs/cifs/connect.c  |    3 +++
 fs/cifs/sess.c     |    8 ++++----
 fs/cifs/smbdes.c   |   19 ++++++++++++++++++-

 4 files changed, 27 insertions(+), 6 deletions(-)
fs/cifs/cifsglob.h +0 -0
index 17afb0f..0b5c950 100644
@@ -710,7 +710,8 @@ require use of the stronger protocol */
  #define   CIFSSEC_MUST_SEAL  0x40040 /* not supported yet */
  #define   CIFSSEC_MUST_NTLMSSP       0x80080 /* raw ntlmssp with ntlmv2 */
 
Quoted 6 lines

fs/cifs/cifsglob.h require use of the stronger protocol */ · line 714

Quoted 3 lines
fs/cifs/cifsglob.h +2 -1
-#define   CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
+#define   CIFSSEC_DEF (CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_SIGN | \
+                     CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)

                       ^^^^^^^^^^^
       Won't this change enable lanman auth by default? Is that intended?

Quoted 7 lines

I think it depends on what server sends in negprot response, the minimun dialect it supports.
If the dialect is greater than Lanman2.1, the default auth mech for cifs client is NTLM (ntlmv1)
if the dialect is less than or upto Lanman2.1, default auth mech for cifs client is LANMAN (lm).

Historically we've required that the admin
set /proc/fs/cifs/SecurityFlags to allow LANMAN auth before the client will allow it to be used. I'm not opposed to changing that, but the description doesn't even mention anything about that.

I think this ought to be a separate patch with a clearly described reason, and probably doesn't belong in 2.6.38. It doesn't seem like it's necessary to fix this bug.

Quoted 7 lines
Quoted 3 lines

--
Jeff Layton <[email protected]>

I think that is still the case.  If we do not have the code,  we will get error CIFS VFS: mount failed weak security disabled in /proc/fs/cifs/SecurityFlags and auth will fail even if admin did necessary to allow LANMAN.

For the record, I'm of the opinion that this secFlags stuff is far too convoluted for anyone's good. It's horribly confusing. I don't think what you're saying is the case however:

...global_secflags is initialized to CIFSSEC_DEF:

       unsigned int global_secflags = CIFSSEC_DEF;

...then, if ses->overrideSecFlg is not set (which is the case if no sec= option is set):

       /* if any of auth flags (ie not sign or seal) are overriden use them */ if (ses->overrideSecFlg & (~(CIFSSEC_MUST_SIGN | CIFSSEC_MUST_SEAL))) secFlags = ses->overrideSecFlg;  /* BB FIXME fix sign flags? */ else /* if override flags set only sign/seal OR them with global auth */ secFlags = global_secflags | ses->overrideSecFlg;

...now, secFlags ends up being global_secflags plus some optional sign/seal flags. Then later:

               if ((secFlags & CIFSSEC_MAY_LANMAN) || (secFlags & CIFSSEC_MAY_PLNTXT)) server->secType = LANMAN;
               else {
                       cERROR(1, "mount failed weak security disabled" " in /proc/fs/cifs/SecurityFlags"); rc = -EOPNOTSUPP;
                       goto neg_err_exit;
               }

Quoted 8 lines

...so, because CIFSSEC_MAY_LANMAN is now set by default, we'll not fall into the else condition above and the mount will work by default when it would have failed before, right? So the default behavior has changed...or am I missing something?

--
Jeff Layton <[email protected]>

Jeff, I am saying I will undo the change in cifsglob.h that is submitted in this patch.
With definition of CIFSSEC_DEF unchagned, all I will be fixing is allowing lanmani
mount option and proper lm authentication (if admin allow lm auth in /proc/fs/cifs/SecurityFlags.
So I would not be changing default behaviour as it exists right now.

A message that is not in the archive (sent off-list or not yet received): AANLkTikXabGo1kVeUZS430A0iawk5z0arkc-SrCW-hiR-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#15 lore raw
Quoted 110 lines · On Wed, 16 Feb 2011 09:27:28 -0600 Shirish Pargaonkar…
Quoted 100 lines · Jeff Layton
Quoted 58 lines · On Wed, 16 Feb 2011 09:06:08 -0600 Shirish Pargaonkar…
Quoted 57 lines · Jeff Layton
Quoted 37 lines · On Wed, 16 Feb 2011 08:46:03 -0600 Shirish Pargaonkar…
Quoted 29 lines · Jeff Layton
Quoted 26 lines · On Tue, 15 Feb 2011 17:10:43 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Fix lanman (lm) authentication code.

Change lm response length back to 24 from 16.
Parse lanmani mount option.
Add code to add odd parity bit to each of the eight bytes of a DES key.

---
 fs/cifs/cifsglob.h |    3 ++-
 fs/cifs/connect.c  |    3 +++
 fs/cifs/sess.c     |    8 ++++----
 fs/cifs/smbdes.c   |   19 ++++++++++++++++++-

 4 files changed, 27 insertions(+), 6 deletions(-)
fs/cifs/cifsglob.h +0 -0
index 17afb0f..0b5c950 100644
@@ -710,7 +710,8 @@ require use of the stronger protocol */
  #define   CIFSSEC_MUST_SEAL  0x40040 /* not supported yet */
  #define   CIFSSEC_MUST_NTLMSSP       0x80080 /* raw ntlmssp with ntlmv2 */
 
Quoted 6 lines

fs/cifs/cifsglob.h require use of the stronger protocol */ · line 714

Quoted 3 lines
fs/cifs/cifsglob.h +2 -1
-#define   CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
+#define   CIFSSEC_DEF (CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_SIGN | \
+                     CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)

                       ^^^^^^^^^^^
       Won't this change enable lanman auth by default? Is that intended?

Quoted 7 lines

I think it depends on what server sends in negprot response, the minimun dialect it supports.
If the dialect is greater than Lanman2.1, the default auth mech for cifs client is NTLM (ntlmv1)
if the dialect is less than or upto Lanman2.1, default auth mech for cifs client is LANMAN (lm).

Historically we've required that the admin
set /proc/fs/cifs/SecurityFlags to allow LANMAN auth before the client will allow it to be used. I'm not opposed to changing that, but the description doesn't even mention anything about that.

I think this ought to be a separate patch with a clearly described reason, and probably doesn't belong in 2.6.38. It doesn't seem like it's necessary to fix this bug.

Quoted 7 lines
Quoted 3 lines

--
Jeff Layton <[email protected]>

I think that is still the case.  If we do not have the code,  we will get error CIFS VFS: mount failed weak security disabled in /proc/fs/cifs/SecurityFlags and auth will fail even if admin did necessary to allow LANMAN.

For the record, I'm of the opinion that this secFlags stuff is far too convoluted for anyone's good. It's horribly confusing. I don't think what you're saying is the case however:

...global_secflags is initialized to CIFSSEC_DEF:

       unsigned int global_secflags = CIFSSEC_DEF;

...then, if ses->overrideSecFlg is not set (which is the case if no sec= option is set):

       /* if any of auth flags (ie not sign or seal) are overriden use them */ if (ses->overrideSecFlg & (~(CIFSSEC_MUST_SIGN | CIFSSEC_MUST_SEAL))) secFlags = ses->overrideSecFlg;  /* BB FIXME fix sign flags? */ else /* if override flags set only sign/seal OR them with global auth */ secFlags = global_secflags | ses->overrideSecFlg;

...now, secFlags ends up being global_secflags plus some optional sign/seal flags. Then later:

               if ((secFlags & CIFSSEC_MAY_LANMAN) || (secFlags & CIFSSEC_MAY_PLNTXT)) server->secType = LANMAN;
               else {
                       cERROR(1, "mount failed weak security disabled" " in /proc/fs/cifs/SecurityFlags"); rc = -EOPNOTSUPP;
                       goto neg_err_exit;
               }

Quoted 8 lines

...so, because CIFSSEC_MAY_LANMAN is now set by default, we'll not fall into the else condition above and the mount will work by default when it would have failed before, right? So the default behavior has changed...or am I missing something?

--
Jeff Layton <[email protected]>

Quoted 7 lines

Jeff, I am saying I will undo the change in cifsglob.h that is submitted in this patch.
With definition of CIFSSEC_DEF unchagned, all I will be fixing is allowing lanmani
mount option and proper lm authentication (if admin allow lm auth in /proc/fs/cifs/SecurityFlags.
So I would not be changing default behaviour as it exists right now.

Sorry about that -- our earlier replies crossed paths. I think that sounds like the best thing to do.

Signature · 1 line
Jeff Layton <[email protected]>
#16 lore raw
In reply to a message not in the archive
Quoted 110 lines · Shirish Pargaonkar
Quoted 100 lines · Jeff Layton
Quoted 58 lines · On Wed, 16 Feb 2011 09:06:08 -0600 Shirish Pargaonkar…
Quoted 57 lines · Jeff Layton
Quoted 37 lines · On Wed, 16 Feb 2011 08:46:03 -0600 Shirish Pargaonkar…
Quoted 29 lines · Jeff Layton
Quoted 26 lines · On Tue, 15 Feb 2011 17:10:43 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Fix lanman (lm) authentication code.

Change lm response length back to 24 from 16.
Parse lanmani mount option.
Add code to add odd parity bit to each of the eight bytes of a DES key.

---
 fs/cifs/cifsglob.h |    3 ++-
 fs/cifs/connect.c  |    3 +++
 fs/cifs/sess.c     |    8 ++++----
 fs/cifs/smbdes.c   |   19 ++++++++++++++++++-

 4 files changed, 27 insertions(+), 6 deletions(-)
fs/cifs/cifsglob.h +0 -0
index 17afb0f..0b5c950 100644
@@ -710,7 +710,8 @@ require use of the stronger protocol */
  #define   CIFSSEC_MUST_SEAL  0x40040 /* not supported yet */
  #define   CIFSSEC_MUST_NTLMSSP       0x80080 /* raw ntlmssp with ntlmv2 */
 
Quoted 6 lines

fs/cifs/cifsglob.h require use of the stronger protocol */ · line 714

Quoted 3 lines
fs/cifs/cifsglob.h +2 -1
-#define   CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
+#define   CIFSSEC_DEF (CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_SIGN | \
+                     CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)

                       ^^^^^^^^^^^
       Won't this change enable lanman auth by default? Is that intended?

Quoted 7 lines

I think it depends on what server sends in negprot response, the minimun dialect it supports.
If the dialect is greater than Lanman2.1, the default auth mech for cifs client is NTLM (ntlmv1)
if the dialect is less than or upto Lanman2.1, default auth mech for cifs client is LANMAN (lm).

Historically we've required that the admin
set /proc/fs/cifs/SecurityFlags to allow LANMAN auth before the client will allow it to be used. I'm not opposed to changing that, but the description doesn't even mention anything about that.

I think this ought to be a separate patch with a clearly described reason, and probably doesn't belong in 2.6.38. It doesn't seem like it's necessary to fix this bug.

Quoted 7 lines
Quoted 3 lines

--
Jeff Layton <[email protected]>

I think that is still the case.  If we do not have the code,  we will get error CIFS VFS: mount failed weak security disabled in /proc/fs/cifs/SecurityFlags and auth will fail even if admin did necessary to allow LANMAN.

For the record, I'm of the opinion that this secFlags stuff is far too convoluted for anyone's good. It's horribly confusing. I don't think what you're saying is the case however:

...global_secflags is initialized to CIFSSEC_DEF:

       unsigned int global_secflags = CIFSSEC_DEF;

...then, if ses->overrideSecFlg is not set (which is the case if no sec= option is set):

       /* if any of auth flags (ie not sign or seal) are overriden use them */ if (ses->overrideSecFlg & (~(CIFSSEC_MUST_SIGN | CIFSSEC_MUST_SEAL))) secFlags = ses->overrideSecFlg;  /* BB FIXME fix sign flags? */ else /* if override flags set only sign/seal OR them with global auth */ secFlags = global_secflags | ses->overrideSecFlg;

...now, secFlags ends up being global_secflags plus some optional sign/seal flags. Then later:

               if ((secFlags & CIFSSEC_MAY_LANMAN) || (secFlags & CIFSSEC_MAY_PLNTXT)) server->secType = LANMAN;
               else {
                       cERROR(1, "mount failed weak security disabled" " in /proc/fs/cifs/SecurityFlags"); rc = -EOPNOTSUPP;
                       goto neg_err_exit;
               }

Quoted 8 lines

...so, because CIFSSEC_MAY_LANMAN is now set by default, we'll not fall into the else condition above and the mount will work by default when it would have failed before, right? So the default behavior has changed...or am I missing something?

--
Jeff Layton <[email protected]>

Quoted 7 lines

Jeff, I am saying I will undo the change in cifsglob.h that is submitted in this patch.
With definition of CIFSSEC_DEF unchagned, all I will be fixing is allowing lanmani
mount option and proper lm authentication (if admin allow lm auth in /proc/fs/cifs/SecurityFlags.
So I would not be changing default behaviour as it exists right now.

Right - we do not want to enable very weak authentication by default.

Signature · 3 lines
Thanks,

Steve
#17 lore raw
In reply to a message not in the archive
Quoted 29 lines · Jeff Layton
Quoted 26 lines · On Tue, 15 Feb 2011 17:10:43 -0600 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Fix lanman (lm) authentication code.

Change lm response length back to 24 from 16.
Parse lanmani mount option.
Add code to add odd parity bit to each of the eight bytes of a DES key.

---
 fs/cifs/cifsglob.h |    3 ++-
 fs/cifs/connect.c  |    3 +++
 fs/cifs/sess.c     |    8 ++++----
 fs/cifs/smbdes.c   |   19 ++++++++++++++++++-

 4 files changed, 27 insertions(+), 6 deletions(-)
fs/cifs/cifsglob.h +0 -0
index 17afb0f..0b5c950 100644
@@ -710,7 +710,8 @@ require use of the stronger protocol */
  #define   CIFSSEC_MUST_SEAL  0x40040 /* not supported yet */
  #define   CIFSSEC_MUST_NTLMSSP       0x80080 /* raw ntlmssp with ntlmv2 */
 
Quoted 6 lines

fs/cifs/cifsglob.h require use of the stronger protocol */ · line 714

Quoted 3 lines
fs/cifs/cifsglob.h +2 -1
-#define   CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
+#define   CIFSSEC_DEF (CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_SIGN | \
+                     CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)

                       ^^^^^^^^^^^
       Won't this change enable lanman auth by default? Is that intended?

Jeff, I think you are right. I should take out this flag and let sysadmin add it
/proc/fs/cifs/SecurityFlags.

Let me repost rest of the change.

Quoted 92 lines
Quoted 86 lines
fs/cifs/cifsglob.h +0 -0
  #define   CIFSSEC_MAX (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2)
  #define   CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5 | CIFSSEC_MAY_NTLMSSP)
  /*
fs/cifs/connect.c +3 -0
index 8d6c17a..e3494df 100644
@@ -1014,6 +1014,9 @@ cifs_parse_mount_options(char *options, const char *devname,
                               /* BB is there a better way to do this? */
                               vol->secFlg |= CIFSSEC_MAY_NTLMV2;
  #ifdef CONFIG_CIFS_WEAK_PW_HASH
+                     } else if (strnicmp(value, "lanmani", 7) == 0) {
+                             vol->secFlg |= CIFSSEC_MAY_LANMAN |
+                                     CIFSSEC_MUST_SIGN;
                       } else if (strnicmp(value, "lanman", 6) == 0) {
                               vol->secFlg |= CIFSSEC_MAY_LANMAN;
  #endif
fs/cifs/sess.c +4 -4
index 1adc962..1676570 100644
@@ -656,13 +656,13 @@ ssetup_ntlmssp_authenticate:
 
       if (type == LANMAN) {
  #ifdef CONFIG_CIFS_WEAK_PW_HASH
-             char lnm_session_key[CIFS_SESS_KEY_SIZE];
+             char lnm_session_key[CIFS_AUTH_RESP_SIZE];
 
               pSMB->req.hdr.Flags2 &= ~SMBFLG2_UNICODE;
 
               /* no capabilities flags in old lanman negotiation */
 
-             pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE);
+             pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_AUTH_RESP_SIZE);
 
               /* Calculate hash with password and copy into bcc_ptr.
                * Encryption Key (stored as in cryptkey) gets used if the
@@ -675,8 +675,8 @@ ssetup_ntlmssp_authenticate:
                                       true : false, lnm_session_key);
 
               ses->flags |= CIFS_SES_LANMAN;
-             memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_SESS_KEY_SIZE);
-             bcc_ptr += CIFS_SESS_KEY_SIZE;
+             memcpy(bcc_ptr, (char *)lnm_session_key, CIFS_AUTH_RESP_SIZE);
+             bcc_ptr += CIFS_AUTH_RESP_SIZE;
 
               /* can not sign if LANMAN negotiated so no need

              to calculate signing key? but what if server

fs/cifs/smbdes.c +14 -0
index 0472148..dcfc379 100644
@@ -299,6 +299,20 @@ dohash(char *out, char *in, char *key, int forw)
       kfree(ki);
  }
 
+static int
+odd_parity(unsigned char c)
+{
+     int i;
+     int val = 0x80;
+     int count = 0;
+
+     for (i = 0; i < 7; ++i)
+             if (c & (val >> i))
+                     ++count;
+
+     return count % 2;
+}
+

 static void
 str_to_key(unsigned char *str, unsigned char *key) {

fs/cifs/smbdes.c +4 -1
@@ -312,8 +326,11 @@ str_to_key(unsigned char *str, unsigned char *key)
       key[5] = ((str[4] & 0x1F) << 2) | (str[5] >> 6);
       key[6] = ((str[5] & 0x3F) << 1) | (str[6] >> 7);
       key[7] = str[6] & 0x7F;
-     for (i = 0; i < 8; i++)
+     for (i = 0; i < 8; i++) {
               key[i] = (key[i] << 1);
+             if (!odd_parity(key[i]))
+                     key[i] |= 0x1;
+     }
  }
 
Quoted 1 line

 static void

--
Jeff Layton <[email protected]>