Commit eeac8047 authored by Steve French's avatar Steve French

[CIFS] Fix CIFS to recognize share mode security

Fix Samba bugzilla bug 3301

In share mode encrypted password must be sent on tree connection (in our
case only the NTLM password is sent, not the older LANMAN one).
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 84153973
...@@ -3,7 +3,8 @@ Version 1.40 ...@@ -3,7 +3,8 @@ Version 1.40
Use fsuid (fsgid) more consistently instead of uid (gid). Improve performance Use fsuid (fsgid) more consistently instead of uid (gid). Improve performance
of readpages by eliminating one extra memcpy. Allow update of file size of readpages by eliminating one extra memcpy. Allow update of file size
from remote server even if file is open for write as long as mount is from remote server even if file is open for write as long as mount is
directio. directio. Recognize share mode security and send NTLM encrypted password
on tree connect if share mode negotiated.
Version 1.39 Version 1.39
------------ ------------
......
...@@ -26,13 +26,13 @@ struct cifs_sid { ...@@ -26,13 +26,13 @@ struct cifs_sid {
__u8 revision; /* revision level */ __u8 revision; /* revision level */
__u8 num_subauths; __u8 num_subauths;
__u8 authority[6]; __u8 authority[6];
__u8 sub_auth[4]; __u32 sub_auth[4];
/* next sub_auth if any ... */ /* next sub_auth if any ... */
} __attribute__((packed)); } __attribute__((packed));
/* everyone */ /* everyone */
const cifs_sid sid_everyone = {1, 1, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0}}; extern const struct cifs_sid sid_everyone;
/* group users */ /* group users */
const cifs_sid sid_user = {1, 2 , {0, 0, 0, 0, 0, 5}, {32, 545, 0, 0}}; extern const struct cifs_sid sid_user;
#endif /* _CIFSACL_H */ #endif /* _CIFSACL_H */
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "cifsproto.h" #include "cifsproto.h"
#include "cifs_unicode.h" #include "cifs_unicode.h"
#include "cifs_debug.h" #include "cifs_debug.h"
#include "cifsacl.h"
#ifdef CONFIG_CIFS_POSIX #ifdef CONFIG_CIFS_POSIX
static struct { static struct {
...@@ -372,8 +373,10 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) ...@@ -372,8 +373,10 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
rc = SendReceive(xid, ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
if (rc == 0) { if (rc == 0) {
server->secMode = pSMBr->SecurityMode; server->secMode = pSMBr->SecurityMode;
server->secType = NTLM; /* BB override default for if((server->secMode & SECMODE_USER) == 0)
cFYI(1,("share mode security"));
server->secType = NTLM; /* BB override default for
NTLMv2 or kerberos v5 */ NTLMv2 or kerberos v5 */
/* one byte - no need to convert this or EncryptionKeyLen /* one byte - no need to convert this or EncryptionKeyLen
from little endian */ from little endian */
...@@ -383,7 +386,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) ...@@ -383,7 +386,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
min(le32_to_cpu(pSMBr->MaxBufferSize), min(le32_to_cpu(pSMBr->MaxBufferSize),
(__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE); (__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);
server->maxRw = le32_to_cpu(pSMBr->MaxRawSize); server->maxRw = le32_to_cpu(pSMBr->MaxRawSize);
cFYI(0, ("Max buf = %d ", ses->server->maxBuf)); cFYI(0, ("Max buf = %d", ses->server->maxBuf));
GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey); GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey);
server->capabilities = le32_to_cpu(pSMBr->Capabilities); server->capabilities = le32_to_cpu(pSMBr->Capabilities);
server->timeZone = le16_to_cpu(pSMBr->ServerTimeZone); server->timeZone = le16_to_cpu(pSMBr->ServerTimeZone);
...@@ -411,8 +414,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) ...@@ -411,8 +414,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
(server->server_GUID, (server->server_GUID,
pSMBr->u.extended_response. pSMBr->u.extended_response.
GUID, 16) != 0) { GUID, 16) != 0) {
cFYI(1, cFYI(1, ("server UID changed"));
("UID of server does not match previous connection to same ip address"));
memcpy(server-> memcpy(server->
server_GUID, server_GUID,
pSMBr->u. pSMBr->u.
...@@ -2494,8 +2496,14 @@ CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon, ...@@ -2494,8 +2496,14 @@ CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon,
#endif /* CONFIG_POSIX */ #endif /* CONFIG_POSIX */
/* security id for everyone */
const struct cifs_sid sid_everyone = {1, 1, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0}};
/* group users */
const struct cifs_sid sid_user = {1, 2 , {0, 0, 0, 0, 0, 5}, {32, 545, 0, 0}};
/* Convert CIFS ACL to POSIX form */ /* Convert CIFS ACL to POSIX form */
static int parse_sec_desc(struct sec_desc * psec_desc, int acl_len) static int parse_sec_desc(struct cifs_sid * psec_desc, int acl_len)
{ {
return 0; return 0;
} }
......
...@@ -1795,7 +1795,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -1795,7 +1795,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
cifs_sb->mnt_gid = volume_info.linux_gid; cifs_sb->mnt_gid = volume_info.linux_gid;
cifs_sb->mnt_file_mode = volume_info.file_mode; cifs_sb->mnt_file_mode = volume_info.file_mode;
cifs_sb->mnt_dir_mode = volume_info.dir_mode; cifs_sb->mnt_dir_mode = volume_info.dir_mode;
cFYI(1,("file mode: 0x%x dir mode: 0x%x",cifs_sb->mnt_file_mode,cifs_sb->mnt_dir_mode)); cFYI(1,("file mode: 0x%x dir mode: 0x%x",
cifs_sb->mnt_file_mode,cifs_sb->mnt_dir_mode));
if(volume_info.noperm) if(volume_info.noperm)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM;
...@@ -1972,7 +1973,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -1972,7 +1973,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
__u32 capabilities; __u32 capabilities;
__u16 count; __u16 count;
cFYI(1, ("In sesssetup ")); cFYI(1, ("In sesssetup"));
if(ses == NULL) if(ses == NULL)
return -EINVAL; return -EINVAL;
user = ses->userName; user = ses->userName;
...@@ -3248,9 +3249,26 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, ...@@ -3248,9 +3249,26 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
pSMB->AndXCommand = 0xFF; pSMB->AndXCommand = 0xFF;
pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO); pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO);
pSMB->PasswordLength = cpu_to_le16(1); /* minimum */
bcc_ptr = &pSMB->Password[0]; bcc_ptr = &pSMB->Password[0];
bcc_ptr++; /* skip password */ if((ses->server->secMode) & SECMODE_USER) {
pSMB->PasswordLength = cpu_to_le16(1); /* minimum */
bcc_ptr++; /* skip password */
} else {
pSMB->PasswordLength = cpu_to_le16(CIFS_SESSION_KEY_SIZE);
/* BB FIXME add code to fail this if NTLMv2 or Kerberos
specified as required (when that support is added to
the vfs in the future) as only NTLM or the much
weaker LANMAN (which we do not send) is accepted
by Samba (not sure whether other servers allow
NTLMv2 password here) */
SMBNTencrypt(ses->password,
ses->server->cryptKey,
bcc_ptr);
bcc_ptr += CIFS_SESSION_KEY_SIZE;
*bcc_ptr = 0;
bcc_ptr++; /* align */
}
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;
...@@ -3268,7 +3286,6 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, ...@@ -3268,7 +3286,6 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
bcc_ptr += 2 * length; /* convert num of 16 bit words to bytes */ bcc_ptr += 2 * length; /* convert num of 16 bit words to bytes */
bcc_ptr += 2; /* skip trailing null */ bcc_ptr += 2; /* skip trailing null */
} else { /* ASCII */ } else { /* ASCII */
strcpy(bcc_ptr, tree); strcpy(bcc_ptr, tree);
bcc_ptr += strlen(tree) + 1; bcc_ptr += strlen(tree) + 1;
} }
......
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