···11+Version 1.4022+------------33+Use fsuid (fsgid) more consistently instead of uid (gid). Improve performance44+of readpages by eliminating one extra memcpy. Allow update of file size55+from remote server even if file is open for write as long as mount is66+directio. Recognize share mode security and send NTLM encrypted password77+on tree connect if share mode negotiated.88+19Version 1.39210------------311Defer close of a file handle slightly if pending writes depend on that handle···157CIFS Unix Extensions. Fix setfacl/getfacl on bigendian. Timeout negative168dentries so files that the client sees as deleted but that later get created179on the server will be recognized. Add client side permission check on setattr.1010+Timeout stuck requests better (where server has never responded or sent corrupt1111+responses)18121913Version 1.382014------------
+11-1
fs/cifs/README
···436436 SFU does). In the future the bottom 9 bits of the mode437437 mode also will be emulated using queries of the security438438 descriptor (ACL).439439-439439+sec Security mode. Allowed values are:440440+ none attempt to connection as a null user (no name)441441+ krb5 Use Kerberos version 5 authentication442442+ krb5i Use Kerberos authentication and packet signing443443+ ntlm Use NTLM password hashing (default)444444+ ntlmi Use NTLM password hashing with signing (if445445+ /proc/fs/cifs/PacketSigningEnabled on or if446446+ server requires signing also can be the default) 447447+ ntlmv2 Use NTLMv2 password hashing 448448+ ntlmv2i Use NTLMv2 password hashing with packet signing449449+440450The mount.cifs mount helper also accepts a few mount options before -o441451including:442452
+31-20
fs/cifs/cifs_debug.c
···219219220220 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {221221 read_lock(&GlobalSMBSeslock);222222+#ifdef CONFIG_CIFS_STATS2223223+ atomic_set(&totBufAllocCount, 0);224224+ atomic_set(&totSmBufAllocCount, 0);225225+#endif /* CONFIG_CIFS_STATS2 */222226 list_for_each(tmp, &GlobalTreeConnectionList) {223227 tcon = list_entry(tmp, struct cifsTconInfo,224228 cifsConnectionList);···280276 smBufAllocCount.counter,cifs_min_small);281277 length += item_length;282278 buf += item_length;279279+#ifdef CONFIG_CIFS_STATS2280280+ item_length = sprintf(buf, "Total Large %d Small %d Allocations\n",281281+ atomic_read(&totBufAllocCount),282282+ atomic_read(&totSmBufAllocCount));283283+ length += item_length;284284+ buf += item_length;285285+#endif /* CONFIG_CIFS_STATS2 */286286+283287 item_length = 284288 sprintf(buf,"Operations (MIDs): %d\n",285289 midCount.counter);···401389static write_proc_t ntlmv2_enabled_write;402390static read_proc_t packet_signing_enabled_read;403391static write_proc_t packet_signing_enabled_write;404404-static read_proc_t quotaEnabled_read;405405-static write_proc_t quotaEnabled_write;392392+static read_proc_t experimEnabled_read;393393+static write_proc_t experimEnabled_write;406394static read_proc_t linuxExtensionsEnabled_read;407395static write_proc_t linuxExtensionsEnabled_write;408396···442430 pde->write_proc = oplockEnabled_write;443431444432 pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs,445445- quotaEnabled_read, NULL);433433+ experimEnabled_read, NULL);446434 if (pde)447447- pde->write_proc = quotaEnabled_write;435435+ pde->write_proc = experimEnabled_write;448436449437 pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,450438 linuxExtensionsEnabled_read, NULL);···586574}587575588576static int589589-quotaEnabled_read(char *page, char **start, off_t off,577577+experimEnabled_read(char *page, char **start, off_t off,590578 int count, int *eof, void *data)591579{592580 int len;593581594582 len = sprintf(page, "%d\n", experimEnabled);595595-/* could also check if quotas are enabled in kernel596596- as a whole first */583583+597584 len -= off;598585 *start = page + off;599586···607596 return len;608597}609598static int610610-quotaEnabled_write(struct file *file, const char __user *buffer,599599+experimEnabled_write(struct file *file, const char __user *buffer,611600 unsigned long count, void *data)612601{613613- char c;614614- int rc;602602+ char c;603603+ int rc;615604616616- rc = get_user(c, buffer);617617- if (rc)618618- return rc;619619- if (c == '0' || c == 'n' || c == 'N')620620- experimEnabled = 0;621621- else if (c == '1' || c == 'y' || c == 'Y')622622- experimEnabled = 1;605605+ rc = get_user(c, buffer);606606+ if (rc)607607+ return rc;608608+ if (c == '0' || c == 'n' || c == 'N')609609+ experimEnabled = 0;610610+ else if (c == '1' || c == 'y' || c == 'Y')611611+ experimEnabled = 1;612612+ else if (c == '2')613613+ experimEnabled = 2;623614624624- return count;615615+ return count;625616}626617627618static int···633620 int len;634621635622 len = sprintf(page, "%d\n", linuxExtEnabled);636636-/* could also check if quotas are enabled in kernel637637- as a whole first */638623 len -= off;639624 *start = page + off;640625
+3-2
fs/cifs/cifs_fs_sb.h
···2424#define CIFS_MOUNT_DIRECT_IO 8 /* do not write nor read through page cache */2525#define CIFS_MOUNT_NO_XATTR 0x10 /* if set - disable xattr support */2626#define CIFS_MOUNT_MAP_SPECIAL_CHR 0x20 /* remap illegal chars in filenames */2727-#define CIFS_MOUNT_POSIX_PATHS 0x40 /* Negotiate posix pathnames if possible. */2828-#define CIFS_MOUNT_UNX_EMUL 0x80 /* Network compat with SFUnix emulation */2727+#define CIFS_MOUNT_POSIX_PATHS 0x40 /* Negotiate posix pathnames if possible. */2828+#define CIFS_MOUNT_UNX_EMUL 0x80 /* Network compat with SFUnix emulation */2929#define CIFS_MOUNT_NO_BRL 0x100 /* No sending byte range locks to srv */3030+#define CIFS_MOUNT_CIFS_ACL 0x200 /* send ACL requests to non-POSIX srv */30313132struct cifs_sb_info {3233 struct cifsTconInfo *tcon; /* primary mount */
+38
fs/cifs/cifsacl.h
···11+/*22+ * fs/cifs/cifsacl.h33+ *44+ * Copyright (c) International Business Machines Corp., 200555+ * Author(s): Steve French (sfrench@us.ibm.com)66+ *77+ * This library is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU Lesser General Public License as published99+ * by the Free Software Foundation; either version 2.1 of the License, or1010+ * (at your option) any later version.1111+ *1212+ * This library is distributed in the hope that it will be useful,1313+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See1515+ * the GNU Lesser General Public License for more details.1616+ *1717+ * You should have received a copy of the GNU Lesser General Public License1818+ * along with this library; if not, write to the Free Software1919+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2020+ */2121+2222+#ifndef _CIFSACL_H2323+#define _CIFSACL_H2424+2525+struct cifs_sid {2626+ __u8 revision; /* revision level */2727+ __u8 num_subauths;2828+ __u8 authority[6];2929+ __u32 sub_auth[4];3030+ /* next sub_auth if any ... */3131+} __attribute__((packed));3232+3333+/* everyone */3434+extern const struct cifs_sid sid_everyone;3535+/* group users */3636+extern const struct cifs_sid sid_user;3737+3838+#endif /* _CIFSACL_H */
···233233 atomic_t num_hardlinks;234234 atomic_t num_symlinks;235235 atomic_t num_locks;236236+ atomic_t num_acl_get;237237+ atomic_t num_acl_set;236238#ifdef CONFIG_CIFS_STATS2237239 unsigned long long time_writes;238240 unsigned long long time_reads;···287285 unsigned endOfSearch:1;288286 unsigned emptyDir:1;289287 unsigned unicode:1;288288+ unsigned smallBuf:1; /* so we know which buf_release function to call */290289};291290292291struct cifsFileInfo {···423420#define MID_RESPONSE_RECEIVED 4424421#define MID_RETRY_NEEDED 8 /* session closed while this request out */425422#define MID_NO_RESP_NEEDED 0x10426426-#define MID_SMALL_BUFFER 0x20 /* 112 byte response buffer instead of 4K */423423+424424+/* Types of response buffer returned from SendReceive2 */425425+#define CIFS_NO_BUFFER 0 /* Response buffer not returned */426426+#define CIFS_SMALL_BUFFER 1427427+#define CIFS_LARGE_BUFFER 2428428+#define CIFS_IOVEC 4 /* array of response buffers */427429428430/*429431 *****************************************************************···513505GLOBAL_EXTERN atomic_t tconInfoReconnectCount;514506515507/* Various Debug counters to remove someday (BB) */516516-GLOBAL_EXTERN atomic_t bufAllocCount;517517-GLOBAL_EXTERN atomic_t smBufAllocCount; 508508+GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */509509+#ifdef CONFIG_CIFS_STATS2510510+GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */511511+GLOBAL_EXTERN atomic_t totSmBufAllocCount;512512+#endif513513+GLOBAL_EXTERN atomic_t smBufAllocCount;518514GLOBAL_EXTERN atomic_t midCount;519515520516/* Misc globals */
+84-13
fs/cifs/cifspdu.h
···11/*22 * fs/cifs/cifspdu.h33 *44- * Copyright (c) International Business Machines Corp., 200244+ * Copyright (c) International Business Machines Corp., 2002,200555 * Author(s): Steve French (sfrench@us.ibm.com)66 *77 * This library is free software; you can redistribute it and/or modify···8080#define NT_TRANSACT_GET_USER_QUOTA 0x078181#define NT_TRANSACT_SET_USER_QUOTA 0x0882828383-#define MAX_CIFS_HDR_SIZE 256 /* is future chained NTCreateXReadX bigger? */8383+#define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */8484+/* future chained NTCreateXReadX bigger, but for time being NTCreateX biggest */8585+/* among the requests (NTCreateX response is bigger with wct of 34) */8686+#define MAX_CIFS_HDR_SIZE 0x58 /* 4 len + 32 hdr + (2*24 wct) + 2 bct + 2 pad */8787+#define CIFS_SMALL_PATH 120 /* allows for (448-88)/3 */84888589/* internal cifs vfs structures */8690/*****************************************************************···528524 /* STRING PrimaryDomain */529525 /* STRING NativeOS */530526 /* STRING NativeLanMan */531531- } __attribute__((packed)) old_req; /* pre-NTLM (LANMAN2.1) request format */527527+ } __attribute__((packed)) old_req; /* pre-NTLM (LANMAN2.1) req format */532528533529 struct { /* default (NTLM) response format */534530 struct smb_hdr hdr; /* wct = 3 */···540536 unsigned char NativeOS[1]; /* followed by */541537/* unsigned char * NativeLanMan; */542538/* unsigned char * PrimaryDomain; */543543- } __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response format */539539+ } __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response */544540} __attribute__((packed)) SESSION_SETUP_ANDX;545541546542#define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"···1007100310081004/* empty wct response to setattr */1009100510101010-/***************************************************/10111011-/* NT Transact structure defintions follow */10121012-/* Currently only ioctl and notify are implemented */10131013-/***************************************************/10061006+/*******************************************************/10071007+/* NT Transact structure defintions follow */10081008+/* Currently only ioctl, acl (get security descriptor) */ 10091009+/* and notify are implemented */10101010+/*******************************************************/10111011+typedef struct smb_com_ntransact_req {10121012+ struct smb_hdr hdr; /* wct >= 19 */10131013+ __u8 MaxSetupCount;10141014+ __u16 Reserved;10151015+ __le32 TotalParameterCount;10161016+ __le32 TotalDataCount;10171017+ __le32 MaxParameterCount;10181018+ __le32 MaxDataCount;10191019+ __le32 ParameterCount;10201020+ __le32 ParameterOffset;10211021+ __le32 DataCount;10221022+ __le32 DataOffset;10231023+ __u8 SetupCount; /* four setup words follow subcommand */10241024+ /* SNIA spec incorrectly included spurious pad here */10251025+ __le16 SubCommand; /* 2 = IOCTL/FSCTL */10261026+ /* SetupCount words follow then */ 10271027+ __le16 ByteCount;10281028+ __u8 Pad[3];10291029+ __u8 Parms[0];10301030+} __attribute__((packed)) NTRANSACT_REQ;10311031+10321032+typedef struct smb_com_ntransact_rsp {10331033+ struct smb_hdr hdr; /* wct = 18 */10341034+ __u8 Reserved[3];10351035+ __le32 TotalParameterCount;10361036+ __le32 TotalDataCount;10371037+ __le32 ParameterCount;10381038+ __le32 ParameterOffset;10391039+ __le32 ParameterDisplacement;10401040+ __le32 DataCount;10411041+ __le32 DataOffset;10421042+ __le32 DataDisplacement;10431043+ __u8 SetupCount; /* 0 */10441044+ __u16 ByteCount;10451045+ /* __u8 Pad[3]; */10461046+ /* parms and data follow */10471047+} __attribute__((packed)) NTRANSACT_RSP;10481048+10141049typedef struct smb_com_transaction_ioctl_req {10151050 struct smb_hdr hdr; /* wct = 23 */10161051 __u8 MaxSetupCount;···10641021 __le32 DataOffset;10651022 __u8 SetupCount; /* four setup words follow subcommand */10661023 /* SNIA spec incorrectly included spurious pad here */10671067- __le16 SubCommand;/* 2 = IOCTL/FSCTL */10241024+ __le16 SubCommand; /* 2 = IOCTL/FSCTL */10681025 __le32 FunctionCode;10691026 __u16 Fid;10701070- __u8 IsFsctl; /* 1 = File System Control, 0 = device control (IOCTL)*/10711071- __u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS share)*/10271027+ __u8 IsFsctl; /* 1 = File System Control 0 = device control (IOCTL) */10281028+ __u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS) */10721029 __le16 ByteCount;10731030 __u8 Pad[3];10741031 __u8 Data[1];···10881045 __u8 SetupCount; /* 1 */10891046 __le16 ReturnedDataLen;10901047 __u16 ByteCount;10911091- __u8 Pad[3];10921048} __attribute__((packed)) TRANSACT_IOCTL_RSP;10491049+10501050+#define CIFS_ACL_OWNER 110511051+#define CIFS_ACL_GROUP 210521052+#define CIFS_ACL_DACL 410531053+#define CIFS_ACL_SACL 810541054+10551055+typedef struct smb_com_transaction_qsec_req {10561056+ struct smb_hdr hdr; /* wct = 19 */10571057+ __u8 MaxSetupCount;10581058+ __u16 Reserved;10591059+ __le32 TotalParameterCount;10601060+ __le32 TotalDataCount;10611061+ __le32 MaxParameterCount;10621062+ __le32 MaxDataCount;10631063+ __le32 ParameterCount;10641064+ __le32 ParameterOffset;10651065+ __le32 DataCount;10661066+ __le32 DataOffset;10671067+ __u8 SetupCount; /* no setup words follow subcommand */10681068+ /* SNIA spec incorrectly included spurious pad here */10691069+ __le16 SubCommand; /* 6 = QUERY_SECURITY_DESC */10701070+ __le16 ByteCount; /* bcc = 3 + 8 */10711071+ __u8 Pad[3];10721072+ __u16 Fid;10731073+ __u16 Reserved2;10741074+ __le32 AclFlags;10751075+} __attribute__((packed)) QUERY_SEC_DESC_REQ;1093107610941077typedef struct smb_com_transaction_change_notify_req {10951078 struct smb_hdr hdr; /* wct = 23 */···11371068 __u8 WatchTree; /* 1 = Monitor subdirectories */11381069 __u8 Reserved2;11391070 __le16 ByteCount;11401140-/* __u8 Pad[3];*/10711071+/* __u8 Pad[3];*/11411072/* __u8 Data[1];*/11421073} __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_REQ;1143107410751075+/* BB eventually change to use generic ntransact rsp struct 10761076+ and validation routine */11441077typedef struct smb_com_transaction_change_notify_rsp {11451078 struct smb_hdr hdr; /* wct = 18 */11461079 __u8 Reserved[3];
+14-9
fs/cifs/cifsproto.h
···4848 struct smb_hdr * /* out */ ,4949 int * /* bytes returned */ , const int long_op);5050extern int SendReceive2(const unsigned int /* xid */ , struct cifsSesInfo *,5151- struct kvec *, int /* nvec */,5252- int * /* bytes returned */ , const int long_op);5151+ struct kvec *, int /* nvec to send */, 5252+ int * /* type of buf returned */ , const int long_op);5353extern int checkSMBhdr(struct smb_hdr *smb, __u16 mid);5454extern int checkSMB(struct smb_hdr *smb, __u16 mid, int length);5555extern int is_valid_oplock_break(struct smb_hdr *smb);···9393 const struct nls_table *);94949595extern int CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,9696- const char *searchName, const struct nls_table *nls_codepage,9797- __u16 *searchHandle, struct cifs_search_info * psrch_inf, int map, const char dirsep);9696+ const char *searchName, const struct nls_table *nls_codepage,9797+ __u16 *searchHandle, struct cifs_search_info * psrch_inf, 9898+ int map, const char dirsep);989999100extern int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,100100- __u16 searchHandle, struct cifs_search_info * psrch_inf);101101+ __u16 searchHandle, struct cifs_search_info * psrch_inf);101102102103extern int CIFSFindClose(const int, struct cifsTconInfo *tcon,103104 const __u16 search_handle);···231230 const int smb_file_id);232231233232extern int CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,234234- const int netfid, unsigned int count,235235- const __u64 lseek, unsigned int *nbytes, char **buf);233233+ const int netfid, unsigned int count,234234+ const __u64 lseek, unsigned int *nbytes, char **buf,235235+ int * return_buf_type);236236extern int CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,237237 const int netfid, const unsigned int count,238238 const __u64 lseek, unsigned int *nbytes,239239 const char *buf, const char __user *ubuf, 240240 const int long_op);241241-#ifdef CONFIG_CIFS_EXPERIMENTAL242241extern int CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,243242 const int netfid, const unsigned int count,244243 const __u64 offset, unsigned int *nbytes, 245244 struct kvec *iov, const int nvec, const int long_op);246246-#endif /* CONFIG_CIFS_EXPERIMENTAL */247245extern int CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,248246 const unsigned char *searchName, __u64 * inode_number,249247 const struct nls_table *nls_codepage, ···269269extern int cifs_reconnect(struct TCP_Server_Info *server);270270271271extern int cifs_sign_smb(struct smb_hdr *, struct TCP_Server_Info *,__u32 *);272272+extern int cifs_sign_smb2(struct kvec *iov, int n_vec, struct TCP_Server_Info *,273273+ __u32 *);272274extern int cifs_verify_signature(struct smb_hdr *, const char * mac_key,273275 __u32 expected_sequence_number);274276extern int cifs_calculate_mac_key(char * key,const char * rn,const char * pass);···299297 const char *fileName, const char * ea_name, 300298 const void * ea_value, const __u16 ea_value_len, 301299 const struct nls_table *nls_codepage, int remap_special_chars);300300+extern int CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon,301301+ __u16 fid, char *acl_inf, const int buflen,302302+ const int acl_type /* ACCESS vs. DEFAULT */);302303extern int CIFSSMBGetPosixACL(const int xid, struct cifsTconInfo *tcon,303304 const unsigned char *searchName,304305 char *acl_inf, const int buflen,const int acl_type,
+247-47
fs/cifs/cifssmb.c
···3737#include "cifsproto.h"3838#include "cifs_unicode.h"3939#include "cifs_debug.h"4040+#include "cifsacl.h"40414142#ifdef CONFIG_CIFS_POSIX4243static struct {···373372 rc = SendReceive(xid, ses, (struct smb_hdr *) pSMB,374373 (struct smb_hdr *) pSMBr, &bytes_returned, 0);375374 if (rc == 0) {376376- server->secMode = pSMBr->SecurityMode; 377377- server->secType = NTLM; /* BB override default for 375375+ server->secMode = pSMBr->SecurityMode;376376+ if((server->secMode & SECMODE_USER) == 0)377377+ cFYI(1,("share mode security"));378378+ server->secType = NTLM; /* BB override default for378379 NTLMv2 or kerberos v5 */379380 /* one byte - no need to convert this or EncryptionKeyLen380381 from little endian */···386383 min(le32_to_cpu(pSMBr->MaxBufferSize),387384 (__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);388385 server->maxRw = le32_to_cpu(pSMBr->MaxRawSize);389389- cFYI(0, ("Max buf = %d ", ses->server->maxBuf));386386+ cFYI(0, ("Max buf = %d", ses->server->maxBuf));390387 GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey);391388 server->capabilities = le32_to_cpu(pSMBr->Capabilities);392389 server->timeZone = le16_to_cpu(pSMBr->ServerTimeZone); ···414411 (server->server_GUID,415412 pSMBr->u.extended_response.416413 GUID, 16) != 0) {417417- cFYI(1,418418- ("UID of server does not match previous connection to same ip address"));414414+ cFYI(1, ("server UID changed"));419415 memcpy(server->420416 server_GUID,421417 pSMBr->u.···960958 return rc;961959}962960963963-/* If no buffer passed in, then caller wants to do the copy964964- as in the case of readpages so the SMB buffer must be965965- freed by the caller */966966-967961int968962CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,969969- const int netfid, const unsigned int count,970970- const __u64 lseek, unsigned int *nbytes, char **buf)963963+ const int netfid, const unsigned int count,964964+ const __u64 lseek, unsigned int *nbytes, char **buf,965965+ int * pbuf_type)971966{972967 int rc = -EACCES;973968 READ_REQ *pSMB = NULL;974969 READ_RSP *pSMBr = NULL;975970 char *pReadData = NULL;976976- int bytes_returned;977971 int wct;972972+ int resp_buf_type = 0;973973+ struct kvec iov[1];978974979975 cFYI(1,("Reading %d bytes on fid %d",count,netfid));980976 if(tcon->ses->capabilities & CAP_LARGE_FILES)···981981 wct = 10; /* old style read */982982983983 *nbytes = 0;984984- rc = smb_init(SMB_COM_READ_ANDX, wct, tcon, (void **) &pSMB,985985- (void **) &pSMBr);984984+ rc = small_smb_init(SMB_COM_READ_ANDX, wct, tcon, (void **) &pSMB);986985 if (rc)987986 return rc;988987···989990 if (tcon->ses->server == NULL)990991 return -ECONNABORTED;991992992992- pSMB->AndXCommand = 0xFF; /* none */993993+ pSMB->AndXCommand = 0xFF; /* none */993994 pSMB->Fid = netfid;994995 pSMB->OffsetLow = cpu_to_le32(lseek & 0xFFFFFFFF);995996 if(wct == 12)996997 pSMB->OffsetHigh = cpu_to_le32(lseek >> 32);997997- else if((lseek >> 32) > 0) /* can not handle this big offset for old */998998- return -EIO;998998+ else if((lseek >> 32) > 0) /* can not handle this big offset for old */999999+ return -EIO;999100010001001 pSMB->Remaining = 0;10011002 pSMB->MaxCount = cpu_to_le16(count & 0xFFFF);···10041005 pSMB->ByteCount = 0; /* no need to do le conversion since 0 */10051006 else {10061007 /* old style read */10071007- struct smb_com_readx_req * pSMBW = 10081008+ struct smb_com_readx_req * pSMBW =10081009 (struct smb_com_readx_req *)pSMB;10091009- pSMBW->ByteCount = 0; 10101010+ pSMBW->ByteCount = 0;10101011 }10111011-10121012- rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,10131013- (struct smb_hdr *) pSMBr, &bytes_returned, 0);10121012+10131013+ iov[0].iov_base = (char *)pSMB;10141014+ iov[0].iov_len = pSMB->hdr.smb_buf_length + 4;10151015+ rc = SendReceive2(xid, tcon->ses, iov, 10161016+ 1 /* num iovecs */,10171017+ &resp_buf_type, 0); 10141018 cifs_stats_inc(&tcon->num_reads);10191019+ pSMBr = (READ_RSP *)iov[0].iov_base;10151020 if (rc) {10161021 cERROR(1, ("Send error in read = %d", rc));10171022 } else {···10251022 *nbytes = data_length;1026102310271024 /*check that DataLength would not go beyond end of SMB */10281028- if ((data_length > CIFSMaxBufSize) 10251025+ if ((data_length > CIFSMaxBufSize)10291026 || (data_length > count)) {10301027 cFYI(1,("bad length %d for count %d",data_length,count));10311028 rc = -EIO;10321029 *nbytes = 0;10331030 } else {10341034- pReadData =10351035- (char *) (&pSMBr->hdr.Protocol) +10311031+ pReadData = (char *) (&pSMBr->hdr.Protocol) +10361032 le16_to_cpu(pSMBr->DataOffset);10371037-/* if(rc = copy_to_user(buf, pReadData, data_length)) {10381038- cERROR(1,("Faulting on read rc = %d",rc));10391039- rc = -EFAULT;10401040- }*/ /* can not use copy_to_user when using page cache*/10331033+/* if(rc = copy_to_user(buf, pReadData, data_length)) {10341034+ cERROR(1,("Faulting on read rc = %d",rc));10351035+ rc = -EFAULT;10361036+ }*/ /* can not use copy_to_user when using page cache*/10411037 if(*buf)10421042- memcpy(*buf,pReadData,data_length);10381038+ memcpy(*buf,pReadData,data_length);10431039 }10441040 }10451045- if(*buf)10461046- cifs_buf_release(pSMB);10471047- else10481048- *buf = (char *)pSMB;1049104110501050- /* Note: On -EAGAIN error only caller can retry on handle based calls 10421042+ cifs_small_buf_release(pSMB);10431043+ if(*buf) {10441044+ if(resp_buf_type == CIFS_SMALL_BUFFER)10451045+ cifs_small_buf_release(iov[0].iov_base);10461046+ else if(resp_buf_type == CIFS_LARGE_BUFFER)10471047+ cifs_buf_release(iov[0].iov_base);10481048+ } else /* return buffer to caller to free */ /* BB FIXME how do we tell caller if it is not a large buffer */ {10491049+ *buf = iov[0].iov_base;10501050+ if(resp_buf_type == CIFS_SMALL_BUFFER)10511051+ *pbuf_type = CIFS_SMALL_BUFFER;10521052+ else if(resp_buf_type == CIFS_LARGE_BUFFER)10531053+ *pbuf_type = CIFS_LARGE_BUFFER;10541054+ }10551055+10561056+ /* Note: On -EAGAIN error only caller can retry on handle based calls10511057 since file handle passed in no longer valid */10521058 return rc;10531059}10601060+1054106110551062int10561063CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,···11681155 return rc;11691156}1170115711711171-#ifdef CONFIG_CIFS_EXPERIMENTAL11721158int11731159CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,11741160 const int netfid, const unsigned int count,···11761164{11771165 int rc = -EACCES;11781166 WRITE_REQ *pSMB = NULL;11791179- int bytes_returned, wct;11671167+ int wct;11801168 int smb_hdr_len;11691169+ int resp_buf_type = 0;1181117011821182- /* BB removeme BB */11831171 cFYI(1,("write2 at %lld %d bytes", (long long)offset, count));1184117211851173 if(tcon->ses->capabilities & CAP_LARGE_FILES)···12221210 pSMBW->ByteCount = cpu_to_le16(count + 5);12231211 }12241212 iov[0].iov_base = pSMB;12251225- iov[0].iov_len = smb_hdr_len + 4;12131213+ if(wct == 14)12141214+ iov[0].iov_len = smb_hdr_len + 4;12151215+ else /* wct == 12 pad bigger by four bytes */12161216+ iov[0].iov_len = smb_hdr_len + 8;12171217+1226121812271227- rc = SendReceive2(xid, tcon->ses, iov, n_vec + 1, &bytes_returned,12191219+ rc = SendReceive2(xid, tcon->ses, iov, n_vec + 1, &resp_buf_type,12281220 long_op);12291221 cifs_stats_inc(&tcon->num_writes);12301222 if (rc) {12311223 cFYI(1, ("Send error Write2 = %d", rc));12321224 *nbytes = 0;12251225+ } else if(resp_buf_type == 0) {12261226+ /* presumably this can not happen, but best to be safe */12271227+ rc = -EIO;12281228+ *nbytes = 0;12331229 } else {12341234- WRITE_RSP * pSMBr = (WRITE_RSP *)pSMB;12301230+ WRITE_RSP * pSMBr = (WRITE_RSP *)iov[0].iov_base;12351231 *nbytes = le16_to_cpu(pSMBr->CountHigh);12361232 *nbytes = (*nbytes) << 16;12371233 *nbytes += le16_to_cpu(pSMBr->Count);12381238- }12341234+ } 1239123512401236 cifs_small_buf_release(pSMB);12371237+ if(resp_buf_type == CIFS_SMALL_BUFFER)12381238+ cifs_small_buf_release(iov[0].iov_base);12391239+ else if(resp_buf_type == CIFS_LARGE_BUFFER)12401240+ cifs_buf_release(iov[0].iov_base);1241124112421242 /* Note: On -EAGAIN error only caller can retry on handle based calls 12431243 since file handle passed in no longer valid */···12571233 return rc;12581234}1259123512601260-12611261-#endif /* CIFS_EXPERIMENTAL */1262123612631237int12641238CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,···19281906 return rc;19291907}1930190819091909+/* Initialize NT TRANSACT SMB into small smb request buffer.19101910+ This assumes that all NT TRANSACTS that we init here have19111911+ total parm and data under about 400 bytes (to fit in small cifs19121912+ buffer size), which is the case so far, it easily fits. NB:19131913+ Setup words themselves and ByteCount19141914+ MaxSetupCount (size of returned setup area) and19151915+ MaxParameterCount (returned parms size) must be set by caller */19161916+static int 19171917+smb_init_ntransact(const __u16 sub_command, const int setup_count,19181918+ const int parm_len, struct cifsTconInfo *tcon,19191919+ void ** ret_buf)19201920+{19211921+ int rc;19221922+ __u32 temp_offset;19231923+ struct smb_com_ntransact_req * pSMB;19241924+19251925+ rc = small_smb_init(SMB_COM_NT_TRANSACT, 19 + setup_count, tcon,19261926+ (void **)&pSMB);19271927+ if (rc)19281928+ return rc;19291929+ *ret_buf = (void *)pSMB;19301930+ pSMB->Reserved = 0;19311931+ pSMB->TotalParameterCount = cpu_to_le32(parm_len);19321932+ pSMB->TotalDataCount = 0;19331933+ pSMB->MaxDataCount = cpu_to_le32((tcon->ses->server->maxBuf -19341934+ MAX_CIFS_HDR_SIZE) & 0xFFFFFF00);19351935+ pSMB->ParameterCount = pSMB->TotalParameterCount;19361936+ pSMB->DataCount = pSMB->TotalDataCount;19371937+ temp_offset = offsetof(struct smb_com_ntransact_req, Parms) +19381938+ (setup_count * 2) - 4 /* for rfc1001 length itself */;19391939+ pSMB->ParameterOffset = cpu_to_le32(temp_offset);19401940+ pSMB->DataOffset = cpu_to_le32(temp_offset + parm_len);19411941+ pSMB->SetupCount = setup_count; /* no need to le convert byte fields */19421942+ pSMB->SubCommand = cpu_to_le16(sub_command);19431943+ return 0;19441944+}19451945+19461946+static int19471947+validate_ntransact(char * buf, char ** ppparm, char ** ppdata,19481948+ int * pdatalen, int * pparmlen)19491949+{19501950+ char * end_of_smb;19511951+ __u32 data_count, data_offset, parm_count, parm_offset;19521952+ struct smb_com_ntransact_rsp * pSMBr;19531953+19541954+ if(buf == NULL)19551955+ return -EINVAL;19561956+19571957+ pSMBr = (struct smb_com_ntransact_rsp *)buf;19581958+19591959+ /* ByteCount was converted from little endian in SendReceive */19601960+ end_of_smb = 2 /* sizeof byte count */ + pSMBr->ByteCount + 19611961+ (char *)&pSMBr->ByteCount;19621962+19631963+19641964+ data_offset = le32_to_cpu(pSMBr->DataOffset);19651965+ data_count = le32_to_cpu(pSMBr->DataCount);19661966+ parm_offset = le32_to_cpu(pSMBr->ParameterOffset);19671967+ parm_count = le32_to_cpu(pSMBr->ParameterCount);19681968+19691969+ *ppparm = (char *)&pSMBr->hdr.Protocol + parm_offset;19701970+ *ppdata = (char *)&pSMBr->hdr.Protocol + data_offset;19711971+19721972+ /* should we also check that parm and data areas do not overlap? */19731973+ if(*ppparm > end_of_smb) {19741974+ cFYI(1,("parms start after end of smb"));19751975+ return -EINVAL;19761976+ } else if(parm_count + *ppparm > end_of_smb) {19771977+ cFYI(1,("parm end after end of smb"));19781978+ return -EINVAL;19791979+ } else if(*ppdata > end_of_smb) {19801980+ cFYI(1,("data starts after end of smb"));19811981+ return -EINVAL;19821982+ } else if(data_count + *ppdata > end_of_smb) {19831983+ cFYI(1,("data %p + count %d (%p) ends after end of smb %p start %p",19841984+ *ppdata, data_count, (data_count + *ppdata), end_of_smb, pSMBr)); /* BB FIXME */19851985+ return -EINVAL;19861986+ } else if(parm_count + data_count > pSMBr->ByteCount) {19871987+ cFYI(1,("parm count and data count larger than SMB"));19881988+ return -EINVAL;19891989+ }19901990+ return 0;19911991+}19921992+19311993int19321994CIFSSMBQueryReparseLinkInfo(const int xid, struct cifsTconInfo *tcon,19331995 const unsigned char *searchName,···20341928 pSMB->TotalDataCount = 0;20351929 pSMB->MaxParameterCount = cpu_to_le32(2);20361930 /* BB find exact data count max from sess structure BB */20372037- pSMB->MaxDataCount = cpu_to_le32(4000);19311931+ pSMB->MaxDataCount = cpu_to_le32((tcon->ses->server->maxBuf -19321932+ MAX_CIFS_HDR_SIZE) & 0xFFFFFF00);20381933 pSMB->MaxSetupCount = 4;20391934 pSMB->Reserved = 0;20401935 pSMB->ParameterOffset = 0;···20621955 rc = -EIO; /* bad smb */20631956 else {20641957 if(data_count && (data_count < 2048)) {20652065- char * end_of_smb = pSMBr->ByteCount + (char *)&pSMBr->ByteCount;19581958+ char * end_of_smb = 2 /* sizeof byte count */ +19591959+ pSMBr->ByteCount +19601960+ (char *)&pSMBr->ByteCount;2066196120671962 struct reparse_data * reparse_buf = (struct reparse_data *)20681963 ((char *)&pSMBr->hdr.Protocol + data_offset);···2308219923092200 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,23102201 (struct smb_hdr *) pSMBr, &bytes_returned, 0);22022202+ cifs_stats_inc(&tcon->num_acl_get);23112203 if (rc) {23122204 cFYI(1, ("Send error in Query POSIX ACL = %d", rc));23132205 } else {···249523852496238624972387#endif /* CONFIG_POSIX */23882388+23892389+23902390+/* security id for everyone */23912391+const struct cifs_sid sid_everyone = {1, 1, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0}};23922392+/* group users */23932393+const struct cifs_sid sid_user = {1, 2 , {0, 0, 0, 0, 0, 5}, {32, 545, 0, 0}};23942394+23952395+/* Convert CIFS ACL to POSIX form */23962396+static int parse_sec_desc(struct cifs_sid * psec_desc, int acl_len)23972397+{23982398+ return 0;23992399+}24002400+24012401+/* Get Security Descriptor (by handle) from remote server for a file or dir */24022402+int24032403+CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid,24042404+ /* BB fix up return info */ char *acl_inf, const int buflen, 24052405+ const int acl_type /* ACCESS/DEFAULT not sure implication */)24062406+{24072407+ int rc = 0;24082408+ int buf_type = 0;24092409+ QUERY_SEC_DESC_REQ * pSMB;24102410+ struct kvec iov[1];24112411+24122412+ cFYI(1, ("GetCifsACL"));24132413+24142414+ rc = smb_init_ntransact(NT_TRANSACT_QUERY_SECURITY_DESC, 0, 24152415+ 8 /* parm len */, tcon, (void **) &pSMB);24162416+ if (rc)24172417+ return rc;24182418+24192419+ pSMB->MaxParameterCount = cpu_to_le32(4);24202420+ /* BB TEST with big acls that might need to be e.g. larger than 16K */24212421+ pSMB->MaxSetupCount = 0;24222422+ pSMB->Fid = fid; /* file handle always le */24232423+ pSMB->AclFlags = cpu_to_le32(CIFS_ACL_OWNER | CIFS_ACL_GROUP |24242424+ CIFS_ACL_DACL);24252425+ pSMB->ByteCount = cpu_to_le16(11); /* 3 bytes pad + 8 bytes parm */24262426+ pSMB->hdr.smb_buf_length += 11;24272427+ iov[0].iov_base = (char *)pSMB;24282428+ iov[0].iov_len = pSMB->hdr.smb_buf_length + 4;24292429+24302430+ rc = SendReceive2(xid, tcon->ses, iov, 1 /* num iovec */, &buf_type, 0);24312431+ cifs_stats_inc(&tcon->num_acl_get);24322432+ if (rc) {24332433+ cFYI(1, ("Send error in QuerySecDesc = %d", rc));24342434+ } else { /* decode response */24352435+ struct cifs_sid * psec_desc;24362436+ __le32 * parm;24372437+ int parm_len;24382438+ int data_len;24392439+ int acl_len;24402440+ struct smb_com_ntransact_rsp * pSMBr;24412441+24422442+/* validate_nttransact */24432443+ rc = validate_ntransact(iov[0].iov_base, (char **)&parm, 24442444+ (char **)&psec_desc,24452445+ &parm_len, &data_len);24462446+24472447+ if(rc)24482448+ goto qsec_out;24492449+ pSMBr = (struct smb_com_ntransact_rsp *)iov[0].iov_base;24502450+24512451+ cERROR(1,("smb %p parm %p data %p",pSMBr,parm,psec_desc)); /* BB removeme BB */24522452+24532453+ if (le32_to_cpu(pSMBr->ParameterCount) != 4) {24542454+ rc = -EIO; /* bad smb */24552455+ goto qsec_out;24562456+ }24572457+24582458+/* BB check that data area is minimum length and as big as acl_len */24592459+24602460+ acl_len = le32_to_cpu(*(__le32 *)parm);24612461+ /* BB check if(acl_len > bufsize) */24622462+24632463+ parse_sec_desc(psec_desc, acl_len);24642464+ }24652465+qsec_out:24662466+ if(buf_type == CIFS_SMALL_BUFFER)24672467+ cifs_small_buf_release(iov[0].iov_base);24682468+ else if(buf_type == CIFS_LARGE_BUFFER)24692469+ cifs_buf_release(iov[0].iov_base);24702470+ cifs_small_buf_release(pSMB);24712471+ return rc;24722472+}24732473+2498247424992475/* Legacy Query Path Information call for lookup to old servers such25002476 as Win9x/WinME */···44804284{44814285 int rc = 0;44824286 struct smb_com_transaction_change_notify_req * pSMB = NULL;44834483- struct smb_com_transaction_change_notify_rsp * pSMBr = NULL;42874287+ struct smb_com_ntransaction_change_notify_rsp * pSMBr = NULL;44844288 struct dir_notify_req *dnotify_req;44854289 int bytes_returned;44864290···44954299 pSMB->MaxParameterCount = cpu_to_le32(2);44964300 /* BB find exact data count max from sess structure BB */44974301 pSMB->MaxDataCount = 0; /* same in little endian or be */43024302+/* BB VERIFY verify which is correct for above BB */43034303+ pSMB->MaxDataCount = cpu_to_le32((tcon->ses->server->maxBuf -43044304+ MAX_CIFS_HDR_SIZE) & 0xFFFFFF00);43054305+44984306 pSMB->MaxSetupCount = 4;44994307 pSMB->Reserved = 0;45004308 pSMB->ParameterOffset = 0;
+76-13
fs/cifs/connect.c
···7676 unsigned setuids:1;7777 unsigned noperm:1;7878 unsigned no_psx_acl:1; /* set if posix acl support should be disabled */7979+ unsigned cifs_acl:1;7980 unsigned no_xattr:1; /* set if xattr (EA) support should be disabled*/8081 unsigned server_ino:1; /* use inode numbers from server ie UniqueId */8182 unsigned direct_io:1;8283 unsigned remap:1; /* set to remap seven reserved chars in filenames */8384 unsigned posix_paths:1; /* unset to not ask for posix pathnames. */8485 unsigned sfu_emul:1;8686+ unsigned krb5:1;8787+ unsigned ntlm:1;8888+ unsigned ntlmv2:1;8989+ unsigned nullauth:1; /* attempt to authenticate with null user */9090+ unsigned sign:1;9191+ unsigned seal:1; /* encrypt */8592 unsigned nocase; /* request case insensitive filenames */8693 unsigned nobrl; /* disable sending byte range locks to srv */8794 unsigned int rsize;···515508 /* else length ok */516509 reconnect = 0;517510518518- if(pdu_length > MAX_CIFS_HDR_SIZE - 4) {511511+ if(pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) {519512 isLargeBuf = TRUE;520513 memcpy(bigbuf, smallbuf, 4);521514 smb_buffer = bigbuf;···784777785778 /* vol->retry default is 0 (i.e. "soft" limited retry not hard retry) */786779 vol->rw = TRUE;787787-780780+ vol->ntlm = TRUE;788781 /* default is always to request posix paths. */789782 vol->posix_paths = 1;790783···910903 printk(KERN_WARNING "CIFS: ip address too long\n");911904 return 1;912905 }906906+ } else if (strnicmp(data, "sec", 3) == 0) { 907907+ if (!value || !*value) {908908+ cERROR(1,("no security value specified"));909909+ continue;910910+ } else if (strnicmp(value, "krb5i", 5) == 0) {911911+ vol->sign = 1;912912+ vol->krb5 = 1;913913+ } else if (strnicmp(value, "krb5p", 5) == 0) {914914+ /* vol->seal = 1; 915915+ vol->krb5 = 1; */916916+ cERROR(1,("Krb5 cifs privacy not supported"));917917+ return 1;918918+ } else if (strnicmp(value, "krb5", 4) == 0) {919919+ vol->krb5 = 1;920920+ } else if (strnicmp(value, "ntlmv2i", 7) == 0) {921921+ vol->ntlmv2 = 1;922922+ vol->sign = 1;923923+ } else if (strnicmp(value, "ntlmv2", 6) == 0) {924924+ vol->ntlmv2 = 1;925925+ } else if (strnicmp(value, "ntlmi", 5) == 0) {926926+ vol->ntlm = 1;927927+ vol->sign = 1;928928+ } else if (strnicmp(value, "ntlm", 4) == 0) {929929+ /* ntlm is default so can be turned off too */930930+ vol->ntlm = 1;931931+ } else if (strnicmp(value, "nontlm", 6) == 0) {932932+ vol->ntlm = 0;933933+ } else if (strnicmp(value, "none", 4) == 0) {934934+ vol->nullauth = 1; 935935+ } else {936936+ cERROR(1,("bad security option: %s", value));937937+ return 1;938938+ }913939 } else if ((strnicmp(data, "unc", 3) == 0)914940 || (strnicmp(data, "target", 6) == 0)915941 || (strnicmp(data, "path", 4) == 0)) {···11601120 vol->server_ino = 1;11611121 } else if (strnicmp(data, "noserverino",9) == 0) {11621122 vol->server_ino = 0;11231123+ } else if (strnicmp(data, "cifsacl",7) == 0) {11241124+ vol->cifs_acl = 1;11251125+ } else if (strnicmp(data, "nocifsacl", 9) == 0) {11261126+ vol->cifs_acl = 0;11631127 } else if (strnicmp(data, "acl",3) == 0) {11641128 vol->no_psx_acl = 0;11651129 } else if (strnicmp(data, "noacl",5) == 0) {···15901546 cFYI(1, ("Username: %s ", volume_info.username));1591154715921548 } else {15931593- cifserror("No username specified ");15491549+ cifserror("No username specified");15941550 /* In userspace mount helper we can get user name from alternate15951551 locations such as env variables and files on disk */15961552 kfree(volume_info.UNC);···16311587 return -EINVAL;16321588 } else /* which servers DFS root would we conect to */ {16331589 cERROR(1,16341634- ("CIFS mount error: No UNC path (e.g. -o unc=//192.168.1.100/public) specified "));15901590+ ("CIFS mount error: No UNC path (e.g. -o unc=//192.168.1.100/public) specified"));16351591 kfree(volume_info.UNC);16361592 kfree(volume_info.password);16371593 FreeXid(xid);···167016261671162716721628 if (srvTcp) {16731673- cFYI(1, ("Existing tcp session with server found ")); 16291629+ cFYI(1, ("Existing tcp session with server found")); 16741630 } else { /* create socket */16751631 if(volume_info.port)16761632 sin_server.sin_port = htons(volume_info.port);···1733168917341690 if (existingCifsSes) {17351691 pSesInfo = existingCifsSes;17361736- cFYI(1, ("Existing smb sess found "));16921692+ cFYI(1, ("Existing smb sess found"));17371693 kfree(volume_info.password);17381694 /* volume_info.UNC freed at end of function */17391695 } else if (!rc) {17401740- cFYI(1, ("Existing smb sess not found "));16961696+ cFYI(1, ("Existing smb sess not found"));17411697 pSesInfo = sesInfoAlloc();17421698 if (pSesInfo == NULL)17431699 rc = -ENOMEM;···17951751 cifs_sb->mnt_gid = volume_info.linux_gid;17961752 cifs_sb->mnt_file_mode = volume_info.file_mode;17971753 cifs_sb->mnt_dir_mode = volume_info.dir_mode;17981798- cFYI(1,("file mode: 0x%x dir mode: 0x%x",cifs_sb->mnt_file_mode,cifs_sb->mnt_dir_mode));17541754+ cFYI(1,("file mode: 0x%x dir mode: 0x%x",17551755+ cifs_sb->mnt_file_mode,cifs_sb->mnt_dir_mode));1799175618001757 if(volume_info.noperm)18011758 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM;···18121767 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UNX_EMUL;18131768 if(volume_info.nobrl)18141769 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL;17701770+ if(volume_info.cifs_acl)17711771+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL;1815177218161773 if(volume_info.direct_io) {18171774 cFYI(1,("mounting share using direct i/o"));···18241777 find_unc(sin_server.sin_addr.s_addr, volume_info.UNC,18251778 volume_info.username);18261779 if (tcon) {18271827- cFYI(1, ("Found match on UNC path "));17801780+ cFYI(1, ("Found match on UNC path"));18281781 /* we can have only one retry value for a connection18291782 to a share so for resources mounted more than once18301783 to the same server share the last value passed in ···19731926 __u32 capabilities;19741927 __u16 count;1975192819761976- cFYI(1, ("In sesssetup "));19291929+ cFYI(1, ("In sesssetup"));19771930 if(ses == NULL)19781931 return -EINVAL;19791932 user = ses->userName;···3249320232503203 pSMB->AndXCommand = 0xFF;32513204 pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO);32523252- pSMB->PasswordLength = cpu_to_le16(1); /* minimum */32533205 bcc_ptr = &pSMB->Password[0];32543254- bcc_ptr++; /* skip password */32063206+ if((ses->server->secMode) & SECMODE_USER) {32073207+ pSMB->PasswordLength = cpu_to_le16(1); /* minimum */32083208+ bcc_ptr++; /* skip password */32093209+ } else {32103210+ pSMB->PasswordLength = cpu_to_le16(CIFS_SESSION_KEY_SIZE);32113211+ /* BB FIXME add code to fail this if NTLMv2 or Kerberos32123212+ specified as required (when that support is added to32133213+ the vfs in the future) as only NTLM or the much32143214+ weaker LANMAN (which we do not send) is accepted32153215+ by Samba (not sure whether other servers allow32163216+ NTLMv2 password here) */32173217+ SMBNTencrypt(ses->password,32183218+ ses->server->cryptKey,32193219+ bcc_ptr);32203220+32213221+ bcc_ptr += CIFS_SESSION_KEY_SIZE;32223222+ *bcc_ptr = 0;32233223+ bcc_ptr++; /* align */32243224+ }3255322532563226 if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))32573227 smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;···32863222 bcc_ptr += 2 * length; /* convert num of 16 bit words to bytes */32873223 bcc_ptr += 2; /* skip trailing null */32883224 } else { /* ASCII */32893289-32903225 strcpy(bcc_ptr, tree);32913226 bcc_ptr += strlen(tree) + 1;32923227 }
+4-4
fs/cifs/dir.c
···33 *44 * vfs operations that deal with dentries55 * 66- * Copyright (C) International Business Machines Corp., 2002,200366+ * Copyright (C) International Business Machines Corp., 2002,200577 * Author(s): Steve French (sfrench@us.ibm.com)88 *99 * This library is free software; you can redistribute it and/or modify···200200 (oplock & CIFS_CREATE_ACTION))201201 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {202202 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,203203- (__u64)current->euid,204204- (__u64)current->egid,203203+ (__u64)current->fsuid,204204+ (__u64)current->fsgid,205205 0 /* dev */,206206 cifs_sb->local_nls, 207207 cifs_sb->mnt_cifs_flags & ···325325 else if (pTcon->ses->capabilities & CAP_UNIX) {326326 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {327327 rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path,328328- mode,(__u64)current->euid,(__u64)current->egid,328328+ mode,(__u64)current->fsuid,(__u64)current->fsgid,329329 device_number, cifs_sb->local_nls,330330 cifs_sb->mnt_cifs_flags & 331331 CIFS_MOUNT_MAP_SPECIAL_CHR);
+46-27
fs/cifs/file.c
···553553 }554554 ptmp = pCFileStruct->srch_inf.ntwrk_buf_start;555555 if (ptmp) {556556- /* BB removeme BB */ cFYI(1, ("freeing smb buf in srch struct in closedir"));556556+ cFYI(1, ("closedir free smb buf in srch struct"));557557 pCFileStruct->srch_inf.ntwrk_buf_start = NULL;558558 cifs_buf_release(ptmp);559559 }560560 ptmp = pCFileStruct->search_resume_name;561561 if (ptmp) {562562- /* BB removeme BB */ cFYI(1, ("freeing resume name in closedir"));562562+ cFYI(1, ("closedir free resume name"));563563 pCFileStruct->search_resume_name = NULL;564564 kfree(ptmp);565565 }···868868 if (rc != 0)869869 break;870870 }871871-#ifdef CONFIG_CIFS_EXPERIMENTAL872871 /* BB FIXME We can not sign across two buffers yet */873873- if((experimEnabled) && ((pTcon->ses->server->secMode & 874874- (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) == 0)) {872872+ if((pTcon->ses->server->secMode & 873873+ (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) == 0) {875874 struct kvec iov[2];876875 unsigned int len;877876···886887 iov, 1, long_op);887888 } else888889 /* BB FIXME fixup indentation of line below */889889-#endif 890890 rc = CIFSSMBWrite(xid, pTcon,891891 open_file->netfid,892892 min_t(const int, cifs_sb->wsize, ···10221024 return rc;10231025}1024102610251025-#ifdef CONFIG_CIFS_EXPERIMENTAL10261027static int cifs_writepages(struct address_space *mapping,10271028 struct writeback_control *wbc)10281029{···1224122712251228 return rc;12261229}12271227-#endif1228123012291231static int cifs_writepage(struct page* page, struct writeback_control *wbc)12301232{···14221426 rc = -EAGAIN;14231427 smb_read_data = NULL;14241428 while (rc == -EAGAIN) {14291429+ int buf_type = CIFS_NO_BUFFER;14251430 if ((open_file->invalidHandle) && 14261431 (!open_file->closePend)) {14271432 rc = cifs_reopen_file(file->f_dentry->d_inode,···14311434 break;14321435 }14331436 rc = CIFSSMBRead(xid, pTcon,14341434- open_file->netfid,14351435- current_read_size, *poffset,14361436- &bytes_read, &smb_read_data);14371437+ open_file->netfid,14381438+ current_read_size, *poffset,14391439+ &bytes_read, &smb_read_data,14401440+ &buf_type);14371441 pSMBr = (struct smb_com_read_rsp *)smb_read_data;14381442 if (copy_to_user(current_offset, 14391443 smb_read_data + 4 /* RFC1001 hdr */14401444 + le16_to_cpu(pSMBr->DataOffset), 14411445 bytes_read)) {14421446 rc = -EFAULT;14431443- FreeXid(xid);14441444- return rc;14451445- }14471447+ }14461448 if (smb_read_data) {14471447- cifs_buf_release(smb_read_data);14491449+ if(buf_type == CIFS_SMALL_BUFFER)14501450+ cifs_small_buf_release(smb_read_data);14511451+ else if(buf_type == CIFS_LARGE_BUFFER)14521452+ cifs_buf_release(smb_read_data);14481453 smb_read_data = NULL;14491454 }14501455 }···14791480 int xid;14801481 char *current_offset;14811482 struct cifsFileInfo *open_file;14831483+ int buf_type = CIFS_NO_BUFFER;1482148414831485 xid = GetXid();14841486 cifs_sb = CIFS_SB(file->f_dentry->d_sb);···15161516 break;15171517 }15181518 rc = CIFSSMBRead(xid, pTcon,15191519- open_file->netfid,15201520- current_read_size, *poffset,15211521- &bytes_read, ¤t_offset);15191519+ open_file->netfid,15201520+ current_read_size, *poffset,15211521+ &bytes_read, ¤t_offset,15221522+ &buf_type);15221523 }15231524 if (rc || (bytes_read == 0)) {15241525 if (total_read) {···16171616 struct smb_com_read_rsp *pSMBr;16181617 struct pagevec lru_pvec;16191618 struct cifsFileInfo *open_file;16191619+ int buf_type = CIFS_NO_BUFFER;1620162016211621 xid = GetXid();16221622 if (file->private_data == NULL) {···16741672 }1675167316761674 rc = CIFSSMBRead(xid, pTcon,16771677- open_file->netfid,16781678- read_size, offset,16791679- &bytes_read, &smb_read_data);16801680-16751675+ open_file->netfid,16761676+ read_size, offset,16771677+ &bytes_read, &smb_read_data,16781678+ &buf_type);16811679 /* BB more RC checks ? */16821680 if (rc== -EAGAIN) {16831681 if (smb_read_data) {16841684- cifs_buf_release(smb_read_data);16821682+ if(buf_type == CIFS_SMALL_BUFFER)16831683+ cifs_small_buf_release(smb_read_data);16841684+ else if(buf_type == CIFS_LARGE_BUFFER)16851685+ cifs_buf_release(smb_read_data);16851686 smb_read_data = NULL;16861687 }16871688 }···17411736 break;17421737 }17431738 if (smb_read_data) {17441744- cifs_buf_release(smb_read_data);17391739+ if(buf_type == CIFS_SMALL_BUFFER)17401740+ cifs_small_buf_release(smb_read_data);17411741+ else if(buf_type == CIFS_LARGE_BUFFER)17421742+ cifs_buf_release(smb_read_data);17451743 smb_read_data = NULL;17461744 }17471745 bytes_read = 0;···1754174617551747/* need to free smb_read_data buf before exit */17561748 if (smb_read_data) {17571757- cifs_buf_release(smb_read_data);17491749+ if(buf_type == CIFS_SMALL_BUFFER)17501750+ cifs_small_buf_release(smb_read_data);17511751+ else if(buf_type == CIFS_LARGE_BUFFER)17521752+ cifs_buf_release(smb_read_data);17581753 smb_read_data = NULL;17591754 } 17601755···18361825 open_file = find_writable_file(cifsInode);1837182618381827 if(open_file) {18281828+ struct cifs_sb_info *cifs_sb;18291829+18391830 /* there is not actually a write pending so let18401831 this handle go free and allow it to18411832 be closable if needed */18421833 atomic_dec(&open_file->wrtPending);18341834+18351835+ cifs_sb = CIFS_SB(cifsInode->vfs_inode.i_sb);18361836+ if ( cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO ) {18371837+ /* since no page cache to corrupt on directio 18381838+ we can change size safely */18391839+ return 1;18401840+ }18411841+18431842 return 0;18441843 } else18451844 return 1;···18941873 .readpage = cifs_readpage,18951874 .readpages = cifs_readpages,18961875 .writepage = cifs_writepage,18971897-#ifdef CONFIG_CIFS_EXPERIMENTAL18981876 .writepages = cifs_writepages,18991899-#endif19001877 .prepare_write = cifs_prepare_write,19011878 .commit_write = cifs_commit_write,19021879 .set_page_dirty = __set_page_dirty_nobuffers,