diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/cifs/CHANGES | 6 | ||||
-rw-r--r-- | fs/cifs/Makefile | 2 | ||||
-rw-r--r-- | fs/cifs/cifsencrypt.c | 6 | ||||
-rw-r--r-- | fs/cifs/cifsfs.c | 5 | ||||
-rw-r--r-- | fs/cifs/cifsfs.h | 2 | ||||
-rw-r--r-- | fs/cifs/cifsglob.h | 11 | ||||
-rw-r--r-- | fs/cifs/cifsproto.h | 10 | ||||
-rw-r--r-- | fs/cifs/cifssmb.c | 32 | ||||
-rw-r--r-- | fs/cifs/connect.c | 50 | ||||
-rw-r--r-- | fs/cifs/dir.c | 4 | ||||
-rw-r--r-- | fs/cifs/inode.c | 3 | ||||
-rw-r--r-- | fs/cifs/misc.c | 6 | ||||
-rw-r--r-- | fs/cifs/ntlmssp.c | 130 | ||||
-rw-r--r-- | fs/cifs/ntlmssp.h | 2 |
14 files changed, 215 insertions, 54 deletions
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES index d335015473a5..a9cf779cf35e 100644 --- a/fs/cifs/CHANGES +++ b/fs/cifs/CHANGES | |||
@@ -1,3 +1,9 @@ | |||
1 | Version 1.41 | ||
2 | ------------ | ||
3 | Fix NTLMv2 security (can be enabled in /proc/fs/cifs) so customers can | ||
4 | configure stronger authentication. Fix sfu symlinks so they can | ||
5 | be followed (not just recognized). | ||
6 | |||
1 | Version 1.40 | 7 | Version 1.40 |
2 | ------------ | 8 | ------------ |
3 | Use fsuid (fsgid) more consistently instead of uid (gid). Improve performance | 9 | Use fsuid (fsgid) more consistently instead of uid (gid). Improve performance |
diff --git a/fs/cifs/Makefile b/fs/cifs/Makefile index 7384947a0f93..58c77254a23b 100644 --- a/fs/cifs/Makefile +++ b/fs/cifs/Makefile | |||
@@ -3,4 +3,4 @@ | |||
3 | # | 3 | # |
4 | obj-$(CONFIG_CIFS) += cifs.o | 4 | obj-$(CONFIG_CIFS) += cifs.o |
5 | 5 | ||
6 | cifs-objs := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o md4.o md5.o cifs_unicode.o nterr.o xattr.o cifsencrypt.o fcntl.o readdir.o ioctl.o | 6 | cifs-objs := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o md4.o md5.o cifs_unicode.o nterr.o xattr.o cifsencrypt.o fcntl.o readdir.o ioctl.o ntlmssp.o |
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index a2c24858d40f..c2cbe0ed98b3 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * fs/cifs/cifsencrypt.c | 2 | * fs/cifs/cifsencrypt.c |
3 | * | 3 | * |
4 | * Copyright (C) International Business Machines Corp., 2005 | 4 | * Copyright (C) International Business Machines Corp., 2005,2006 |
5 | * Author(s): Steve French (sfrench@us.ibm.com) | 5 | * Author(s): Steve French (sfrench@us.ibm.com) |
6 | * | 6 | * |
7 | * This library is free software; you can redistribute it and/or modify | 7 | * This library is free software; you can redistribute it and/or modify |
@@ -36,7 +36,8 @@ | |||
36 | extern void mdfour(unsigned char *out, unsigned char *in, int n); | 36 | extern void mdfour(unsigned char *out, unsigned char *in, int n); |
37 | extern void E_md4hash(const unsigned char *passwd, unsigned char *p16); | 37 | extern void E_md4hash(const unsigned char *passwd, unsigned char *p16); |
38 | 38 | ||
39 | static int cifs_calculate_signature(const struct smb_hdr * cifs_pdu, const char * key, char * signature) | 39 | static int cifs_calculate_signature(const struct smb_hdr * cifs_pdu, |
40 | const char * key, char * signature) | ||
40 | { | 41 | { |
41 | struct MD5Context context; | 42 | struct MD5Context context; |
42 | 43 | ||
@@ -259,4 +260,5 @@ void CalcNTLMv2_response(const struct cifsSesInfo * ses,char * v2_session_respon | |||
259 | /* hmac_md5_update(v2_session_response+16)client thing,8,&context); */ /* BB fix */ | 260 | /* hmac_md5_update(v2_session_response+16)client thing,8,&context); */ /* BB fix */ |
260 | 261 | ||
261 | hmac_md5_final(v2_session_response,&context); | 262 | hmac_md5_final(v2_session_response,&context); |
263 | cifs_dump_mem("v2_sess_rsp: ", v2_session_response, 32); /* BB removeme BB */ | ||
262 | } | 264 | } |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 79eeccd0437f..8219c02145a7 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -93,13 +93,10 @@ cifs_read_super(struct super_block *sb, void *data, | |||
93 | int rc = 0; | 93 | int rc = 0; |
94 | 94 | ||
95 | sb->s_flags |= MS_NODIRATIME; /* and probably even noatime */ | 95 | sb->s_flags |= MS_NODIRATIME; /* and probably even noatime */ |
96 | sb->s_fs_info = kmalloc(sizeof(struct cifs_sb_info),GFP_KERNEL); | 96 | sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info),GFP_KERNEL); |
97 | cifs_sb = CIFS_SB(sb); | 97 | cifs_sb = CIFS_SB(sb); |
98 | if(cifs_sb == NULL) | 98 | if(cifs_sb == NULL) |
99 | return -ENOMEM; | 99 | return -ENOMEM; |
100 | else | ||
101 | memset(cifs_sb,0,sizeof(struct cifs_sb_info)); | ||
102 | |||
103 | 100 | ||
104 | rc = cifs_mount(sb, cifs_sb, data, devname); | 101 | rc = cifs_mount(sb, cifs_sb, data, devname); |
105 | 102 | ||
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index 821a8eb22559..4cf10f23cda9 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h | |||
@@ -99,5 +99,5 @@ extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t); | |||
99 | extern ssize_t cifs_listxattr(struct dentry *, char *, size_t); | 99 | extern ssize_t cifs_listxattr(struct dentry *, char *, size_t); |
100 | extern int cifs_ioctl (struct inode * inode, struct file * filep, | 100 | extern int cifs_ioctl (struct inode * inode, struct file * filep, |
101 | unsigned int command, unsigned long arg); | 101 | unsigned int command, unsigned long arg); |
102 | #define CIFS_VERSION "1.40" | 102 | #define CIFS_VERSION "1.41" |
103 | #endif /* _CIFSFS_H */ | 103 | #endif /* _CIFSFS_H */ |
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 7bed27601ce5..006eb33bff5f 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * fs/cifs/cifsglob.h | 2 | * fs/cifs/cifsglob.h |
3 | * | 3 | * |
4 | * Copyright (C) International Business Machines Corp., 2002,2005 | 4 | * Copyright (C) International Business Machines Corp., 2002,2006 |
5 | * Author(s): Steve French (sfrench@us.ibm.com) | 5 | * Author(s): Steve French (sfrench@us.ibm.com) |
6 | * | 6 | * |
7 | * This library is free software; you can redistribute it and/or modify | 7 | * This library is free software; you can redistribute it and/or modify |
@@ -430,6 +430,15 @@ struct dir_notify_req { | |||
430 | #define CIFS_LARGE_BUFFER 2 | 430 | #define CIFS_LARGE_BUFFER 2 |
431 | #define CIFS_IOVEC 4 /* array of response buffers */ | 431 | #define CIFS_IOVEC 4 /* array of response buffers */ |
432 | 432 | ||
433 | /* Type of session setup needed */ | ||
434 | #define CIFS_PLAINTEXT 0 | ||
435 | #define CIFS_LANMAN 1 | ||
436 | #define CIFS_NTLM 2 | ||
437 | #define CIFS_NTLMSSP_NEG 3 | ||
438 | #define CIFS_NTLMSSP_AUTH 4 | ||
439 | #define CIFS_SPNEGO_INIT 5 | ||
440 | #define CIFS_SPNEGO_TARG 6 | ||
441 | |||
433 | /* | 442 | /* |
434 | ***************************************************************** | 443 | ***************************************************************** |
435 | * All constants go here | 444 | * All constants go here |
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 3c03aadaff0c..79e7f5a54323 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * fs/cifs/cifsproto.h | 2 | * fs/cifs/cifsproto.h |
3 | * | 3 | * |
4 | * Copyright (c) International Business Machines Corp., 2002,2005 | 4 | * Copyright (c) International Business Machines Corp., 2002,2006 |
5 | * Author(s): Steve French (sfrench@us.ibm.com) | 5 | * Author(s): Steve French (sfrench@us.ibm.com) |
6 | * | 6 | * |
7 | * This library is free software; you can redistribute it and/or modify | 7 | * This library is free software; you can redistribute it and/or modify |
@@ -64,6 +64,14 @@ extern int map_smb_to_linux_error(struct smb_hdr *smb); | |||
64 | extern void header_assemble(struct smb_hdr *, char /* command */ , | 64 | extern void header_assemble(struct smb_hdr *, char /* command */ , |
65 | const struct cifsTconInfo *, int /* length of | 65 | const struct cifsTconInfo *, int /* length of |
66 | fixed section (word count) in two byte units */); | 66 | fixed section (word count) in two byte units */); |
67 | #ifdef CONFIG_CIFS_EXPERIMENTAL | ||
68 | extern int small_smb_init_no_tc(const int smb_cmd, const int wct, | ||
69 | struct cifsSesInfo *ses, | ||
70 | void ** request_buf); | ||
71 | extern int CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, | ||
72 | const int stage, int * pNTLMv2_flg, | ||
73 | const struct nls_table *nls_cp); | ||
74 | #endif | ||
67 | extern __u16 GetNextMid(struct TCP_Server_Info *server); | 75 | extern __u16 GetNextMid(struct TCP_Server_Info *server); |
68 | extern struct oplock_q_entry * AllocOplockQEntry(struct inode *, u16, | 76 | extern struct oplock_q_entry * AllocOplockQEntry(struct inode *, u16, |
69 | struct cifsTconInfo *); | 77 | struct cifsTconInfo *); |
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index b41e8b379652..9d7bbd225eff 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * fs/cifs/cifssmb.c | 2 | * fs/cifs/cifssmb.c |
3 | * | 3 | * |
4 | * Copyright (C) International Business Machines Corp., 2002,2005 | 4 | * Copyright (C) International Business Machines Corp., 2002,2006 |
5 | * Author(s): Steve French (sfrench@us.ibm.com) | 5 | * Author(s): Steve French (sfrench@us.ibm.com) |
6 | * | 6 | * |
7 | * Contains the routines for constructing the SMB PDUs themselves | 7 | * Contains the routines for constructing the SMB PDUs themselves |
@@ -186,7 +186,35 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, | |||
186 | cifs_stats_inc(&tcon->num_smbs_sent); | 186 | cifs_stats_inc(&tcon->num_smbs_sent); |
187 | 187 | ||
188 | return rc; | 188 | return rc; |
189 | } | 189 | } |
190 | |||
191 | #ifdef CONFIG_CIFS_EXPERIMENTAL | ||
192 | int | ||
193 | small_smb_init_no_tc(const int smb_command, const int wct, | ||
194 | struct cifsSesInfo *ses, void **request_buf) | ||
195 | { | ||
196 | int rc; | ||
197 | struct smb_hdr * buffer; | ||
198 | |||
199 | rc = small_smb_init(smb_command, wct, NULL, request_buf); | ||
200 | if(rc) | ||
201 | return rc; | ||
202 | |||
203 | buffer = (struct smb_hdr *)*request_buf; | ||
204 | buffer->Mid = GetNextMid(ses->server); | ||
205 | if (ses->capabilities & CAP_UNICODE) | ||
206 | buffer->Flags2 |= SMBFLG2_UNICODE; | ||
207 | if (ses->capabilities & CAP_STATUS32) | ||
208 | buffer->Flags2 |= SMBFLG2_ERR_STATUS; | ||
209 | |||
210 | /* uid, tid can stay at zero as set in header assemble */ | ||
211 | |||
212 | /* BB add support for turning on the signing when | ||
213 | this function is used after 1st of session setup requests */ | ||
214 | |||
215 | return rc; | ||
216 | } | ||
217 | #endif /* CONFIG_CIFS_EXPERIMENTAL */ | ||
190 | 218 | ||
191 | /* If the return code is zero, this function must fill in request_buf pointer */ | 219 | /* If the return code is zero, this function must fill in request_buf pointer */ |
192 | static int | 220 | static int |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index ef5ae6f93c75..16535b510a96 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * fs/cifs/connect.c | 2 | * fs/cifs/connect.c |
3 | * | 3 | * |
4 | * Copyright (C) International Business Machines Corp., 2002,2005 | 4 | * Copyright (C) International Business Machines Corp., 2002,2006 |
5 | * Author(s): Steve French (sfrench@us.ibm.com) | 5 | * Author(s): Steve French (sfrench@us.ibm.com) |
6 | * | 6 | * |
7 | * This library is free software; you can redistribute it and/or modify | 7 | * This library is free software; you can redistribute it and/or modify |
@@ -2525,7 +2525,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2525 | __u32 negotiate_flags, capabilities; | 2525 | __u32 negotiate_flags, capabilities; |
2526 | __u16 count; | 2526 | __u16 count; |
2527 | 2527 | ||
2528 | cFYI(1, ("In NTLMSSP sesssetup (negotiate) ")); | 2528 | cFYI(1, ("In NTLMSSP sesssetup (negotiate)")); |
2529 | if(ses == NULL) | 2529 | if(ses == NULL) |
2530 | return -EINVAL; | 2530 | return -EINVAL; |
2531 | domain = ses->domainName; | 2531 | domain = ses->domainName; |
@@ -2575,7 +2575,8 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2575 | SecurityBlob->MessageType = NtLmNegotiate; | 2575 | SecurityBlob->MessageType = NtLmNegotiate; |
2576 | negotiate_flags = | 2576 | negotiate_flags = |
2577 | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_OEM | | 2577 | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_OEM | |
2578 | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_NTLM | 0x80000000 | | 2578 | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_NTLM | |
2579 | NTLMSSP_NEGOTIATE_56 | | ||
2579 | /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN | */ NTLMSSP_NEGOTIATE_128; | 2580 | /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN | */ NTLMSSP_NEGOTIATE_128; |
2580 | if(sign_CIFS_PDUs) | 2581 | if(sign_CIFS_PDUs) |
2581 | negotiate_flags |= NTLMSSP_NEGOTIATE_SIGN; | 2582 | negotiate_flags |= NTLMSSP_NEGOTIATE_SIGN; |
@@ -2588,26 +2589,11 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2588 | SecurityBlob->WorkstationName.Length = 0; | 2589 | SecurityBlob->WorkstationName.Length = 0; |
2589 | SecurityBlob->WorkstationName.MaximumLength = 0; | 2590 | SecurityBlob->WorkstationName.MaximumLength = 0; |
2590 | 2591 | ||
2591 | if (domain == NULL) { | 2592 | /* Domain not sent on first Sesssetup in NTLMSSP, instead it is sent |
2592 | SecurityBlob->DomainName.Buffer = 0; | 2593 | along with username on auth request (ie the response to challenge) */ |
2593 | SecurityBlob->DomainName.Length = 0; | 2594 | SecurityBlob->DomainName.Buffer = 0; |
2594 | SecurityBlob->DomainName.MaximumLength = 0; | 2595 | SecurityBlob->DomainName.Length = 0; |
2595 | } else { | 2596 | SecurityBlob->DomainName.MaximumLength = 0; |
2596 | __u16 len; | ||
2597 | negotiate_flags |= NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED; | ||
2598 | strncpy(bcc_ptr, domain, 63); | ||
2599 | len = strnlen(domain, 64); | ||
2600 | SecurityBlob->DomainName.MaximumLength = | ||
2601 | cpu_to_le16(len); | ||
2602 | SecurityBlob->DomainName.Buffer = | ||
2603 | cpu_to_le32((long) &SecurityBlob-> | ||
2604 | DomainString - | ||
2605 | (long) &SecurityBlob->Signature); | ||
2606 | bcc_ptr += len; | ||
2607 | SecurityBlobLength += len; | ||
2608 | SecurityBlob->DomainName.Length = | ||
2609 | cpu_to_le16(len); | ||
2610 | } | ||
2611 | if (ses->capabilities & CAP_UNICODE) { | 2597 | if (ses->capabilities & CAP_UNICODE) { |
2612 | if ((long) bcc_ptr % 2) { | 2598 | if ((long) bcc_ptr % 2) { |
2613 | *bcc_ptr = 0; | 2599 | *bcc_ptr = 0; |
@@ -2677,7 +2663,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2677 | SecurityBlob2->MessageType)); | 2663 | SecurityBlob2->MessageType)); |
2678 | } else if (ses) { | 2664 | } else if (ses) { |
2679 | ses->Suid = smb_buffer_response->Uid; /* UID left in le format */ | 2665 | ses->Suid = smb_buffer_response->Uid; /* UID left in le format */ |
2680 | cFYI(1, ("UID = %d ", ses->Suid)); | 2666 | cFYI(1, ("UID = %d", ses->Suid)); |
2681 | if ((pSMBr->resp.hdr.WordCount == 3) | 2667 | if ((pSMBr->resp.hdr.WordCount == 3) |
2682 | || ((pSMBr->resp.hdr.WordCount == 4) | 2668 | || ((pSMBr->resp.hdr.WordCount == 4) |
2683 | && (blob_len < | 2669 | && (blob_len < |
@@ -2685,17 +2671,17 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2685 | 2671 | ||
2686 | if (pSMBr->resp.hdr.WordCount == 4) { | 2672 | if (pSMBr->resp.hdr.WordCount == 4) { |
2687 | bcc_ptr += blob_len; | 2673 | bcc_ptr += blob_len; |
2688 | cFYI(1, | 2674 | cFYI(1, ("Security Blob Length %d", |
2689 | ("Security Blob Length %d ", | ||
2690 | blob_len)); | 2675 | blob_len)); |
2691 | } | 2676 | } |
2692 | 2677 | ||
2693 | cFYI(1, ("NTLMSSP Challenge rcvd ")); | 2678 | cFYI(1, ("NTLMSSP Challenge rcvd")); |
2694 | 2679 | ||
2695 | memcpy(ses->server->cryptKey, | 2680 | memcpy(ses->server->cryptKey, |
2696 | SecurityBlob2->Challenge, | 2681 | SecurityBlob2->Challenge, |
2697 | CIFS_CRYPTO_KEY_SIZE); | 2682 | CIFS_CRYPTO_KEY_SIZE); |
2698 | if(SecurityBlob2->NegotiateFlags & cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2)) | 2683 | if(SecurityBlob2->NegotiateFlags & |
2684 | cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2)) | ||
2699 | *pNTLMv2_flag = TRUE; | 2685 | *pNTLMv2_flag = TRUE; |
2700 | 2686 | ||
2701 | if((SecurityBlob2->NegotiateFlags & | 2687 | if((SecurityBlob2->NegotiateFlags & |
@@ -2818,7 +2804,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2818 | bcc_ptr++; | 2804 | bcc_ptr++; |
2819 | } else | 2805 | } else |
2820 | cFYI(1, | 2806 | cFYI(1, |
2821 | ("Variable field of length %d extends beyond end of smb ", | 2807 | ("Variable field of length %d extends beyond end of smb", |
2822 | len)); | 2808 | len)); |
2823 | } | 2809 | } |
2824 | } else { | 2810 | } else { |
@@ -2830,7 +2816,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2830 | } | 2816 | } |
2831 | } else { | 2817 | } else { |
2832 | cERROR(1, | 2818 | cERROR(1, |
2833 | (" Invalid Word count %d: ", | 2819 | (" Invalid Word count %d:", |
2834 | smb_buffer_response->WordCount)); | 2820 | smb_buffer_response->WordCount)); |
2835 | rc = -EIO; | 2821 | rc = -EIO; |
2836 | } | 2822 | } |
@@ -3447,7 +3433,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3447 | if (extended_security | 3433 | if (extended_security |
3448 | && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY) | 3434 | && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY) |
3449 | && (pSesInfo->server->secType == NTLMSSP)) { | 3435 | && (pSesInfo->server->secType == NTLMSSP)) { |
3450 | cFYI(1, ("New style sesssetup ")); | 3436 | cFYI(1, ("New style sesssetup")); |
3451 | rc = CIFSSpnegoSessSetup(xid, pSesInfo, | 3437 | rc = CIFSSpnegoSessSetup(xid, pSesInfo, |
3452 | NULL /* security blob */, | 3438 | NULL /* security blob */, |
3453 | 0 /* blob length */, | 3439 | 0 /* blob length */, |
@@ -3455,7 +3441,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, | |||
3455 | } else if (extended_security | 3441 | } else if (extended_security |
3456 | && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY) | 3442 | && (pSesInfo->capabilities & CAP_EXTENDED_SECURITY) |
3457 | && (pSesInfo->server->secType == RawNTLMSSP)) { | 3443 | && (pSesInfo->server->secType == RawNTLMSSP)) { |
3458 | cFYI(1, ("NTLMSSP sesssetup ")); | 3444 | cFYI(1, ("NTLMSSP sesssetup")); |
3459 | rc = CIFSNTLMSSPNegotiateSessSetup(xid, | 3445 | rc = CIFSNTLMSSPNegotiateSessSetup(xid, |
3460 | pSesInfo, | 3446 | pSesInfo, |
3461 | &ntlmv2_flag, | 3447 | &ntlmv2_flag, |
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index fed55e3c53df..77e1fc01d747 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c | |||
@@ -255,12 +255,10 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, | |||
255 | CIFSSMBClose(xid, pTcon, fileHandle); | 255 | CIFSSMBClose(xid, pTcon, fileHandle); |
256 | } else if(newinode) { | 256 | } else if(newinode) { |
257 | pCifsFile = | 257 | pCifsFile = |
258 | kmalloc(sizeof (struct cifsFileInfo), GFP_KERNEL); | 258 | kzalloc(sizeof (struct cifsFileInfo), GFP_KERNEL); |
259 | 259 | ||
260 | if(pCifsFile == NULL) | 260 | if(pCifsFile == NULL) |
261 | goto cifs_create_out; | 261 | goto cifs_create_out; |
262 | memset((char *)pCifsFile, 0, | ||
263 | sizeof (struct cifsFileInfo)); | ||
264 | pCifsFile->netfid = fileHandle; | 262 | pCifsFile->netfid = fileHandle; |
265 | pCifsFile->pid = current->tgid; | 263 | pCifsFile->pid = current->tgid; |
266 | pCifsFile->pInode = newinode; | 264 | pCifsFile->pInode = newinode; |
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 59359911f481..0fb42feff3c7 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -609,9 +609,8 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
609 | } | 609 | } |
610 | } else if (rc == -EACCES) { | 610 | } else if (rc == -EACCES) { |
611 | /* try only if r/o attribute set in local lookup data? */ | 611 | /* try only if r/o attribute set in local lookup data? */ |
612 | pinfo_buf = kmalloc(sizeof(FILE_BASIC_INFO), GFP_KERNEL); | 612 | pinfo_buf = kzalloc(sizeof(FILE_BASIC_INFO), GFP_KERNEL); |
613 | if (pinfo_buf) { | 613 | if (pinfo_buf) { |
614 | memset(pinfo_buf, 0, sizeof(FILE_BASIC_INFO)); | ||
615 | /* ATTRS set to normal clears r/o bit */ | 614 | /* ATTRS set to normal clears r/o bit */ |
616 | pinfo_buf->Attributes = cpu_to_le32(ATTR_NORMAL); | 615 | pinfo_buf->Attributes = cpu_to_le32(ATTR_NORMAL); |
617 | if (!(pTcon->ses->flags & CIFS_SES_NT4)) | 616 | if (!(pTcon->ses->flags & CIFS_SES_NT4)) |
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index 812c6bb0fe38..0f3ebad09d3e 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c | |||
@@ -72,10 +72,9 @@ sesInfoAlloc(void) | |||
72 | struct cifsSesInfo *ret_buf; | 72 | struct cifsSesInfo *ret_buf; |
73 | 73 | ||
74 | ret_buf = | 74 | ret_buf = |
75 | (struct cifsSesInfo *) kmalloc(sizeof (struct cifsSesInfo), | 75 | (struct cifsSesInfo *) kzalloc(sizeof (struct cifsSesInfo), |
76 | GFP_KERNEL); | 76 | GFP_KERNEL); |
77 | if (ret_buf) { | 77 | if (ret_buf) { |
78 | memset(ret_buf, 0, sizeof (struct cifsSesInfo)); | ||
79 | write_lock(&GlobalSMBSeslock); | 78 | write_lock(&GlobalSMBSeslock); |
80 | atomic_inc(&sesInfoAllocCount); | 79 | atomic_inc(&sesInfoAllocCount); |
81 | ret_buf->status = CifsNew; | 80 | ret_buf->status = CifsNew; |
@@ -110,10 +109,9 @@ tconInfoAlloc(void) | |||
110 | { | 109 | { |
111 | struct cifsTconInfo *ret_buf; | 110 | struct cifsTconInfo *ret_buf; |
112 | ret_buf = | 111 | ret_buf = |
113 | (struct cifsTconInfo *) kmalloc(sizeof (struct cifsTconInfo), | 112 | (struct cifsTconInfo *) kzalloc(sizeof (struct cifsTconInfo), |
114 | GFP_KERNEL); | 113 | GFP_KERNEL); |
115 | if (ret_buf) { | 114 | if (ret_buf) { |
116 | memset(ret_buf, 0, sizeof (struct cifsTconInfo)); | ||
117 | write_lock(&GlobalSMBSeslock); | 115 | write_lock(&GlobalSMBSeslock); |
118 | atomic_inc(&tconInfoAllocCount); | 116 | atomic_inc(&tconInfoAllocCount); |
119 | list_add(&ret_buf->cifsConnectionList, | 117 | list_add(&ret_buf->cifsConnectionList, |
diff --git a/fs/cifs/ntlmssp.c b/fs/cifs/ntlmssp.c new file mode 100644 index 000000000000..4aabe2d7cb7b --- /dev/null +++ b/fs/cifs/ntlmssp.c | |||
@@ -0,0 +1,130 @@ | |||
1 | /* | ||
2 | * fs/cifs/ntlmssp.h | ||
3 | * | ||
4 | * Copyright (c) International Business Machines Corp., 2006 | ||
5 | * Author(s): Steve French (sfrench@us.ibm.com) | ||
6 | * | ||
7 | * This library is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU Lesser General Public License as published | ||
9 | * by the Free Software Foundation; either version 2.1 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This library is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See | ||
15 | * the GNU Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public License | ||
18 | * along with this library; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | |||
22 | #include "cifspdu.h" | ||
23 | #include "cifsglob.h" | ||
24 | #include "cifsproto.h" | ||
25 | #include "cifs_unicode.h" | ||
26 | #include "cifs_debug.h" | ||
27 | #include "ntlmssp.h" | ||
28 | #include "nterr.h" | ||
29 | |||
30 | #ifdef CONFIG_CIFS_EXPERIMENTAL | ||
31 | static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB) | ||
32 | { | ||
33 | __u32 capabilities = 0; | ||
34 | |||
35 | /* init fields common to all four types of SessSetup */ | ||
36 | /* note that header is initialized to zero in header_assemble */ | ||
37 | pSMB->req.AndXCommand = 0xFF; | ||
38 | pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); | ||
39 | pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); | ||
40 | |||
41 | /* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */ | ||
42 | |||
43 | /* BB verify whether signing required on neg or just on auth frame | ||
44 | (and NTLM case) */ | ||
45 | |||
46 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | | ||
47 | CAP_LARGE_WRITE_X | CAP_LARGE_READ_X; | ||
48 | |||
49 | if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | ||
50 | pSMB->req.hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | ||
51 | |||
52 | if (ses->capabilities & CAP_UNICODE) { | ||
53 | pSMB->req.hdr.Flags2 |= SMBFLG2_UNICODE; | ||
54 | capabilities |= CAP_UNICODE; | ||
55 | } | ||
56 | if (ses->capabilities & CAP_STATUS32) { | ||
57 | pSMB->req.hdr.Flags2 |= SMBFLG2_ERR_STATUS; | ||
58 | capabilities |= CAP_STATUS32; | ||
59 | } | ||
60 | if (ses->capabilities & CAP_DFS) { | ||
61 | pSMB->req.hdr.Flags2 |= SMBFLG2_DFS; | ||
62 | capabilities |= CAP_DFS; | ||
63 | } | ||
64 | |||
65 | /* BB check whether to init vcnum BB */ | ||
66 | return capabilities; | ||
67 | } | ||
68 | int | ||
69 | CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, const int type, | ||
70 | int * pNTLMv2_flg, const struct nls_table *nls_cp) | ||
71 | { | ||
72 | int rc = 0; | ||
73 | int wct; | ||
74 | struct smb_hdr *smb_buffer; | ||
75 | char *bcc_ptr; | ||
76 | SESSION_SETUP_ANDX *pSMB; | ||
77 | __u32 capabilities; | ||
78 | |||
79 | if(ses == NULL) | ||
80 | return -EINVAL; | ||
81 | |||
82 | cFYI(1,("SStp type: %d",type)); | ||
83 | if(type < CIFS_NTLM) { | ||
84 | #ifndef CONFIG_CIFS_WEAK_PW_HASH | ||
85 | /* LANMAN and plaintext are less secure and off by default. | ||
86 | So we make this explicitly be turned on in kconfig (in the | ||
87 | build) and turned on at runtime (changed from the default) | ||
88 | in proc/fs/cifs or via mount parm. Unfortunately this is | ||
89 | needed for old Win (e.g. Win95), some obscure NAS and OS/2 */ | ||
90 | return -EOPNOTSUPP; | ||
91 | #endif | ||
92 | wct = 10; /* lanman 2 style sessionsetup */ | ||
93 | } else if(type < CIFS_NTLMSSP_NEG) | ||
94 | wct = 13; /* old style NTLM sessionsetup */ | ||
95 | else /* same size for negotiate or auth, NTLMSSP or extended security */ | ||
96 | wct = 12; | ||
97 | |||
98 | rc = small_smb_init_no_tc(SMB_COM_SESSION_SETUP_ANDX, wct, ses, | ||
99 | (void **)&smb_buffer); | ||
100 | if(rc) | ||
101 | return rc; | ||
102 | |||
103 | pSMB = (SESSION_SETUP_ANDX *)smb_buffer; | ||
104 | |||
105 | capabilities = cifs_ssetup_hdr(ses, pSMB); | ||
106 | bcc_ptr = pByteArea(smb_buffer); | ||
107 | if(type > CIFS_NTLM) { | ||
108 | pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC; | ||
109 | capabilities |= CAP_EXTENDED_SECURITY; | ||
110 | pSMB->req.Capabilities = cpu_to_le32(capabilities); | ||
111 | /* BB set password lengths */ | ||
112 | } else if(type < CIFS_NTLM) /* lanman */ { | ||
113 | /* no capabilities flags in old lanman negotiation */ | ||
114 | /* pSMB->old_req.PasswordLength = */ /* BB fixme BB */ | ||
115 | } else /* type CIFS_NTLM */ { | ||
116 | pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities); | ||
117 | pSMB->req_no_secext.CaseInsensitivePasswordLength = | ||
118 | cpu_to_le16(CIFS_SESSION_KEY_SIZE); | ||
119 | pSMB->req_no_secext.CaseSensitivePasswordLength = | ||
120 | cpu_to_le16(CIFS_SESSION_KEY_SIZE); | ||
121 | } | ||
122 | |||
123 | |||
124 | /* rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buf_type, 0); */ | ||
125 | |||
126 | cifs_small_buf_release(smb_buffer); | ||
127 | |||
128 | return rc; | ||
129 | } | ||
130 | #endif /* CONFIG_CIFS_EXPERIMENTAL */ | ||
diff --git a/fs/cifs/ntlmssp.h b/fs/cifs/ntlmssp.h index 803389b64a2c..d39b712a11c5 100644 --- a/fs/cifs/ntlmssp.h +++ b/fs/cifs/ntlmssp.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * fs/cifs/ntlmssp.h | 2 | * fs/cifs/ntlmssp.h |
3 | * | 3 | * |
4 | * Copyright (c) International Business Machines Corp., 2002 | 4 | * Copyright (c) International Business Machines Corp., 2002,2006 |
5 | * Author(s): Steve French (sfrench@us.ibm.com) | 5 | * Author(s): Steve French (sfrench@us.ibm.com) |
6 | * | 6 | * |
7 | * This library is free software; you can redistribute it and/or modify | 7 | * This library is free software; you can redistribute it and/or modify |