Commit 0c5ba019 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] cifs: annotate SESSION_SETUP_ANX

Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 928e5846
...@@ -436,15 +436,15 @@ typedef union smb_com_session_setup_andx { ...@@ -436,15 +436,15 @@ typedef union smb_com_session_setup_andx {
struct smb_hdr hdr; /* wct = 12 */ struct smb_hdr hdr; /* wct = 12 */
__u8 AndXCommand; __u8 AndXCommand;
__u8 AndXReserved; __u8 AndXReserved;
__u16 AndXOffset; __le16 AndXOffset;
__u16 MaxBufferSize; __le16 MaxBufferSize;
__u16 MaxMpxCount; __le16 MaxMpxCount;
__u16 VcNumber; __le16 VcNumber;
__u32 SessionKey; __u32 SessionKey;
__u16 SecurityBlobLength; __le16 SecurityBlobLength;
__u32 Reserved; __u32 Reserved;
__u32 Capabilities; /* see below */ __le32 Capabilities; /* see below */
__u16 ByteCount; __le16 ByteCount;
unsigned char SecurityBlob[1]; /* followed by */ unsigned char SecurityBlob[1]; /* followed by */
/* STRING NativeOS */ /* STRING NativeOS */
/* STRING NativeLanMan */ /* STRING NativeLanMan */
...@@ -454,16 +454,16 @@ typedef union smb_com_session_setup_andx { ...@@ -454,16 +454,16 @@ typedef union smb_com_session_setup_andx {
struct smb_hdr hdr; /* wct = 13 */ struct smb_hdr hdr; /* wct = 13 */
__u8 AndXCommand; __u8 AndXCommand;
__u8 AndXReserved; __u8 AndXReserved;
__u16 AndXOffset; __le16 AndXOffset;
__u16 MaxBufferSize; __le16 MaxBufferSize;
__u16 MaxMpxCount; __le16 MaxMpxCount;
__u16 VcNumber; __le16 VcNumber;
__u32 SessionKey; __u32 SessionKey;
__u16 CaseInsensitivePasswordLength; /* ASCII password length */ __le16 CaseInsensitivePasswordLength; /* ASCII password length */
__u16 CaseSensitivePasswordLength; /* Unicode password length */ __le16 CaseSensitivePasswordLength; /* Unicode password length */
__u32 Reserved; /* see below */ __u32 Reserved; /* see below */
__u32 Capabilities; __le32 Capabilities;
__u16 ByteCount; __le16 ByteCount;
unsigned char CaseInsensitivePassword[1]; /* followed by: */ unsigned char CaseInsensitivePassword[1]; /* followed by: */
/* unsigned char * CaseSensitivePassword; */ /* unsigned char * CaseSensitivePassword; */
/* STRING AccountName */ /* STRING AccountName */
...@@ -476,9 +476,9 @@ typedef union smb_com_session_setup_andx { ...@@ -476,9 +476,9 @@ typedef union smb_com_session_setup_andx {
struct smb_hdr hdr; /* wct = 4 */ struct smb_hdr hdr; /* wct = 4 */
__u8 AndXCommand; __u8 AndXCommand;
__u8 AndXReserved; __u8 AndXReserved;
__u16 AndXOffset; __le16 AndXOffset;
__u16 Action; /* see below */ __le16 Action; /* see below */
__u16 SecurityBlobLength; __le16 SecurityBlobLength;
__u16 ByteCount; __u16 ByteCount;
unsigned char SecurityBlob[1]; /* followed by */ unsigned char SecurityBlob[1]; /* followed by */
/* unsigned char * NativeOS; */ /* unsigned char * NativeOS; */
...@@ -490,14 +490,14 @@ typedef union smb_com_session_setup_andx { ...@@ -490,14 +490,14 @@ typedef union smb_com_session_setup_andx {
struct smb_hdr hdr; /* wct = 10 */ struct smb_hdr hdr; /* wct = 10 */
__u8 AndXCommand; __u8 AndXCommand;
__u8 AndXReserved; __u8 AndXReserved;
__u16 AndXOffset; __le16 AndXOffset;
__u16 MaxBufferSize; __le16 MaxBufferSize;
__u16 MaxMpxCount; __le16 MaxMpxCount;
__u16 VcNumber; __le16 VcNumber;
__u32 SessionKey; __u32 SessionKey;
__u16 PassswordLength; __le16 PassswordLength;
__u32 Reserved; __u32 Reserved;
__u16 ByteCount; __le16 ByteCount;
unsigned char AccountPassword[1]; /* followed by */ unsigned char AccountPassword[1]; /* followed by */
/* STRING AccountName */ /* STRING AccountName */
/* STRING PrimaryDomain */ /* STRING PrimaryDomain */
...@@ -509,8 +509,8 @@ typedef union smb_com_session_setup_andx { ...@@ -509,8 +509,8 @@ typedef union smb_com_session_setup_andx {
struct smb_hdr hdr; /* wct = 3 */ struct smb_hdr hdr; /* wct = 3 */
__u8 AndXCommand; __u8 AndXCommand;
__u8 AndXReserved; __u8 AndXReserved;
__u16 AndXOffset; __le16 AndXOffset;
__u16 Action; /* see below */ __le16 Action; /* see below */
__u16 ByteCount; __u16 ByteCount;
unsigned char NativeOS[1]; /* followed by */ unsigned char NativeOS[1]; /* followed by */
/* unsigned char * NativeLanMan; */ /* unsigned char * NativeLanMan; */
......
...@@ -1512,6 +1512,8 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -1512,6 +1512,8 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
int remaining_words = 0; int remaining_words = 0;
int bytes_returned = 0; int bytes_returned = 0;
int len; int len;
__u32 capabilities;
__u16 count;
cFYI(1, ("In sesssetup ")); cFYI(1, ("In sesssetup "));
if(ses == NULL) if(ses == NULL)
...@@ -1536,22 +1538,20 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -1536,22 +1538,20 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
pSMB->req_no_secext.Capabilities = capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS;
CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS;
if (ses->capabilities & CAP_UNICODE) { if (ses->capabilities & CAP_UNICODE) {
smb_buffer->Flags2 |= SMBFLG2_UNICODE; smb_buffer->Flags2 |= SMBFLG2_UNICODE;
pSMB->req_no_secext.Capabilities |= CAP_UNICODE; capabilities |= CAP_UNICODE;
} }
if (ses->capabilities & CAP_STATUS32) { if (ses->capabilities & CAP_STATUS32) {
smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS; smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS;
pSMB->req_no_secext.Capabilities |= CAP_STATUS32; capabilities |= CAP_STATUS32;
} }
if (ses->capabilities & CAP_DFS) { if (ses->capabilities & CAP_DFS) {
smb_buffer->Flags2 |= SMBFLG2_DFS; smb_buffer->Flags2 |= SMBFLG2_DFS;
pSMB->req_no_secext.Capabilities |= CAP_DFS; capabilities |= CAP_DFS;
} }
pSMB->req_no_secext.Capabilities = pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities);
cpu_to_le32(pSMB->req_no_secext.Capabilities);
/* pSMB->req_no_secext.CaseInsensitivePasswordLength = /* pSMB->req_no_secext.CaseInsensitivePasswordLength =
CIFS_SESSION_KEY_SIZE; */ CIFS_SESSION_KEY_SIZE; */
pSMB->req_no_secext.CaseInsensitivePasswordLength = 0; pSMB->req_no_secext.CaseInsensitivePasswordLength = 0;
...@@ -1623,9 +1623,9 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -1623,9 +1623,9 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
strcpy(bcc_ptr, CIFS_NETWORK_OPSYS); strcpy(bcc_ptr, CIFS_NETWORK_OPSYS);
bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1; bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1;
} }
BCC(smb_buffer) = (long) bcc_ptr - (long) pByteArea(smb_buffer); count = (long) bcc_ptr - (long) pByteArea(smb_buffer);
smb_buffer->smb_buf_length += BCC(smb_buffer); smb_buffer->smb_buf_length += count;
BCC(smb_buffer) = cpu_to_le16(BCC(smb_buffer)); pSMB->req_no_secext.ByteCount = cpu_to_le16(count);
rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response,
&bytes_returned, 1); &bytes_returned, 1);
...@@ -1633,8 +1633,8 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -1633,8 +1633,8 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
/* rc = map_smb_to_linux_error(smb_buffer_response); now done in SendReceive */ /* rc = map_smb_to_linux_error(smb_buffer_response); now done in SendReceive */
} else if ((smb_buffer_response->WordCount == 3) } else if ((smb_buffer_response->WordCount == 3)
|| (smb_buffer_response->WordCount == 4)) { || (smb_buffer_response->WordCount == 4)) {
pSMBr->resp.Action = le16_to_cpu(pSMBr->resp.Action); __u16 action = le16_to_cpu(pSMBr->resp.Action);
if (pSMBr->resp.Action & GUEST_LOGIN) if (action & GUEST_LOGIN)
cFYI(1, (" Guest login")); /* do we want to mark SesInfo struct ? */ cFYI(1, (" Guest login")); /* do we want to mark SesInfo struct ? */
ses->Suid = smb_buffer_response->Uid; /* UID left in wire format (le) */ ses->Suid = smb_buffer_response->Uid; /* UID left in wire format (le) */
cFYI(1, ("UID = %d ", ses->Suid)); cFYI(1, ("UID = %d ", ses->Suid));
...@@ -1764,6 +1764,8 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -1764,6 +1764,8 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
int remaining_words = 0; int remaining_words = 0;
int bytes_returned = 0; int bytes_returned = 0;
int len; int len;
__u32 capabilities;
__u16 count;
cFYI(1, ("In spnego sesssetup ")); cFYI(1, ("In spnego sesssetup "));
if(ses == NULL) if(ses == NULL)
...@@ -1789,22 +1791,21 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -1789,22 +1791,21 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
pSMB->req.Capabilities = capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
CAP_EXTENDED_SECURITY; CAP_EXTENDED_SECURITY;
if (ses->capabilities & CAP_UNICODE) { if (ses->capabilities & CAP_UNICODE) {
smb_buffer->Flags2 |= SMBFLG2_UNICODE; smb_buffer->Flags2 |= SMBFLG2_UNICODE;
pSMB->req.Capabilities |= CAP_UNICODE; capabilities |= CAP_UNICODE;
} }
if (ses->capabilities & CAP_STATUS32) { if (ses->capabilities & CAP_STATUS32) {
smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS; smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS;
pSMB->req.Capabilities |= CAP_STATUS32; capabilities |= CAP_STATUS32;
} }
if (ses->capabilities & CAP_DFS) { if (ses->capabilities & CAP_DFS) {
smb_buffer->Flags2 |= SMBFLG2_DFS; smb_buffer->Flags2 |= SMBFLG2_DFS;
pSMB->req.Capabilities |= CAP_DFS; capabilities |= CAP_DFS;
} }
pSMB->req.Capabilities = cpu_to_le32(pSMB->req.Capabilities); pSMB->req.Capabilities = cpu_to_le32(capabilities);
pSMB->req.SecurityBlobLength = cpu_to_le16(SecurityBlobLength); pSMB->req.SecurityBlobLength = cpu_to_le16(SecurityBlobLength);
bcc_ptr = pByteArea(smb_buffer); bcc_ptr = pByteArea(smb_buffer);
...@@ -1865,9 +1866,9 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -1865,9 +1866,9 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
strcpy(bcc_ptr, CIFS_NETWORK_OPSYS); strcpy(bcc_ptr, CIFS_NETWORK_OPSYS);
bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1; bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1;
} }
BCC(smb_buffer) = (long) bcc_ptr - (long) pByteArea(smb_buffer); count = (long) bcc_ptr - (long) pByteArea(smb_buffer);
smb_buffer->smb_buf_length += BCC(smb_buffer); smb_buffer->smb_buf_length += count;
BCC(smb_buffer) = cpu_to_le16(BCC(smb_buffer)); pSMB->req.ByteCount = cpu_to_le16(count);
rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response,
&bytes_returned, 1); &bytes_returned, 1);
...@@ -1875,10 +1876,10 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -1875,10 +1876,10 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
/* rc = map_smb_to_linux_error(smb_buffer_response); *//* done in SendReceive now */ /* rc = map_smb_to_linux_error(smb_buffer_response); *//* done in SendReceive now */
} else if ((smb_buffer_response->WordCount == 3) } else if ((smb_buffer_response->WordCount == 3)
|| (smb_buffer_response->WordCount == 4)) { || (smb_buffer_response->WordCount == 4)) {
pSMBr->resp.Action = le16_to_cpu(pSMBr->resp.Action); __u16 action = le16_to_cpu(pSMBr->resp.Action);
pSMBr->resp.SecurityBlobLength = __u16 blob_len =
le16_to_cpu(pSMBr->resp.SecurityBlobLength); le16_to_cpu(pSMBr->resp.SecurityBlobLength);
if (pSMBr->resp.Action & GUEST_LOGIN) if (action & GUEST_LOGIN)
cFYI(1, (" Guest login")); /* BB do we want to set anything in SesInfo struct ? */ cFYI(1, (" Guest login")); /* BB do we want to set anything in SesInfo struct ? */
if (ses) { if (ses) {
ses->Suid = smb_buffer_response->Uid; /* UID left in wire format (le) */ ses->Suid = smb_buffer_response->Uid; /* UID left in wire format (le) */
...@@ -1889,14 +1890,14 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -1889,14 +1890,14 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
if ((pSMBr->resp.hdr.WordCount == 3) if ((pSMBr->resp.hdr.WordCount == 3)
|| ((pSMBr->resp.hdr.WordCount == 4) || ((pSMBr->resp.hdr.WordCount == 4)
&& (pSMBr->resp.SecurityBlobLength < && (blob_len <
pSMBr->resp.ByteCount))) { pSMBr->resp.ByteCount))) {
if (pSMBr->resp.hdr.WordCount == 4) { if (pSMBr->resp.hdr.WordCount == 4) {
bcc_ptr += bcc_ptr +=
pSMBr->resp.SecurityBlobLength; blob_len;
cFYI(1, cFYI(1,
("Security Blob Length %d ", ("Security Blob Length %d ",
pSMBr->resp.SecurityBlobLength)); blob_len));
} }
if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { if (smb_buffer->Flags2 & SMBFLG2_UNICODE) {
...@@ -2029,6 +2030,8 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, ...@@ -2029,6 +2030,8 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
int SecurityBlobLength = sizeof (NEGOTIATE_MESSAGE); int SecurityBlobLength = sizeof (NEGOTIATE_MESSAGE);
PNEGOTIATE_MESSAGE SecurityBlob; PNEGOTIATE_MESSAGE SecurityBlob;
PCHALLENGE_MESSAGE SecurityBlob2; PCHALLENGE_MESSAGE SecurityBlob2;
__u32 negotiate_flags, capabilities;
__u16 count;
cFYI(1, ("In NTLMSSP sesssetup (negotiate) ")); cFYI(1, ("In NTLMSSP sesssetup (negotiate) "));
if(ses == NULL) if(ses == NULL)
...@@ -2056,35 +2059,34 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, ...@@ -2056,35 +2059,34 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
pSMB->req.Capabilities = capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
CAP_EXTENDED_SECURITY; CAP_EXTENDED_SECURITY;
if (ses->capabilities & CAP_UNICODE) { if (ses->capabilities & CAP_UNICODE) {
smb_buffer->Flags2 |= SMBFLG2_UNICODE; smb_buffer->Flags2 |= SMBFLG2_UNICODE;
pSMB->req.Capabilities |= CAP_UNICODE; capabilities |= CAP_UNICODE;
} }
if (ses->capabilities & CAP_STATUS32) { if (ses->capabilities & CAP_STATUS32) {
smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS; smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS;
pSMB->req.Capabilities |= CAP_STATUS32; capabilities |= CAP_STATUS32;
} }
if (ses->capabilities & CAP_DFS) { if (ses->capabilities & CAP_DFS) {
smb_buffer->Flags2 |= SMBFLG2_DFS; smb_buffer->Flags2 |= SMBFLG2_DFS;
pSMB->req.Capabilities |= CAP_DFS; capabilities |= CAP_DFS;
} }
pSMB->req.Capabilities = cpu_to_le32(pSMB->req.Capabilities); pSMB->req.Capabilities = cpu_to_le32(capabilities);
bcc_ptr = (char *) &pSMB->req.SecurityBlob; bcc_ptr = (char *) &pSMB->req.SecurityBlob;
SecurityBlob = (PNEGOTIATE_MESSAGE) bcc_ptr; SecurityBlob = (PNEGOTIATE_MESSAGE) bcc_ptr;
strncpy(SecurityBlob->Signature, NTLMSSP_SIGNATURE, 8); strncpy(SecurityBlob->Signature, NTLMSSP_SIGNATURE, 8);
SecurityBlob->MessageType = NtLmNegotiate; SecurityBlob->MessageType = NtLmNegotiate;
SecurityBlob->NegotiateFlags = negotiate_flags =
NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_OEM | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_OEM |
NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_NTLM | 0x80000000 | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_NTLM | 0x80000000 |
/* NTLMSSP_NEGOTIATE_ALWAYS_SIGN | */ NTLMSSP_NEGOTIATE_128; /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN | */ NTLMSSP_NEGOTIATE_128;
if(sign_CIFS_PDUs) if(sign_CIFS_PDUs)
SecurityBlob->NegotiateFlags |= NTLMSSP_NEGOTIATE_SIGN; negotiate_flags |= NTLMSSP_NEGOTIATE_SIGN;
if(ntlmv2_support) if(ntlmv2_support)
SecurityBlob->NegotiateFlags |= NTLMSSP_NEGOTIATE_NTLMV2; negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2;
/* setup pointers to domain name and workstation name */ /* setup pointers to domain name and workstation name */
bcc_ptr += SecurityBlobLength; bcc_ptr += SecurityBlobLength;
...@@ -2097,20 +2099,20 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, ...@@ -2097,20 +2099,20 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
SecurityBlob->DomainName.Length = 0; SecurityBlob->DomainName.Length = 0;
SecurityBlob->DomainName.MaximumLength = 0; SecurityBlob->DomainName.MaximumLength = 0;
} else { } else {
SecurityBlob->NegotiateFlags |= __u16 len;
NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED; negotiate_flags |= NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED;
strncpy(bcc_ptr, domain, 63); strncpy(bcc_ptr, domain, 63);
SecurityBlob->DomainName.Length = strnlen(domain, 64); len = strnlen(domain, 64);
SecurityBlob->DomainName.MaximumLength = SecurityBlob->DomainName.MaximumLength =
cpu_to_le16(SecurityBlob->DomainName.Length); cpu_to_le16(len);
SecurityBlob->DomainName.Buffer = SecurityBlob->DomainName.Buffer =
cpu_to_le32((long) &SecurityBlob-> cpu_to_le32((long) &SecurityBlob->
DomainString - DomainString -
(long) &SecurityBlob->Signature); (long) &SecurityBlob->Signature);
bcc_ptr += SecurityBlob->DomainName.Length; bcc_ptr += len;
SecurityBlobLength += SecurityBlob->DomainName.Length; SecurityBlobLength += len;
SecurityBlob->DomainName.Length = SecurityBlob->DomainName.Length =
cpu_to_le16(SecurityBlob->DomainName.Length); cpu_to_le16(len);
} }
if (ses->capabilities & CAP_UNICODE) { if (ses->capabilities & CAP_UNICODE) {
if ((long) bcc_ptr % 2) { if ((long) bcc_ptr % 2) {
...@@ -2147,12 +2149,11 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, ...@@ -2147,12 +2149,11 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
bcc_ptr++; /* empty domain field */ bcc_ptr++; /* empty domain field */
*bcc_ptr = 0; *bcc_ptr = 0;
} }
SecurityBlob->NegotiateFlags = SecurityBlob->NegotiateFlags = cpu_to_le32(negotiate_flags);
cpu_to_le32(SecurityBlob->NegotiateFlags);
pSMB->req.SecurityBlobLength = cpu_to_le16(SecurityBlobLength); pSMB->req.SecurityBlobLength = cpu_to_le16(SecurityBlobLength);
BCC(smb_buffer) = (long) bcc_ptr - (long) pByteArea(smb_buffer); count = (long) bcc_ptr - (long) pByteArea(smb_buffer);
smb_buffer->smb_buf_length += BCC(smb_buffer); smb_buffer->smb_buf_length += count;
BCC(smb_buffer) = cpu_to_le16(BCC(smb_buffer)); pSMB->req.ByteCount = cpu_to_le16(count);
rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response,
&bytes_returned, 1); &bytes_returned, 1);
...@@ -2165,10 +2166,10 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, ...@@ -2165,10 +2166,10 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
/* rc = map_smb_to_linux_error(smb_buffer_response); *//* done in SendReceive now */ /* rc = map_smb_to_linux_error(smb_buffer_response); *//* done in SendReceive now */
} else if ((smb_buffer_response->WordCount == 3) } else if ((smb_buffer_response->WordCount == 3)
|| (smb_buffer_response->WordCount == 4)) { || (smb_buffer_response->WordCount == 4)) {
pSMBr->resp.Action = le16_to_cpu(pSMBr->resp.Action); __u16 action = le16_to_cpu(pSMBr->resp.Action);
pSMBr->resp.SecurityBlobLength = __u16 blob_len = le16_to_cpu(pSMBr->resp.SecurityBlobLength);
le16_to_cpu(pSMBr->resp.SecurityBlobLength);
if (pSMBr->resp.Action & GUEST_LOGIN) if (action & GUEST_LOGIN)
cFYI(1, (" Guest login")); cFYI(1, (" Guest login"));
/* Do we want to set anything in SesInfo struct when guest login? */ /* Do we want to set anything in SesInfo struct when guest login? */
...@@ -2185,14 +2186,14 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, ...@@ -2185,14 +2186,14 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
cFYI(1, ("UID = %d ", ses->Suid)); cFYI(1, ("UID = %d ", ses->Suid));
if ((pSMBr->resp.hdr.WordCount == 3) if ((pSMBr->resp.hdr.WordCount == 3)
|| ((pSMBr->resp.hdr.WordCount == 4) || ((pSMBr->resp.hdr.WordCount == 4)
&& (pSMBr->resp.SecurityBlobLength < && (blob_len <
pSMBr->resp.ByteCount))) { pSMBr->resp.ByteCount))) {
if (pSMBr->resp.hdr.WordCount == 4) { if (pSMBr->resp.hdr.WordCount == 4) {
bcc_ptr += bcc_ptr += blob_len;
pSMBr->resp.SecurityBlobLength;
cFYI(1, cFYI(1,
("Security Blob Length %d ", ("Security Blob Length %d ",
pSMBr->resp.SecurityBlobLength)); blob_len));
} }
cFYI(1, ("NTLMSSP Challenge rcvd ")); cFYI(1, ("NTLMSSP Challenge rcvd "));
...@@ -2353,7 +2354,6 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, ...@@ -2353,7 +2354,6 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
return rc; return rc;
} }
static int static int
CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
char *ntlm_session_key, int ntlmv2_flag, char *ntlm_session_key, int ntlmv2_flag,
...@@ -2372,6 +2372,8 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2372,6 +2372,8 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
int len; int len;
int SecurityBlobLength = sizeof (AUTHENTICATE_MESSAGE); int SecurityBlobLength = sizeof (AUTHENTICATE_MESSAGE);
PAUTHENTICATE_MESSAGE SecurityBlob; PAUTHENTICATE_MESSAGE SecurityBlob;
__u32 negotiate_flags, capabilities;
__u16 count;
cFYI(1, ("In NTLMSSPSessSetup (Authenticate)")); cFYI(1, ("In NTLMSSPSessSetup (Authenticate)"));
if(ses == NULL) if(ses == NULL)
...@@ -2400,36 +2402,35 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2400,36 +2402,35 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE; smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
pSMB->req.Capabilities = capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
CAP_EXTENDED_SECURITY; CAP_EXTENDED_SECURITY;
if (ses->capabilities & CAP_UNICODE) { if (ses->capabilities & CAP_UNICODE) {
smb_buffer->Flags2 |= SMBFLG2_UNICODE; smb_buffer->Flags2 |= SMBFLG2_UNICODE;
pSMB->req.Capabilities |= CAP_UNICODE; capabilities |= CAP_UNICODE;
} }
if (ses->capabilities & CAP_STATUS32) { if (ses->capabilities & CAP_STATUS32) {
smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS; smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS;
pSMB->req.Capabilities |= CAP_STATUS32; capabilities |= CAP_STATUS32;
} }
if (ses->capabilities & CAP_DFS) { if (ses->capabilities & CAP_DFS) {
smb_buffer->Flags2 |= SMBFLG2_DFS; smb_buffer->Flags2 |= SMBFLG2_DFS;
pSMB->req.Capabilities |= CAP_DFS; capabilities |= CAP_DFS;
} }
pSMB->req.Capabilities = cpu_to_le32(pSMB->req.Capabilities); pSMB->req.Capabilities = cpu_to_le32(capabilities);
bcc_ptr = (char *) &pSMB->req.SecurityBlob; bcc_ptr = (char *) &pSMB->req.SecurityBlob;
SecurityBlob = (PAUTHENTICATE_MESSAGE) bcc_ptr; SecurityBlob = (PAUTHENTICATE_MESSAGE) bcc_ptr;
strncpy(SecurityBlob->Signature, NTLMSSP_SIGNATURE, 8); strncpy(SecurityBlob->Signature, NTLMSSP_SIGNATURE, 8);
SecurityBlob->MessageType = NtLmAuthenticate; SecurityBlob->MessageType = NtLmAuthenticate;
bcc_ptr += SecurityBlobLength; bcc_ptr += SecurityBlobLength;
SecurityBlob->NegotiateFlags = negotiate_flags =
NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_REQUEST_TARGET |
NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_TARGET_INFO | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_TARGET_INFO |
0x80000000 | NTLMSSP_NEGOTIATE_128; 0x80000000 | NTLMSSP_NEGOTIATE_128;
if(sign_CIFS_PDUs) if(sign_CIFS_PDUs)
SecurityBlob->NegotiateFlags |= /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN |*/ NTLMSSP_NEGOTIATE_SIGN; negotiate_flags |= /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN |*/ NTLMSSP_NEGOTIATE_SIGN;
if(ntlmv2_flag) if(ntlmv2_flag)
SecurityBlob->NegotiateFlags |= NTLMSSP_NEGOTIATE_NTLMV2; negotiate_flags |= NTLMSSP_NEGOTIATE_NTLMV2;
/* setup pointers to domain name and workstation name */ /* setup pointers to domain name and workstation name */
...@@ -2460,36 +2461,36 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2460,36 +2461,36 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
SecurityBlob->DomainName.Length = 0; SecurityBlob->DomainName.Length = 0;
SecurityBlob->DomainName.MaximumLength = 0; SecurityBlob->DomainName.MaximumLength = 0;
} else { } else {
SecurityBlob->DomainName.Length = __u16 len =
cifs_strtoUCS((wchar_t *) bcc_ptr, domain, 64, cifs_strtoUCS((wchar_t *) bcc_ptr, domain, 64,
nls_codepage); nls_codepage);
SecurityBlob->DomainName.Length *= 2; len *= 2;
SecurityBlob->DomainName.MaximumLength = SecurityBlob->DomainName.MaximumLength =
cpu_to_le16(SecurityBlob->DomainName.Length); cpu_to_le16(len);
SecurityBlob->DomainName.Buffer = SecurityBlob->DomainName.Buffer =
cpu_to_le32(SecurityBlobLength); cpu_to_le32(SecurityBlobLength);
bcc_ptr += SecurityBlob->DomainName.Length; bcc_ptr += len;
SecurityBlobLength += SecurityBlob->DomainName.Length; SecurityBlobLength += len;
SecurityBlob->DomainName.Length = SecurityBlob->DomainName.Length =
cpu_to_le16(SecurityBlob->DomainName.Length); cpu_to_le16(len);
} }
if (user == NULL) { if (user == NULL) {
SecurityBlob->UserName.Buffer = 0; SecurityBlob->UserName.Buffer = 0;
SecurityBlob->UserName.Length = 0; SecurityBlob->UserName.Length = 0;
SecurityBlob->UserName.MaximumLength = 0; SecurityBlob->UserName.MaximumLength = 0;
} else { } else {
SecurityBlob->UserName.Length = __u16 len =
cifs_strtoUCS((wchar_t *) bcc_ptr, user, 64, cifs_strtoUCS((wchar_t *) bcc_ptr, user, 64,
nls_codepage); nls_codepage);
SecurityBlob->UserName.Length *= 2; len *= 2;
SecurityBlob->UserName.MaximumLength = SecurityBlob->UserName.MaximumLength =
cpu_to_le16(SecurityBlob->UserName.Length); cpu_to_le16(len);
SecurityBlob->UserName.Buffer = SecurityBlob->UserName.Buffer =
cpu_to_le32(SecurityBlobLength); cpu_to_le32(SecurityBlobLength);
bcc_ptr += SecurityBlob->UserName.Length; bcc_ptr += len;
SecurityBlobLength += SecurityBlob->UserName.Length; SecurityBlobLength += len;
SecurityBlob->UserName.Length = SecurityBlob->UserName.Length =
cpu_to_le16(SecurityBlob->UserName.Length); cpu_to_le16(len);
} }
/* SecurityBlob->WorkstationName.Length = cifs_strtoUCS((wchar_t *) bcc_ptr, "AMACHINE",64, nls_codepage); /* SecurityBlob->WorkstationName.Length = cifs_strtoUCS((wchar_t *) bcc_ptr, "AMACHINE",64, nls_codepage);
...@@ -2529,34 +2530,33 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2529,34 +2530,33 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
SecurityBlob->DomainName.Length = 0; SecurityBlob->DomainName.Length = 0;
SecurityBlob->DomainName.MaximumLength = 0; SecurityBlob->DomainName.MaximumLength = 0;
} else { } else {
SecurityBlob->NegotiateFlags |= __u16 len;
NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED; negotiate_flags |= NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED;
strncpy(bcc_ptr, domain, 63); strncpy(bcc_ptr, domain, 63);
SecurityBlob->DomainName.Length = strnlen(domain, 64); len = strnlen(domain, 64);
SecurityBlob->DomainName.MaximumLength = SecurityBlob->DomainName.MaximumLength =
cpu_to_le16(SecurityBlob->DomainName.Length); cpu_to_le16(len);
SecurityBlob->DomainName.Buffer = SecurityBlob->DomainName.Buffer =
cpu_to_le32(SecurityBlobLength); cpu_to_le32(SecurityBlobLength);
bcc_ptr += SecurityBlob->DomainName.Length; bcc_ptr += len;
SecurityBlobLength += SecurityBlob->DomainName.Length; SecurityBlobLength += len;
SecurityBlob->DomainName.Length = SecurityBlob->DomainName.Length = cpu_to_le16(len);
cpu_to_le16(SecurityBlob->DomainName.Length);
} }
if (user == NULL) { if (user == NULL) {
SecurityBlob->UserName.Buffer = 0; SecurityBlob->UserName.Buffer = 0;
SecurityBlob->UserName.Length = 0; SecurityBlob->UserName.Length = 0;
SecurityBlob->UserName.MaximumLength = 0; SecurityBlob->UserName.MaximumLength = 0;
} else { } else {
__u16 len;
strncpy(bcc_ptr, user, 63); strncpy(bcc_ptr, user, 63);
SecurityBlob->UserName.Length = strnlen(user, 64); len = strnlen(user, 64);
SecurityBlob->UserName.MaximumLength = SecurityBlob->UserName.MaximumLength =
cpu_to_le16(SecurityBlob->UserName.Length); cpu_to_le16(len);
SecurityBlob->UserName.Buffer = SecurityBlob->UserName.Buffer =
cpu_to_le32(SecurityBlobLength); cpu_to_le32(SecurityBlobLength);
bcc_ptr += SecurityBlob->UserName.Length; bcc_ptr += len;
SecurityBlobLength += SecurityBlob->UserName.Length; SecurityBlobLength += len;
SecurityBlob->UserName.Length = SecurityBlob->UserName.Length = cpu_to_le16(len);
cpu_to_le16(SecurityBlob->UserName.Length);
} }
/* BB fill in our workstation name if known BB */ /* BB fill in our workstation name if known BB */
...@@ -2569,12 +2569,11 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2569,12 +2569,11 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
bcc_ptr++; /* null domain */ bcc_ptr++; /* null domain */
*bcc_ptr = 0; *bcc_ptr = 0;
} }
SecurityBlob->NegotiateFlags = SecurityBlob->NegotiateFlags = cpu_to_le32(negotiate_flags);
cpu_to_le32(SecurityBlob->NegotiateFlags);
pSMB->req.SecurityBlobLength = cpu_to_le16(SecurityBlobLength); pSMB->req.SecurityBlobLength = cpu_to_le16(SecurityBlobLength);
BCC(smb_buffer) = (long) bcc_ptr - (long) pByteArea(smb_buffer); count = (long) bcc_ptr - (long) pByteArea(smb_buffer);
smb_buffer->smb_buf_length += BCC(smb_buffer); smb_buffer->smb_buf_length += count;
BCC(smb_buffer) = cpu_to_le16(BCC(smb_buffer)); pSMB->req.ByteCount = cpu_to_le16(count);
rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response,
&bytes_returned, 1); &bytes_returned, 1);
...@@ -2582,10 +2581,10 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2582,10 +2581,10 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
/* rc = map_smb_to_linux_error(smb_buffer_response); *//* done in SendReceive now */ /* rc = map_smb_to_linux_error(smb_buffer_response); *//* done in SendReceive now */
} else if ((smb_buffer_response->WordCount == 3) } else if ((smb_buffer_response->WordCount == 3)
|| (smb_buffer_response->WordCount == 4)) { || (smb_buffer_response->WordCount == 4)) {
pSMBr->resp.Action = le16_to_cpu(pSMBr->resp.Action); __u16 action = le16_to_cpu(pSMBr->resp.Action);
pSMBr->resp.SecurityBlobLength = __u16 blob_len =
le16_to_cpu(pSMBr->resp.SecurityBlobLength); le16_to_cpu(pSMBr->resp.SecurityBlobLength);
if (pSMBr->resp.Action & GUEST_LOGIN) if (action & GUEST_LOGIN)
cFYI(1, (" Guest login")); /* BB do we want to set anything in SesInfo struct ? */ cFYI(1, (" Guest login")); /* BB do we want to set anything in SesInfo struct ? */
/* if(SecurityBlob2->MessageType != NtLm??){ /* if(SecurityBlob2->MessageType != NtLm??){
cFYI("Unexpected message type on auth response is %d ")); cFYI("Unexpected message type on auth response is %d "));
...@@ -2599,14 +2598,14 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2599,14 +2598,14 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
/* response can have either 3 or 4 word count - Samba sends 3 */ /* response can have either 3 or 4 word count - Samba sends 3 */
if ((pSMBr->resp.hdr.WordCount == 3) if ((pSMBr->resp.hdr.WordCount == 3)
|| ((pSMBr->resp.hdr.WordCount == 4) || ((pSMBr->resp.hdr.WordCount == 4)
&& (pSMBr->resp.SecurityBlobLength < && (blob_len <
pSMBr->resp.ByteCount))) { pSMBr->resp.ByteCount))) {
if (pSMBr->resp.hdr.WordCount == 4) { if (pSMBr->resp.hdr.WordCount == 4) {
bcc_ptr += bcc_ptr +=
pSMBr->resp.SecurityBlobLength; blob_len;
cFYI(1, cFYI(1,
("Security Blob Length %d ", ("Security Blob Length %d ",
pSMBr->resp.SecurityBlobLength)); blob_len));
} }
cFYI(1, cFYI(1,
......
...@@ -60,15 +60,15 @@ ...@@ -60,15 +60,15 @@
/* appearance */ /* appearance */
typedef struct _SECURITY_BUFFER { typedef struct _SECURITY_BUFFER {
__u16 Length; __le16 Length;
__u16 MaximumLength; __le16 MaximumLength;
__u32 Buffer; /* offset to buffer */ __le32 Buffer; /* offset to buffer */
} SECURITY_BUFFER; } SECURITY_BUFFER;
typedef struct _NEGOTIATE_MESSAGE { typedef struct _NEGOTIATE_MESSAGE {
__u8 Signature[sizeof (NTLMSSP_SIGNATURE)]; __u8 Signature[sizeof (NTLMSSP_SIGNATURE)];
__u32 MessageType; /* 1 */ __le32 MessageType; /* 1 */
__u32 NegotiateFlags; __le32 NegotiateFlags;
SECURITY_BUFFER DomainName; /* RFC 1001 style and ASCII */ SECURITY_BUFFER DomainName; /* RFC 1001 style and ASCII */
SECURITY_BUFFER WorkstationName; /* RFC 1001 and ASCII */ SECURITY_BUFFER WorkstationName; /* RFC 1001 and ASCII */
char DomainString[0]; char DomainString[0];
...@@ -77,9 +77,9 @@ typedef struct _NEGOTIATE_MESSAGE { ...@@ -77,9 +77,9 @@ typedef struct _NEGOTIATE_MESSAGE {
typedef struct _CHALLENGE_MESSAGE { typedef struct _CHALLENGE_MESSAGE {
__u8 Signature[sizeof (NTLMSSP_SIGNATURE)]; __u8 Signature[sizeof (NTLMSSP_SIGNATURE)];
__u32 MessageType; /* 2 */ __le32 MessageType; /* 2 */
SECURITY_BUFFER TargetName; SECURITY_BUFFER TargetName;
__u32 NegotiateFlags; __le32 NegotiateFlags;
__u8 Challenge[CIFS_CRYPTO_KEY_SIZE]; __u8 Challenge[CIFS_CRYPTO_KEY_SIZE];
__u8 Reserved[8]; __u8 Reserved[8];
SECURITY_BUFFER TargetInfoArray; SECURITY_BUFFER TargetInfoArray;
...@@ -87,14 +87,14 @@ typedef struct _CHALLENGE_MESSAGE { ...@@ -87,14 +87,14 @@ typedef struct _CHALLENGE_MESSAGE {
typedef struct _AUTHENTICATE_MESSAGE { typedef struct _AUTHENTICATE_MESSAGE {
__u8 Signature[sizeof (NTLMSSP_SIGNATURE)]; __u8 Signature[sizeof (NTLMSSP_SIGNATURE)];
__u32 MessageType; /* 3 */ __le32 MessageType; /* 3 */
SECURITY_BUFFER LmChallengeResponse; SECURITY_BUFFER LmChallengeResponse;
SECURITY_BUFFER NtChallengeResponse; SECURITY_BUFFER NtChallengeResponse;
SECURITY_BUFFER DomainName; SECURITY_BUFFER DomainName;
SECURITY_BUFFER UserName; SECURITY_BUFFER UserName;
SECURITY_BUFFER WorkstationName; SECURITY_BUFFER WorkstationName;
SECURITY_BUFFER SessionKey; SECURITY_BUFFER SessionKey;
__u32 NegotiateFlags; __le32 NegotiateFlags;
char UserString[0]; char UserString[0];
} AUTHENTICATE_MESSAGE, *PAUTHENTICATE_MESSAGE; } AUTHENTICATE_MESSAGE, *PAUTHENTICATE_MESSAGE;
......
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