···44 int charlen, outlen = 0;45 int maxwords = maxbytes / 2;46 char tmp[NLS_MAX_CHARSET_SIZE];04748- for (i = 0; i < maxwords && from[i]; i++) {49- charlen = codepage->uni2char(le16_to_cpu(from[i]), tmp,50- NLS_MAX_CHARSET_SIZE);00051 if (charlen > 0)52 outlen += charlen;53 else···62}6364/*65- * cifs_mapchar - convert a little-endian char to proper char in codepage66 * @target - where converted character should be copied67- * @src_char - 2 byte little-endian source character68 * @cp - codepage to which character should be converted69 * @mapchar - should character be mapped according to mapchars mount option?70 *···73 * enough to hold the result of the conversion (at least NLS_MAX_CHARSET_SIZE).74 */75static int76-cifs_mapchar(char *target, const __le16 src_char, const struct nls_table *cp,77 bool mapchar)78{79 int len = 1;···86 * build_path_from_dentry are modified, as they use slash as87 * separator.88 */89- switch (le16_to_cpu(src_char)) {90 case UNI_COLON:91 *target = ':';92 break;···113 return len;114115cp_convert:116- len = cp->uni2char(le16_to_cpu(src_char), target,117- NLS_MAX_CHARSET_SIZE);118 if (len <= 0) {119 *target = '?';120 len = 1;···152 int nullsize = nls_nullsize(codepage);153 int fromwords = fromlen / 2;154 char tmp[NLS_MAX_CHARSET_SIZE];0155156 /*157 * because the chars can be of varying widths, we need to take care···162 */163 safelen = tolen - (NLS_MAX_CHARSET_SIZE + nullsize);164165- for (i = 0; i < fromwords && from[i]; i++) {0000166 /*167 * check to see if converting this character might make the168 * conversion bleed into the null terminator169 */170 if (outlen >= safelen) {171- charlen = cifs_mapchar(tmp, from[i], codepage, mapchar);172 if ((outlen + charlen) > (tolen - nullsize))173 break;174 }175176 /* put converted char into 'to' buffer */177- charlen = cifs_mapchar(&to[outlen], from[i], codepage, mapchar);178 outlen += charlen;179 }180···201{202 int charlen;203 int i;204- wchar_t *wchar_to = (wchar_t *)to; /* needed to quiet sparse */205206 for (i = 0; len && *from; i++, from += charlen, len -= charlen) {207-208- /* works for 2.4.0 kernel or later */209- charlen = codepage->char2uni(from, len, &wchar_to[i]);210 if (charlen < 1) {211- cERROR(1, "strtoUCS: char2uni of %d returned %d",212- (int)*from, charlen);213 /* A question mark */214- to[i] = cpu_to_le16(0x003f);215 charlen = 1;216- } else217- to[i] = cpu_to_le16(wchar_to[i]);218-219 }220221- to[i] = 0;222 return i;223}224···255 }256257 return dst;0000000000000000000000000000000000000000000000000000000000000000000000000000258}259
···44 int charlen, outlen = 0;45 int maxwords = maxbytes / 2;46 char tmp[NLS_MAX_CHARSET_SIZE];47+ __u16 ftmp;4849+ for (i = 0; i < maxwords; i++) {50+ ftmp = get_unaligned_le16(&from[i]);51+ if (ftmp == 0)52+ break;53+54+ charlen = codepage->uni2char(ftmp, tmp, NLS_MAX_CHARSET_SIZE);55 if (charlen > 0)56 outlen += charlen;57 else···58}5960/*61+ * cifs_mapchar - convert a host-endian char to proper char in codepage62 * @target - where converted character should be copied63+ * @src_char - 2 byte host-endian source character64 * @cp - codepage to which character should be converted65 * @mapchar - should character be mapped according to mapchars mount option?66 *···69 * enough to hold the result of the conversion (at least NLS_MAX_CHARSET_SIZE).70 */71static int72+cifs_mapchar(char *target, const __u16 src_char, const struct nls_table *cp,73 bool mapchar)74{75 int len = 1;···82 * build_path_from_dentry are modified, as they use slash as83 * separator.84 */85+ switch (src_char) {86 case UNI_COLON:87 *target = ':';88 break;···109 return len;110111cp_convert:112+ len = cp->uni2char(src_char, target, NLS_MAX_CHARSET_SIZE);0113 if (len <= 0) {114 *target = '?';115 len = 1;···149 int nullsize = nls_nullsize(codepage);150 int fromwords = fromlen / 2;151 char tmp[NLS_MAX_CHARSET_SIZE];152+ __u16 ftmp;153154 /*155 * because the chars can be of varying widths, we need to take care···158 */159 safelen = tolen - (NLS_MAX_CHARSET_SIZE + nullsize);160161+ for (i = 0; i < fromwords; i++) {162+ ftmp = get_unaligned_le16(&from[i]);163+ if (ftmp == 0)164+ break;165+166 /*167 * check to see if converting this character might make the168 * conversion bleed into the null terminator169 */170 if (outlen >= safelen) {171+ charlen = cifs_mapchar(tmp, ftmp, codepage, mapchar);172 if ((outlen + charlen) > (tolen - nullsize))173 break;174 }175176 /* put converted char into 'to' buffer */177+ charlen = cifs_mapchar(&to[outlen], ftmp, codepage, mapchar);178 outlen += charlen;179 }180···193{194 int charlen;195 int i;196+ wchar_t wchar_to; /* needed to quiet sparse */197198 for (i = 0; len && *from; i++, from += charlen, len -= charlen) {199+ charlen = codepage->char2uni(from, len, &wchar_to);00200 if (charlen < 1) {201+ cERROR(1, "strtoUCS: char2uni of 0x%x returned %d",202+ *from, charlen);203 /* A question mark */204+ wchar_to = 0x003f;205 charlen = 1;206+ }207+ put_unaligned_le16(wchar_to, &to[i]);0208 }209210+ put_unaligned_le16(0, &to[i]);211 return i;212}213···250 }251252 return dst;253+}254+255+/*256+ * Convert 16 bit Unicode pathname to wire format from string in current code257+ * page. Conversion may involve remapping up the six characters that are258+ * only legal in POSIX-like OS (if they are present in the string). Path259+ * names are little endian 16 bit Unicode on the wire260+ */261+int262+cifsConvertToUCS(__le16 *target, const char *source, int maxlen,263+ const struct nls_table *cp, int mapChars)264+{265+ int i, j, charlen;266+ int len_remaining = maxlen;267+ char src_char;268+ __u16 temp;269+270+ if (!mapChars)271+ return cifs_strtoUCS(target, source, PATH_MAX, cp);272+273+ for (i = 0, j = 0; i < maxlen; j++) {274+ src_char = source[i];275+ switch (src_char) {276+ case 0:277+ put_unaligned_le16(0, &target[j]);278+ goto ctoUCS_out;279+ case ':':280+ temp = UNI_COLON;281+ break;282+ case '*':283+ temp = UNI_ASTERIK;284+ break;285+ case '?':286+ temp = UNI_QUESTION;287+ break;288+ case '<':289+ temp = UNI_LESSTHAN;290+ break;291+ case '>':292+ temp = UNI_GRTRTHAN;293+ break;294+ case '|':295+ temp = UNI_PIPE;296+ break;297+ /*298+ * FIXME: We can not handle remapping backslash (UNI_SLASH)299+ * until all the calls to build_path_from_dentry are modified,300+ * as they use backslash as separator.301+ */302+ default:303+ charlen = cp->char2uni(source+i, len_remaining,304+ &temp);305+ /*306+ * if no match, use question mark, which at least in307+ * some cases serves as wild card308+ */309+ if (charlen < 1) {310+ temp = 0x003f;311+ charlen = 1;312+ }313+ len_remaining -= charlen;314+ /*315+ * character may take more than one byte in the source316+ * string, but will take exactly two bytes in the317+ * target string318+ */319+ i += charlen;320+ continue;321+ }322+ put_unaligned_le16(temp, &target[j]);323+ i++; /* move to next char in source string */324+ len_remaining--;325+ }326+327+ctoUCS_out:328+ return i;329}330
+38
fs/cifs/cifsfs.c
···733 .setlease = cifs_setlease,734};7350000000000000000000736const struct file_operations cifs_file_direct_ops = {737 /* no aio, no readv -738 BB reevaluate whether they can be done with directio, no cache */···770 .llseek = cifs_llseek,771 .setlease = cifs_setlease,772};0773const struct file_operations cifs_file_nobrl_ops = {774 .read = do_sync_read,775 .write = do_sync_write,···781 .fsync = cifs_fsync,782 .flush = cifs_flush,783 .mmap = cifs_file_mmap,000000000000000000784 .splice_read = generic_file_splice_read,785 .llseek = cifs_llseek,786#ifdef CONFIG_CIFS_POSIX
···61 struct dentry *);62extern int cifs_revalidate_file(struct file *filp);63extern int cifs_revalidate_dentry(struct dentry *);064extern int cifs_getattr(struct vfsmount *, struct dentry *, struct kstat *);65extern int cifs_setattr(struct dentry *, struct iattr *);66···73/* Functions related to files and directories */74extern const struct file_operations cifs_file_ops;75extern const struct file_operations cifs_file_direct_ops; /* if directio mnt */76-extern const struct file_operations cifs_file_nobrl_ops;77-extern const struct file_operations cifs_file_direct_nobrl_ops; /* no brlocks */0078extern int cifs_open(struct inode *inode, struct file *file);79extern int cifs_close(struct inode *inode, struct file *file);80extern int cifs_closedir(struct inode *inode, struct file *file);81extern ssize_t cifs_user_read(struct file *file, char __user *read_data,82- size_t read_size, loff_t *poffset);0083extern ssize_t cifs_user_write(struct file *file, const char __user *write_data,84 size_t write_size, loff_t *poffset);85extern int cifs_lock(struct file *, int, struct file_lock *);86extern int cifs_fsync(struct file *, int);087extern int cifs_flush(struct file *, fl_owner_t id);88extern int cifs_file_mmap(struct file * , struct vm_area_struct *);089extern const struct file_operations cifs_dir_ops;90extern int cifs_dir_open(struct inode *inode, struct file *file);91extern int cifs_readdir(struct file *file, void *direntry, filldir_t filldir);
···61 struct dentry *);62extern int cifs_revalidate_file(struct file *filp);63extern int cifs_revalidate_dentry(struct dentry *);64+extern void cifs_invalidate_mapping(struct inode *inode);65extern int cifs_getattr(struct vfsmount *, struct dentry *, struct kstat *);66extern int cifs_setattr(struct dentry *, struct iattr *);67···72/* Functions related to files and directories */73extern const struct file_operations cifs_file_ops;74extern const struct file_operations cifs_file_direct_ops; /* if directio mnt */75+extern const struct file_operations cifs_file_strict_ops; /* if strictio mnt */76+extern const struct file_operations cifs_file_nobrl_ops; /* no brlocks */77+extern const struct file_operations cifs_file_direct_nobrl_ops;78+extern const struct file_operations cifs_file_strict_nobrl_ops;79extern int cifs_open(struct inode *inode, struct file *file);80extern int cifs_close(struct inode *inode, struct file *file);81extern int cifs_closedir(struct inode *inode, struct file *file);82extern ssize_t cifs_user_read(struct file *file, char __user *read_data,83+ size_t read_size, loff_t *poffset);84+extern ssize_t cifs_strict_readv(struct kiocb *iocb, const struct iovec *iov,85+ unsigned long nr_segs, loff_t pos);86extern ssize_t cifs_user_write(struct file *file, const char __user *write_data,87 size_t write_size, loff_t *poffset);88extern int cifs_lock(struct file *, int, struct file_lock *);89extern int cifs_fsync(struct file *, int);90+extern int cifs_strict_fsync(struct file *, int);91extern int cifs_flush(struct file *, fl_owner_t id);92extern int cifs_file_mmap(struct file * , struct vm_area_struct *);93+extern int cifs_file_strict_mmap(struct file * , struct vm_area_struct *);94extern const struct file_operations cifs_dir_ops;95extern int cifs_dir_open(struct inode *inode, struct file *file);96extern int cifs_readdir(struct file *file, void *direntry, filldir_t filldir);
+14-22
fs/cifs/cifsglob.h
···161 int srv_count; /* reference counter */162 /* 15 character server name + 0x20 16th byte indicating type = srv */163 char server_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL];0164 char *hostname; /* hostname portion of UNC string */165 struct socket *ssocket;166 struct sockaddr_storage dstaddr;···169 wait_queue_head_t response_q;170 wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/171 struct list_head pending_mid_q;172- void *Server_NlsInfo; /* BB - placeholder for future NLS info */173- unsigned short server_codepage; /* codepage for the server */174- enum protocolEnum protocolType;175- char versionMajor;176- char versionMinor;177- bool svlocal:1; /* local server or remote */178 bool noblocksnd; /* use blocking sendmsg */179 bool noautotune; /* do not autotune send buf sizes */180 bool tcp_nodelay;181 atomic_t inFlight; /* number of requests on the wire to server */182-#ifdef CONFIG_CIFS_STATS2183- atomic_t inSend; /* requests trying to send */184- atomic_t num_waiters; /* blocked waiting to get in sendrecv */185-#endif186- enum statusEnum tcpStatus; /* what we think the status is */187 struct mutex srv_mutex;188 struct task_struct *tsk;189 char server_GUID[16];190 char secMode;00191 enum securityEnum secType;192 unsigned int maxReq; /* Clients should submit no more */193 /* than maxReq distinct unanswered SMBs to the server when using */···191 unsigned int max_vcs; /* maximum number of smb sessions, at least192 those that can be specified uniquely with193 vcnumbers */194- char sessid[4]; /* unique token id for this session */195- /* (returned on Negotiate */196 int capabilities; /* allow selective disabling of caps by smb sess */197 int timeAdj; /* Adjust for difference in server time zone in sec */198 __u16 CurrentMid; /* multiplex id - rotating counter */···200 __u32 sequence_number; /* for signing, protected by srv_mutex */201 struct session_key session_key;202 unsigned long lstrp; /* when we got last response from this server */203- u16 dialect; /* dialect index that server chose */204 struct cifs_secmech secmech; /* crypto sec mech functs, descriptors */205 /* extended security flavors that server supports */00206 bool sec_kerberos; /* supports plain Kerberos */207 bool sec_mskerberos; /* supports legacy MS Kerberos */208- bool sec_kerberosu2u; /* supports U2U Kerberos */209- bool sec_ntlmssp; /* supports NTLMSSP */210- bool session_estab; /* mark when very first sess is established */211 struct delayed_work echo; /* echo ping workqueue job */212#ifdef CONFIG_CIFS_FSCACHE213 struct fscache_cookie *fscache; /* client index cache cookie */0000214#endif215};216···439 /* BB add in lists for dirty pages i.e. write caching info for oplock */440 struct list_head openFileList;441 __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */442- unsigned long time; /* jiffies of last update/check of inode */443- bool clientCanCacheRead:1; /* read oplock */444- bool clientCanCacheAll:1; /* read and writebehind oplock */445- bool delete_pending:1; /* DELETE_ON_CLOSE is set */446- bool invalid_mapping:1; /* pagecache is invalid */447 u64 server_eof; /* current file size on server */448 u64 uniqueid; /* server inode number */449 u64 createtime; /* creation time on server */
···161 int srv_count; /* reference counter */162 /* 15 character server name + 0x20 16th byte indicating type = srv */163 char server_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL];164+ enum statusEnum tcpStatus; /* what we think the status is */165 char *hostname; /* hostname portion of UNC string */166 struct socket *ssocket;167 struct sockaddr_storage dstaddr;···168 wait_queue_head_t response_q;169 wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/170 struct list_head pending_mid_q;000000171 bool noblocksnd; /* use blocking sendmsg */172 bool noautotune; /* do not autotune send buf sizes */173 bool tcp_nodelay;174 atomic_t inFlight; /* number of requests on the wire to server */00000175 struct mutex srv_mutex;176 struct task_struct *tsk;177 char server_GUID[16];178 char secMode;179+ bool session_estab; /* mark when very first sess is established */180+ u16 dialect; /* dialect index that server chose */181 enum securityEnum secType;182 unsigned int maxReq; /* Clients should submit no more */183 /* than maxReq distinct unanswered SMBs to the server when using */···199 unsigned int max_vcs; /* maximum number of smb sessions, at least200 those that can be specified uniquely with201 vcnumbers */00202 int capabilities; /* allow selective disabling of caps by smb sess */203 int timeAdj; /* Adjust for difference in server time zone in sec */204 __u16 CurrentMid; /* multiplex id - rotating counter */···210 __u32 sequence_number; /* for signing, protected by srv_mutex */211 struct session_key session_key;212 unsigned long lstrp; /* when we got last response from this server */0213 struct cifs_secmech secmech; /* crypto sec mech functs, descriptors */214 /* extended security flavors that server supports */215+ bool sec_ntlmssp; /* supports NTLMSSP */216+ bool sec_kerberosu2u; /* supports U2U Kerberos */217 bool sec_kerberos; /* supports plain Kerberos */218 bool sec_mskerberos; /* supports legacy MS Kerberos */000219 struct delayed_work echo; /* echo ping workqueue job */220#ifdef CONFIG_CIFS_FSCACHE221 struct fscache_cookie *fscache; /* client index cache cookie */222+#endif223+#ifdef CONFIG_CIFS_STATS2224+ atomic_t inSend; /* requests trying to send */225+ atomic_t num_waiters; /* blocked waiting to get in sendrecv */226#endif227};228···447 /* BB add in lists for dirty pages i.e. write caching info for oplock */448 struct list_head openFileList;449 __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */450+ bool clientCanCacheRead; /* read oplock */451+ bool clientCanCacheAll; /* read and writebehind oplock */452+ bool delete_pending; /* DELETE_ON_CLOSE is set */453+ bool invalid_mapping; /* pagecache is invalid */454+ unsigned long time; /* jiffies of last update of inode */455 u64 server_eof; /* current file size on server */456 u64 uniqueid; /* server inode number */457 u64 createtime; /* creation time on server */
+43-4
fs/cifs/cifspdu.h
···23#define _CIFSPDU_H2425#include <net/sock.h>026#include "smbfsctl.h"2728#ifdef CONFIG_CIFS_WEAK_PW_HASH···427 __u16 Mid;428 __u8 WordCount;429} __attribute__((packed));430-/* given a pointer to an smb_hdr retrieve the value of byte count */431-#define BCC(smb_var) (*(__u16 *)((char *)(smb_var) + sizeof(struct smb_hdr) + (2 * (smb_var)->WordCount)))432-#define BCC_LE(smb_var) (*(__le16 *)((char *)(smb_var) + sizeof(struct smb_hdr) + (2 * (smb_var)->WordCount)))00433/* given a pointer to an smb_hdr retrieve the pointer to the byte area */434-#define pByteArea(smb_var) ((unsigned char *)(smb_var) + sizeof(struct smb_hdr) + (2 * (smb_var)->WordCount) + 2)000000000000000000000000000000000000435436/*437 * Computer Name Length (since Netbios name was length 16 with last byte 0x20)
···23#define _CIFSPDU_H2425#include <net/sock.h>26+#include <asm/unaligned.h>27#include "smbfsctl.h"2829#ifdef CONFIG_CIFS_WEAK_PW_HASH···426 __u16 Mid;427 __u8 WordCount;428} __attribute__((packed));429+430+/* given a pointer to an smb_hdr retrieve a char pointer to the byte count */431+#define BCC(smb_var) ((unsigned char *)(smb_var) + sizeof(struct smb_hdr) + \432+ (2 * (smb_var)->WordCount))433+434/* given a pointer to an smb_hdr retrieve the pointer to the byte area */435+#define pByteArea(smb_var) (BCC(smb_var) + 2)436+437+/* get the converted ByteCount for a SMB packet and return it */438+static inline __u16439+get_bcc(struct smb_hdr *hdr)440+{441+ __u16 *bc_ptr = (__u16 *)BCC(hdr);442+443+ return get_unaligned(bc_ptr);444+}445+446+/* get the unconverted ByteCount for a SMB packet and return it */447+static inline __u16448+get_bcc_le(struct smb_hdr *hdr)449+{450+ __le16 *bc_ptr = (__le16 *)BCC(hdr);451+452+ return get_unaligned_le16(bc_ptr);453+}454+455+/* set the ByteCount for a SMB packet in host-byte order */456+static inline void457+put_bcc(__u16 count, struct smb_hdr *hdr)458+{459+ __u16 *bc_ptr = (__u16 *)BCC(hdr);460+461+ put_unaligned(count, bc_ptr);462+}463+464+/* set the ByteCount for a SMB packet in little-endian */465+static inline void466+put_bcc_le(__u16 count, struct smb_hdr *hdr)467+{468+ __le16 *bc_ptr = (__le16 *)BCC(hdr);469+470+ put_unaligned_le16(count, bc_ptr);471+}472473/*474 * Computer Name Length (since Netbios name was length 16 with last byte 0x20)
+25-29
fs/cifs/cifssmb.c
···331332static int validate_t2(struct smb_t2_rsp *pSMB)333{334- int rc = -EINVAL;335- int total_size;336- char *pBCC;337338- /* check for plausible wct, bcc and t2 data and parm sizes */000339 /* check for parm and data offset going beyond end of smb */340- if (pSMB->hdr.WordCount >= 10) {341- if ((le16_to_cpu(pSMB->t2_rsp.ParameterOffset) <= 1024) &&342- (le16_to_cpu(pSMB->t2_rsp.DataOffset) <= 1024)) {343- /* check that bcc is at least as big as parms + data */344- /* check that bcc is less than negotiated smb buffer */345- total_size = le16_to_cpu(pSMB->t2_rsp.ParameterCount);346- if (total_size < 512) {347- total_size +=348- le16_to_cpu(pSMB->t2_rsp.DataCount);349- /* BCC le converted in SendReceive */350- pBCC = (pSMB->hdr.WordCount * 2) +351- sizeof(struct smb_hdr) +352- (char *)pSMB;353- if ((total_size <= (*(u16 *)pBCC)) &&354- (total_size <355- CIFSMaxBufSize+MAX_CIFS_HDR_SIZE)) {356- return 0;357- }358- }359- }360- }361 cifs_dump_mem("Invalid transact2 SMB: ", (char *)pSMB,362 sizeof(struct smb_t2_rsp) + 16);363- return rc;364}0365int366CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)367{···450 server->maxBuf = min((__u32)le16_to_cpu(rsp->MaxBufSize),451 (__u32)CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);452 server->max_vcs = le16_to_cpu(rsp->MaxNumberVcs);453- GETU32(server->sessid) = le32_to_cpu(rsp->SessionKey);454 /* even though we do not use raw we might as well set this455 accurately, in case we ever find a need for it */456 if ((le16_to_cpu(rsp->RawMode) & RAW_ENABLE) == RAW_ENABLE) {···563 (__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);564 server->max_rw = le32_to_cpu(pSMBr->MaxRawSize);565 cFYI(DBG2, "Max buf = %d", ses->server->maxBuf);566- GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey);567 server->capabilities = le32_to_cpu(pSMBr->Capabilities);568 server->timeAdj = (int)(__s16)le16_to_cpu(pSMBr->ServerTimeZone);569 server->timeAdj *= 60;···5607 }56085609 /* make sure list_len doesn't go past end of SMB */5610- end_of_smb = (char *)pByteArea(&pSMBr->hdr) + BCC(&pSMBr->hdr);5611 if ((char *)ea_response_data + list_len > end_of_smb) {5612 cFYI(1, "EA list appears to go beyond SMB");5613 rc = -EIO;
···331332static int validate_t2(struct smb_t2_rsp *pSMB)333{334+ unsigned int total_size;00335336+ /* check for plausible wct */337+ if (pSMB->hdr.WordCount < 10)338+ goto vt2_err;339+340 /* check for parm and data offset going beyond end of smb */341+ if (get_unaligned_le16(&pSMB->t2_rsp.ParameterOffset) > 1024 ||342+ get_unaligned_le16(&pSMB->t2_rsp.DataOffset) > 1024)343+ goto vt2_err;344+345+ /* check that bcc is at least as big as parms + data */346+ /* check that bcc is less than negotiated smb buffer */347+ total_size = get_unaligned_le16(&pSMB->t2_rsp.ParameterCount);348+ if (total_size >= 512)349+ goto vt2_err;350+351+ total_size += get_unaligned_le16(&pSMB->t2_rsp.DataCount);352+ if (total_size > get_bcc(&pSMB->hdr) ||353+ total_size >= CIFSMaxBufSize + MAX_CIFS_HDR_SIZE)354+ goto vt2_err;355+356+ return 0;357+vt2_err:0000358 cifs_dump_mem("Invalid transact2 SMB: ", (char *)pSMB,359 sizeof(struct smb_t2_rsp) + 16);360+ return -EINVAL;361}362+363int364CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)365{···452 server->maxBuf = min((__u32)le16_to_cpu(rsp->MaxBufSize),453 (__u32)CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);454 server->max_vcs = le16_to_cpu(rsp->MaxNumberVcs);0455 /* even though we do not use raw we might as well set this456 accurately, in case we ever find a need for it */457 if ((le16_to_cpu(rsp->RawMode) & RAW_ENABLE) == RAW_ENABLE) {···566 (__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);567 server->max_rw = le32_to_cpu(pSMBr->MaxRawSize);568 cFYI(DBG2, "Max buf = %d", ses->server->maxBuf);0569 server->capabilities = le32_to_cpu(pSMBr->Capabilities);570 server->timeAdj = (int)(__s16)le16_to_cpu(pSMBr->ServerTimeZone);571 server->timeAdj *= 60;···5611 }56125613 /* make sure list_len doesn't go past end of SMB */5614+ end_of_smb = (char *)pByteArea(&pSMBr->hdr) + get_bcc(&pSMBr->hdr);5615 if ((char *)ea_response_data + list_len > end_of_smb) {5616 cFYI(1, "EA list appears to go beyond SMB");5617 rc = -EIO;
+19-24
fs/cifs/connect.c
···232static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize)233{234 struct smb_t2_rsp *pSMBt;235- int total_data_size;236- int data_in_this_rsp;237 int remaining;0238239 if (pSMB->Command != SMB_COM_TRANSACTION2)240 return 0;···247248 pSMBt = (struct smb_t2_rsp *)pSMB;249250- total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount);251- data_in_this_rsp = le16_to_cpu(pSMBt->t2_rsp.DataCount);252253 remaining = total_data_size - data_in_this_rsp;254···274{275 struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond;276 struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB;277- int total_data_size;278- int total_in_buf;279- int remaining;280- int total_in_buf2;281 char *data_area_of_target;282 char *data_area_of_buf2;283- __u16 byte_count;0284285- total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount);286287- if (total_data_size != le16_to_cpu(pSMB2->t2_rsp.TotalDataCount)) {0288 cFYI(1, "total data size of primary and secondary t2 differ");289- }290291- total_in_buf = le16_to_cpu(pSMBt->t2_rsp.DataCount);292293 remaining = total_data_size - total_in_buf;294···295 if (remaining == 0) /* nothing to do, ignore */296 return 0;297298- total_in_buf2 = le16_to_cpu(pSMB2->t2_rsp.DataCount);299 if (remaining < total_in_buf2) {300 cFYI(1, "transact2 2nd response contains too much data");301 }302303 /* find end of first SMB data area */304 data_area_of_target = (char *)&pSMBt->hdr.Protocol +305- le16_to_cpu(pSMBt->t2_rsp.DataOffset);306 /* validate target area */307308- data_area_of_buf2 = (char *) &pSMB2->hdr.Protocol +309- le16_to_cpu(pSMB2->t2_rsp.DataOffset);310311 data_area_of_target += total_in_buf;312313 /* copy second buffer into end of first buffer */314 memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2);315 total_in_buf += total_in_buf2;316- pSMBt->t2_rsp.DataCount = cpu_to_le16(total_in_buf);317- byte_count = le16_to_cpu(BCC_LE(pTargetSMB));318 byte_count += total_in_buf2;319- BCC_LE(pTargetSMB) = cpu_to_le16(byte_count);320321 byte_count = pTargetSMB->smb_buf_length;322 byte_count += total_in_buf2;···330 return 0; /* we are done */331 } else /* more responses to go */332 return 1;333-334}335336static void···2932 TCONX_RSP *pSMBr;2933 unsigned char *bcc_ptr;2934 int rc = 0;2935- int length, bytes_left;2936- __u16 count;29372938 if (ses == NULL)2939 return -EIO;···3027 tcon->need_reconnect = false;3028 tcon->tid = smb_buffer_response->Tid;3029 bcc_ptr = pByteArea(smb_buffer_response);3030- bytes_left = BCC(smb_buffer_response);3031 length = strnlen(bcc_ptr, bytes_left - 2);3032 if (smb_buffer->Flags2 & SMBFLG2_UNICODE)3033 is_unicode = true;
···232static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize)233{234 struct smb_t2_rsp *pSMBt;00235 int remaining;236+ __u16 total_data_size, data_in_this_rsp;237238 if (pSMB->Command != SMB_COM_TRANSACTION2)239 return 0;···248249 pSMBt = (struct smb_t2_rsp *)pSMB;250251+ total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);252+ data_in_this_rsp = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);253254 remaining = total_data_size - data_in_this_rsp;255···275{276 struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond;277 struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB;0000278 char *data_area_of_target;279 char *data_area_of_buf2;280+ int remaining;281+ __u16 byte_count, total_data_size, total_in_buf, total_in_buf2;282283+ total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);284285+ if (total_data_size !=286+ get_unaligned_le16(&pSMB2->t2_rsp.TotalDataCount))287 cFYI(1, "total data size of primary and secondary t2 differ");0288289+ total_in_buf = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);290291 remaining = total_data_size - total_in_buf;292···299 if (remaining == 0) /* nothing to do, ignore */300 return 0;301302+ total_in_buf2 = get_unaligned_le16(&pSMB2->t2_rsp.DataCount);303 if (remaining < total_in_buf2) {304 cFYI(1, "transact2 2nd response contains too much data");305 }306307 /* find end of first SMB data area */308 data_area_of_target = (char *)&pSMBt->hdr.Protocol +309+ get_unaligned_le16(&pSMBt->t2_rsp.DataOffset);310 /* validate target area */311312+ data_area_of_buf2 = (char *)&pSMB2->hdr.Protocol +313+ get_unaligned_le16(&pSMB2->t2_rsp.DataOffset);314315 data_area_of_target += total_in_buf;316317 /* copy second buffer into end of first buffer */318 memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2);319 total_in_buf += total_in_buf2;320+ put_unaligned_le16(total_in_buf, &pSMBt->t2_rsp.DataCount);321+ byte_count = get_bcc_le(pTargetSMB);322 byte_count += total_in_buf2;323+ put_bcc_le(byte_count, pTargetSMB);324325 byte_count = pTargetSMB->smb_buf_length;326 byte_count += total_in_buf2;···334 return 0; /* we are done */335 } else /* more responses to go */336 return 1;0337}338339static void···2937 TCONX_RSP *pSMBr;2938 unsigned char *bcc_ptr;2939 int rc = 0;2940+ int length;2941+ __u16 bytes_left, count;29422943 if (ses == NULL)2944 return -EIO;···3032 tcon->need_reconnect = false;3033 tcon->tid = smb_buffer_response->Tid;3034 bcc_ptr = pByteArea(smb_buffer_response);3035+ bytes_left = get_bcc(smb_buffer_response);3036 length = strnlen(bcc_ptr, bytes_left - 2);3037 if (smb_buffer->Flags2 & SMBFLG2_UNICODE)3038 is_unicode = true;
···287 struct inode *inode = cifs_file->dentry->d_inode;288 struct cifsTconInfo *tcon = tlink_tcon(cifs_file->tlink);289 struct cifsInodeInfo *cifsi = CIFS_I(inode);290+ struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);291 struct cifsLockInfo *li, *tmp;292293 spin_lock(&cifs_file_list_lock);···302 if (list_empty(&cifsi->openFileList)) {303 cFYI(1, "closing last open instance for inode %p",304 cifs_file->dentry->d_inode);305+306+ /* in strict cache mode we need invalidate mapping on the last307+ close because it may cause a error when we open this file308+ again and get at least level II oplock */309+ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)310+ CIFS_I(inode)->invalid_mapping = true;311+312 cifs_set_oplock_level(cifsi, 0);313 }314 spin_unlock(&cifs_file_list_lock);···1520 return rc;1521}15221523+int cifs_strict_fsync(struct file *file, int datasync)1524{1525 int xid;1526 int rc = 0;1527 struct cifsTconInfo *tcon;1528 struct cifsFileInfo *smbfile = file->private_data;1529 struct inode *inode = file->f_path.dentry->d_inode;1530+ struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);15311532 xid = GetXid();15331534 cFYI(1, "Sync file - name: %s datasync: 0x%x",1535 file->f_path.dentry->d_name.name, datasync);15361537+ if (!CIFS_I(inode)->clientCanCacheRead)1538+ cifs_invalidate_mapping(inode);015391540+ tcon = tlink_tcon(smbfile->tlink);1541+ if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))1542+ rc = CIFSSMBFlush(xid, tcon, smbfile->netfid);1543+1544+ FreeXid(xid);1545+ return rc;1546+}1547+1548+int cifs_fsync(struct file *file, int datasync)1549+{1550+ int xid;1551+ int rc = 0;1552+ struct cifsTconInfo *tcon;1553+ struct cifsFileInfo *smbfile = file->private_data;1554+ struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);1555+1556+ xid = GetXid();1557+1558+ cFYI(1, "Sync file - name: %s datasync: 0x%x",1559+ file->f_path.dentry->d_name.name, datasync);1560+1561+ tcon = tlink_tcon(smbfile->tlink);1562+ if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))1563+ rc = CIFSSMBFlush(xid, tcon, smbfile->netfid);15641565 FreeXid(xid);1566 return rc;···1591 return rc;1592}15931594+static ssize_t1595+cifs_iovec_read(struct file *file, const struct iovec *iov,1596+ unsigned long nr_segs, loff_t *poffset)1597{1598+ int rc;1599+ int xid;1600+ unsigned int total_read, bytes_read = 0;1601+ size_t len, cur_len;1602+ int iov_offset = 0;1603 struct cifs_sb_info *cifs_sb;1604 struct cifsTconInfo *pTcon;01605 struct cifsFileInfo *open_file;001606 struct smb_com_read_rsp *pSMBr;1607+ char *read_data;1608+1609+ if (!nr_segs)1610+ return 0;1611+1612+ len = iov_length(iov, nr_segs);1613+ if (!len)1614+ return 0;16151616 xid = GetXid();1617 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);1618000001619 open_file = file->private_data;1620 pTcon = tlink_tcon(open_file->tlink);16211622 if ((file->f_flags & O_ACCMODE) == O_WRONLY)1623 cFYI(1, "attempting read on write only file instance");16241625+ for (total_read = 0; total_read < len; total_read += bytes_read) {1626+ cur_len = min_t(const size_t, len - total_read, cifs_sb->rsize);0001627 rc = -EAGAIN;1628+ read_data = NULL;1629+1630 while (rc == -EAGAIN) {1631 int buf_type = CIFS_NO_BUFFER;1632 if (open_file->invalidHandle) {···1634 if (rc != 0)1635 break;1636 }1637+ rc = CIFSSMBRead(xid, pTcon, open_file->netfid,1638+ cur_len, *poffset, &bytes_read,1639+ &read_data, &buf_type);1640+ pSMBr = (struct smb_com_read_rsp *)read_data;1641+ if (read_data) {1642+ char *data_offset = read_data + 4 +1643+ le16_to_cpu(pSMBr->DataOffset);1644+ if (memcpy_toiovecend(iov, data_offset,1645+ iov_offset, bytes_read))0001646 rc = -EFAULT;01647 if (buf_type == CIFS_SMALL_BUFFER)1648+ cifs_small_buf_release(read_data);1649 else if (buf_type == CIFS_LARGE_BUFFER)1650+ cifs_buf_release(read_data);1651+ read_data = NULL;1652+ iov_offset += bytes_read;1653 }1654 }1655+1656 if (rc || (bytes_read == 0)) {1657 if (total_read) {1658 break;···1667 *poffset += bytes_read;1668 }1669 }1670+1671 FreeXid(xid);1672 return total_read;1673}16741675+ssize_t cifs_user_read(struct file *file, char __user *read_data,1676+ size_t read_size, loff_t *poffset)1677+{1678+ struct iovec iov;1679+ iov.iov_base = read_data;1680+ iov.iov_len = read_size;1681+1682+ return cifs_iovec_read(file, &iov, 1, poffset);1683+}1684+1685+static ssize_t cifs_user_readv(struct kiocb *iocb, const struct iovec *iov,1686+ unsigned long nr_segs, loff_t pos)1687+{1688+ ssize_t read;1689+1690+ read = cifs_iovec_read(iocb->ki_filp, iov, nr_segs, &pos);1691+ if (read > 0)1692+ iocb->ki_pos = pos;1693+1694+ return read;1695+}1696+1697+ssize_t cifs_strict_readv(struct kiocb *iocb, const struct iovec *iov,1698+ unsigned long nr_segs, loff_t pos)1699+{1700+ struct inode *inode;1701+1702+ inode = iocb->ki_filp->f_path.dentry->d_inode;1703+1704+ if (CIFS_I(inode)->clientCanCacheRead)1705+ return generic_file_aio_read(iocb, iov, nr_segs, pos);1706+1707+ /*1708+ * In strict cache mode we need to read from the server all the time1709+ * if we don't have level II oplock because the server can delay mtime1710+ * change - so we can't make a decision about inode invalidating.1711+ * And we can also fail with pagereading if there are mandatory locks1712+ * on pages affected by this read but not on the region from pos to1713+ * pos+len-1.1714+ */1715+1716+ return cifs_user_readv(iocb, iov, nr_segs, pos);1717+}17181719static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,1720+ loff_t *poffset)1721{1722 int rc = -EACCES;1723 unsigned int bytes_read = 0;···1739 }1740 FreeXid(xid);1741 return total_read;1742+}1743+1744+int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma)1745+{1746+ int rc, xid;1747+ struct inode *inode = file->f_path.dentry->d_inode;1748+1749+ xid = GetXid();1750+1751+ if (!CIFS_I(inode)->clientCanCacheRead)1752+ cifs_invalidate_mapping(inode);1753+1754+ rc = generic_file_mmap(file, vma);1755+ FreeXid(xid);1756+ return rc;1757}17581759int cifs_file_mmap(struct file *file, struct vm_area_struct *vma)
+6-2
fs/cifs/inode.c
···44 inode->i_fop = &cifs_file_direct_nobrl_ops;45 else46 inode->i_fop = &cifs_file_direct_ops;0000047 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)48 inode->i_fop = &cifs_file_nobrl_ops;49 else { /* not direct, send byte range locks */50 inode->i_fop = &cifs_file_ops;51 }52-5354 /* check if server can support readpages */55 if (cifs_sb_master_tcon(cifs_sb)->ses->server->maxBuf <···1683/*1684 * Zap the cache. Called when invalid_mapping flag is set.1685 */1686-static void1687cifs_invalidate_mapping(struct inode *inode)1688{1689 int rc;
···44 inode->i_fop = &cifs_file_direct_nobrl_ops;45 else46 inode->i_fop = &cifs_file_direct_ops;47+ } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) {48+ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)49+ inode->i_fop = &cifs_file_strict_nobrl_ops;50+ else51+ inode->i_fop = &cifs_file_strict_ops;52 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)53 inode->i_fop = &cifs_file_nobrl_ops;54 else { /* not direct, send byte range locks */55 inode->i_fop = &cifs_file_ops;56 }05758 /* check if server can support readpages */59 if (cifs_sb_master_tcon(cifs_sb)->ses->server->maxBuf <···1679/*1680 * Zap the cache. Called when invalid_mapping flag is set.1681 */1682+void1683cifs_invalidate_mapping(struct inode *inode)1684{1685 int rc;
-71
fs/cifs/misc.c
···637 return;638}639640-/* Convert 16 bit Unicode pathname to wire format from string in current code641- page. Conversion may involve remapping up the seven characters that are642- only legal in POSIX-like OS (if they are present in the string). Path643- names are little endian 16 bit Unicode on the wire */644-int645-cifsConvertToUCS(__le16 *target, const char *source, int maxlen,646- const struct nls_table *cp, int mapChars)647-{648- int i, j, charlen;649- int len_remaining = maxlen;650- char src_char;651- __u16 temp;652-653- if (!mapChars)654- return cifs_strtoUCS(target, source, PATH_MAX, cp);655-656- for (i = 0, j = 0; i < maxlen; j++) {657- src_char = source[i];658- switch (src_char) {659- case 0:660- target[j] = 0;661- goto ctoUCS_out;662- case ':':663- target[j] = cpu_to_le16(UNI_COLON);664- break;665- case '*':666- target[j] = cpu_to_le16(UNI_ASTERIK);667- break;668- case '?':669- target[j] = cpu_to_le16(UNI_QUESTION);670- break;671- case '<':672- target[j] = cpu_to_le16(UNI_LESSTHAN);673- break;674- case '>':675- target[j] = cpu_to_le16(UNI_GRTRTHAN);676- break;677- case '|':678- target[j] = cpu_to_le16(UNI_PIPE);679- break;680- /* BB We can not handle remapping slash until681- all the calls to build_path_from_dentry682- are modified, as they use slash as separator BB */683- /* case '\\':684- target[j] = cpu_to_le16(UNI_SLASH);685- break;*/686- default:687- charlen = cp->char2uni(source+i,688- len_remaining, &temp);689- /* if no match, use question mark, which690- at least in some cases servers as wild card */691- if (charlen < 1) {692- target[j] = cpu_to_le16(0x003f);693- charlen = 1;694- } else695- target[j] = cpu_to_le16(temp);696- len_remaining -= charlen;697- /* character may take more than one byte in the698- the source string, but will take exactly two699- bytes in the target string */700- i += charlen;701- continue;702- }703- i++; /* move to next char in source string */704- len_remaining--;705- }706-707-ctoUCS_out:708- return i;709-}710-711void712cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb)713{
···916smbCalcSize(struct smb_hdr *ptr)917{918 return (sizeof(struct smb_hdr) + (2 * ptr->WordCount) +919- 2 /* size of the bcc field */ + BCC(ptr));920}921922unsigned int923smbCalcSize_LE(struct smb_hdr *ptr)924{925 return (sizeof(struct smb_hdr) + (2 * ptr->WordCount) +926- 2 /* size of the bcc field */ + le16_to_cpu(BCC_LE(ptr)));927}928929/* The following are taken from fs/ntfs/util.c */
···916smbCalcSize(struct smb_hdr *ptr)917{918 return (sizeof(struct smb_hdr) + (2 * ptr->WordCount) +919+ 2 /* size of the bcc field */ + get_bcc(ptr));920}921922unsigned int923smbCalcSize_LE(struct smb_hdr *ptr)924{925 return (sizeof(struct smb_hdr) + (2 * ptr->WordCount) +926+ 2 /* size of the bcc field */ + get_bcc_le(ptr));927}928929/* The following are taken from fs/ntfs/util.c */
+6-7
fs/cifs/sess.c
···277}278279static void280-decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifsSesInfo *ses,281 const struct nls_table *nls_cp)282{283 int len;···323 return;324}325326-static int decode_ascii_ssetup(char **pbcc_area, int bleft,327 struct cifsSesInfo *ses,328 const struct nls_table *nls_cp)329{···575 char *str_area;576 SESSION_SETUP_ANDX *pSMB;577 __u32 capabilities;578- int count;579 int resp_buf_type;580 struct kvec iov[3];581 enum securityEnum type;582- __u16 action;583- int bytes_remaining;584 struct key *spnego_key = NULL;585 __le32 phase = NtLmNegotiate; /* NTLMSSP, if needed, is multistage */586 u16 blob_len;···875 count = iov[1].iov_len + iov[2].iov_len;876 smb_buf->smb_buf_length += count;877878- BCC_LE(smb_buf) = cpu_to_le16(count);879880 rc = SendReceive2(xid, ses, iov, 3 /* num_iovecs */, &resp_buf_type,881 CIFS_LOG_ERROR);···909 cFYI(1, "UID = %d ", ses->Suid);910 /* response can have either 3 or 4 word count - Samba sends 3 */911 /* and lanman response is 3 */912- bytes_remaining = BCC(smb_buf);913 bcc_ptr = pByteArea(smb_buf);914915 if (smb_buf->WordCount == 4) {
···277}278279static void280+decode_unicode_ssetup(char **pbcc_area, __u16 bleft, struct cifsSesInfo *ses,281 const struct nls_table *nls_cp)282{283 int len;···323 return;324}325326+static int decode_ascii_ssetup(char **pbcc_area, __u16 bleft,327 struct cifsSesInfo *ses,328 const struct nls_table *nls_cp)329{···575 char *str_area;576 SESSION_SETUP_ANDX *pSMB;577 __u32 capabilities;578+ __u16 count;579 int resp_buf_type;580 struct kvec iov[3];581 enum securityEnum type;582+ __u16 action, bytes_remaining;0583 struct key *spnego_key = NULL;584 __le32 phase = NtLmNegotiate; /* NTLMSSP, if needed, is multistage */585 u16 blob_len;···876 count = iov[1].iov_len + iov[2].iov_len;877 smb_buf->smb_buf_length += count;878879+ put_bcc_le(count, smb_buf);880881 rc = SendReceive2(xid, ses, iov, 3 /* num_iovecs */, &resp_buf_type,882 CIFS_LOG_ERROR);···910 cFYI(1, "UID = %d ", ses->Suid);911 /* response can have either 3 or 4 word count - Samba sends 3 */912 /* and lanman response is 3 */913+ bytes_remaining = get_bcc(smb_buf);914 bcc_ptr = pByteArea(smb_buf);915916 if (smb_buf->WordCount == 4) {
+4-5
fs/cifs/transport.c
···484 in_buf->smb_buf_length = sizeof(struct smb_hdr) - 4 + 2;485 in_buf->Command = SMB_COM_NT_CANCEL;486 in_buf->WordCount = 0;487- BCC_LE(in_buf) = 0;488489 mutex_lock(&server->srv_mutex);490 rc = cifs_sign_smb(in_buf, server, &mid->sequence_number);···632 if (receive_len >= sizeof(struct smb_hdr) - 4633 /* do not count RFC1001 header */ +634 (2 * midQ->resp_buf->WordCount) + 2 /* bcc */ )635- BCC(midQ->resp_buf) =636- le16_to_cpu(BCC_LE(midQ->resp_buf));637 if ((flags & CIFS_NO_RESP) == 0)638 midQ->resp_buf = NULL; /* mark it so buf will639 not be freed by···775 if (receive_len >= sizeof(struct smb_hdr) - 4776 /* do not count RFC1001 header */ +777 (2 * out_buf->WordCount) + 2 /* bcc */ )778- BCC(out_buf) = le16_to_cpu(BCC_LE(out_buf));779 } else {780 rc = -EIO;781 cERROR(1, "Bad MID state?");···976 if (receive_len >= sizeof(struct smb_hdr) - 4977 /* do not count RFC1001 header */ +978 (2 * out_buf->WordCount) + 2 /* bcc */ )979- BCC(out_buf) = le16_to_cpu(BCC_LE(out_buf));980981out:982 delete_mid(midQ);
···484 in_buf->smb_buf_length = sizeof(struct smb_hdr) - 4 + 2;485 in_buf->Command = SMB_COM_NT_CANCEL;486 in_buf->WordCount = 0;487+ put_bcc_le(0, in_buf);488489 mutex_lock(&server->srv_mutex);490 rc = cifs_sign_smb(in_buf, server, &mid->sequence_number);···632 if (receive_len >= sizeof(struct smb_hdr) - 4633 /* do not count RFC1001 header */ +634 (2 * midQ->resp_buf->WordCount) + 2 /* bcc */ )635+ put_bcc(get_bcc_le(midQ->resp_buf), midQ->resp_buf);0636 if ((flags & CIFS_NO_RESP) == 0)637 midQ->resp_buf = NULL; /* mark it so buf will638 not be freed by···776 if (receive_len >= sizeof(struct smb_hdr) - 4777 /* do not count RFC1001 header */ +778 (2 * out_buf->WordCount) + 2 /* bcc */ )779+ put_bcc(get_bcc_le(midQ->resp_buf), midQ->resp_buf);780 } else {781 rc = -EIO;782 cERROR(1, "Bad MID state?");···977 if (receive_len >= sizeof(struct smb_hdr) - 4978 /* do not count RFC1001 header */ +979 (2 * out_buf->WordCount) + 2 /* bcc */ )980+ put_bcc(get_bcc_le(out_buf), out_buf);981982out:983 delete_mid(midQ);