Commit e545937a authored by Jeff Layton's avatar Jeff Layton Committed by Steve French

[CIFS] add OIDs for KRB5 and MSKRB5 to ASN1 parsing routines

Also, fix the parser to recognize them and set the secType
accordingly. Make CIFSSMBNegotiate not error out automatically
after parsing the securityBlob.

Also thanks to Q (Igor) and Simo for their help on this
set of kerberos patches (and Dave Howells for help on the
upcall).
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 84a15b93
...@@ -77,8 +77,12 @@ ...@@ -77,8 +77,12 @@
#define SPNEGO_OID_LEN 7 #define SPNEGO_OID_LEN 7
#define NTLMSSP_OID_LEN 10 #define NTLMSSP_OID_LEN 10
#define KRB5_OID_LEN 7
#define MSKRB5_OID_LEN 7
static unsigned long SPNEGO_OID[7] = { 1, 3, 6, 1, 5, 5, 2 }; static unsigned long SPNEGO_OID[7] = { 1, 3, 6, 1, 5, 5, 2 };
static unsigned long NTLMSSP_OID[10] = { 1, 3, 6, 1, 4, 1, 311, 2, 2, 10 }; static unsigned long NTLMSSP_OID[10] = { 1, 3, 6, 1, 4, 1, 311, 2, 2, 10 };
static unsigned long KRB5_OID[7] = { 1, 2, 840, 113554, 1, 2, 2 };
static unsigned long MSKRB5_OID[7] = { 1, 2, 840, 48018, 1, 2, 2 };
/* /*
* ASN.1 context. * ASN.1 context.
...@@ -457,6 +461,7 @@ decode_negTokenInit(unsigned char *security_blob, int length, ...@@ -457,6 +461,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
unsigned long *oid = NULL; unsigned long *oid = NULL;
unsigned int cls, con, tag, oidlen, rc; unsigned int cls, con, tag, oidlen, rc;
int use_ntlmssp = FALSE; int use_ntlmssp = FALSE;
int use_kerberos = FALSE;
*secType = NTLM; /* BB eventually make Kerberos or NLTMSSP the default*/ *secType = NTLM; /* BB eventually make Kerberos or NLTMSSP the default*/
...@@ -545,18 +550,28 @@ decode_negTokenInit(unsigned char *security_blob, int length, ...@@ -545,18 +550,28 @@ decode_negTokenInit(unsigned char *security_blob, int length,
return 0; return 0;
} }
if ((tag == ASN1_OJI) && (con == ASN1_PRI)) { if ((tag == ASN1_OJI) && (con == ASN1_PRI)) {
rc = asn1_oid_decode(&ctx, end, &oid, &oidlen); if (asn1_oid_decode(&ctx, end, &oid, &oidlen)) {
if (rc) {
cFYI(1, cFYI(1,
("OID len = %d oid = 0x%lx 0x%lx " ("OID len = %d oid = 0x%lx 0x%lx "
"0x%lx 0x%lx", "0x%lx 0x%lx",
oidlen, *oid, *(oid + 1), oidlen, *oid, *(oid + 1),
*(oid + 2), *(oid + 3))); *(oid + 2), *(oid + 3)));
rc = compare_oid(oid, oidlen,
NTLMSSP_OID, NTLMSSP_OID_LEN); if (compare_oid(oid, oidlen,
kfree(oid); MSKRB5_OID,
if (rc) MSKRB5_OID_LEN))
use_kerberos = TRUE;
else if (compare_oid(oid, oidlen,
KRB5_OID,
KRB5_OID_LEN))
use_kerberos = TRUE;
else if (compare_oid(oid, oidlen,
NTLMSSP_OID,
NTLMSSP_OID_LEN))
use_ntlmssp = TRUE; use_ntlmssp = TRUE;
kfree(oid);
} }
} else { } else {
cFYI(1, ("Should be an oid what is going on?")); cFYI(1, ("Should be an oid what is going on?"));
...@@ -609,12 +624,10 @@ decode_negTokenInit(unsigned char *security_blob, int length, ...@@ -609,12 +624,10 @@ decode_negTokenInit(unsigned char *security_blob, int length,
ctx.pointer)); /* is this UTF-8 or ASCII? */ ctx.pointer)); /* is this UTF-8 or ASCII? */
} }
/* if (use_kerberos) if (use_kerberos)
*secType = Kerberos *secType = Kerberos;
else */ else if (use_ntlmssp)
if (use_ntlmssp) {
*secType = NTLMSSP; *secType = NTLMSSP;
}
return 1; return 1;
} }
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "cifs_fs_sb.h" #include "cifs_fs_sb.h"
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/key-type.h> #include <linux/key-type.h>
#include "cifs_spnego.h"
#define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */ #define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */
#ifdef CONFIG_CIFS_QUOTA #ifdef CONFIG_CIFS_QUOTA
......
...@@ -647,8 +647,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) ...@@ -647,8 +647,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
count - 16, count - 16,
&server->secType); &server->secType);
if (rc == 1) { if (rc == 1) {
/* BB Need to fill struct for sessetup here */ rc = 0;
rc = -EOPNOTSUPP;
} else { } else {
rc = -EINVAL; rc = -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment