Merge branch 'for-next'

+402 -237
+1
fs/cifs/cifs_fs_sb.h
··· 40 40 #define CIFS_MOUNT_FSCACHE 0x8000 /* local caching enabled */ 41 41 #define CIFS_MOUNT_MF_SYMLINKS 0x10000 /* Minshall+French Symlinks enabled */ 42 42 #define CIFS_MOUNT_MULTIUSER 0x20000 /* multiuser mount */ 43 + #define CIFS_MOUNT_STRICT_IO 0x40000 /* strict cache mode */ 43 44 44 45 struct cifs_sb_info { 45 46 struct rb_root tlink_tree;
+104 -23
fs/cifs/cifs_unicode.c
··· 44 44 int charlen, outlen = 0; 45 45 int maxwords = maxbytes / 2; 46 46 char tmp[NLS_MAX_CHARSET_SIZE]; 47 + __u16 ftmp; 47 48 48 - for (i = 0; i < maxwords && from[i]; i++) { 49 - charlen = codepage->uni2char(le16_to_cpu(from[i]), tmp, 50 - NLS_MAX_CHARSET_SIZE); 49 + 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); 51 55 if (charlen > 0) 52 56 outlen += charlen; 53 57 else ··· 62 58 } 63 59 64 60 /* 65 - * cifs_mapchar - convert a little-endian char to proper char in codepage 61 + * cifs_mapchar - convert a host-endian char to proper char in codepage 66 62 * @target - where converted character should be copied 67 - * @src_char - 2 byte little-endian source character 63 + * @src_char - 2 byte host-endian source character 68 64 * @cp - codepage to which character should be converted 69 65 * @mapchar - should character be mapped according to mapchars mount option? 70 66 * ··· 73 69 * enough to hold the result of the conversion (at least NLS_MAX_CHARSET_SIZE). 74 70 */ 75 71 static int 76 - cifs_mapchar(char *target, const __le16 src_char, const struct nls_table *cp, 72 + cifs_mapchar(char *target, const __u16 src_char, const struct nls_table *cp, 77 73 bool mapchar) 78 74 { 79 75 int len = 1; ··· 86 82 * build_path_from_dentry are modified, as they use slash as 87 83 * separator. 88 84 */ 89 - switch (le16_to_cpu(src_char)) { 85 + switch (src_char) { 90 86 case UNI_COLON: 91 87 *target = ':'; 92 88 break; ··· 113 109 return len; 114 110 115 111 cp_convert: 116 - len = cp->uni2char(le16_to_cpu(src_char), target, 117 - NLS_MAX_CHARSET_SIZE); 112 + len = cp->uni2char(src_char, target, NLS_MAX_CHARSET_SIZE); 118 113 if (len <= 0) { 119 114 *target = '?'; 120 115 len = 1; ··· 152 149 int nullsize = nls_nullsize(codepage); 153 150 int fromwords = fromlen / 2; 154 151 char tmp[NLS_MAX_CHARSET_SIZE]; 152 + __u16 ftmp; 155 153 156 154 /* 157 155 * because the chars can be of varying widths, we need to take care ··· 162 158 */ 163 159 safelen = tolen - (NLS_MAX_CHARSET_SIZE + nullsize); 164 160 165 - for (i = 0; i < fromwords && from[i]; i++) { 161 + for (i = 0; i < fromwords; i++) { 162 + ftmp = get_unaligned_le16(&from[i]); 163 + if (ftmp == 0) 164 + break; 165 + 166 166 /* 167 167 * check to see if converting this character might make the 168 168 * conversion bleed into the null terminator 169 169 */ 170 170 if (outlen >= safelen) { 171 - charlen = cifs_mapchar(tmp, from[i], codepage, mapchar); 171 + charlen = cifs_mapchar(tmp, ftmp, codepage, mapchar); 172 172 if ((outlen + charlen) > (tolen - nullsize)) 173 173 break; 174 174 } 175 175 176 176 /* put converted char into 'to' buffer */ 177 - charlen = cifs_mapchar(&to[outlen], from[i], codepage, mapchar); 177 + charlen = cifs_mapchar(&to[outlen], ftmp, codepage, mapchar); 178 178 outlen += charlen; 179 179 } 180 180 ··· 201 193 { 202 194 int charlen; 203 195 int i; 204 - wchar_t *wchar_to = (wchar_t *)to; /* needed to quiet sparse */ 196 + wchar_t wchar_to; /* needed to quiet sparse */ 205 197 206 198 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]); 199 + charlen = codepage->char2uni(from, len, &wchar_to); 210 200 if (charlen < 1) { 211 - cERROR(1, "strtoUCS: char2uni of %d returned %d", 212 - (int)*from, charlen); 201 + cERROR(1, "strtoUCS: char2uni of 0x%x returned %d", 202 + *from, charlen); 213 203 /* A question mark */ 214 - to[i] = cpu_to_le16(0x003f); 204 + wchar_to = 0x003f; 215 205 charlen = 1; 216 - } else 217 - to[i] = cpu_to_le16(wchar_to[i]); 218 - 206 + } 207 + put_unaligned_le16(wchar_to, &to[i]); 219 208 } 220 209 221 - to[i] = 0; 210 + put_unaligned_le16(0, &to[i]); 222 211 return i; 223 212 } 224 213 ··· 255 250 } 256 251 257 252 return dst; 253 + } 254 + 255 + /* 256 + * Convert 16 bit Unicode pathname to wire format from string in current code 257 + * page. Conversion may involve remapping up the six characters that are 258 + * only legal in POSIX-like OS (if they are present in the string). Path 259 + * names are little endian 16 bit Unicode on the wire 260 + */ 261 + int 262 + 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 in 307 + * some cases serves as wild card 308 + */ 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 source 316 + * string, but will take exactly two bytes in the 317 + * target string 318 + */ 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; 258 329 } 259 330
+38
fs/cifs/cifsfs.c
··· 733 733 .setlease = cifs_setlease, 734 734 }; 735 735 736 + const struct file_operations cifs_file_strict_ops = { 737 + .read = do_sync_read, 738 + .write = do_sync_write, 739 + .aio_read = cifs_strict_readv, 740 + .aio_write = cifs_file_aio_write, 741 + .open = cifs_open, 742 + .release = cifs_close, 743 + .lock = cifs_lock, 744 + .fsync = cifs_strict_fsync, 745 + .flush = cifs_flush, 746 + .mmap = cifs_file_strict_mmap, 747 + .splice_read = generic_file_splice_read, 748 + .llseek = cifs_llseek, 749 + #ifdef CONFIG_CIFS_POSIX 750 + .unlocked_ioctl = cifs_ioctl, 751 + #endif /* CONFIG_CIFS_POSIX */ 752 + .setlease = cifs_setlease, 753 + }; 754 + 736 755 const struct file_operations cifs_file_direct_ops = { 737 756 /* no aio, no readv - 738 757 BB reevaluate whether they can be done with directio, no cache */ ··· 770 751 .llseek = cifs_llseek, 771 752 .setlease = cifs_setlease, 772 753 }; 754 + 773 755 const struct file_operations cifs_file_nobrl_ops = { 774 756 .read = do_sync_read, 775 757 .write = do_sync_write, ··· 781 761 .fsync = cifs_fsync, 782 762 .flush = cifs_flush, 783 763 .mmap = cifs_file_mmap, 764 + .splice_read = generic_file_splice_read, 765 + .llseek = cifs_llseek, 766 + #ifdef CONFIG_CIFS_POSIX 767 + .unlocked_ioctl = cifs_ioctl, 768 + #endif /* CONFIG_CIFS_POSIX */ 769 + .setlease = cifs_setlease, 770 + }; 771 + 772 + const struct file_operations cifs_file_strict_nobrl_ops = { 773 + .read = do_sync_read, 774 + .write = do_sync_write, 775 + .aio_read = cifs_strict_readv, 776 + .aio_write = cifs_file_aio_write, 777 + .open = cifs_open, 778 + .release = cifs_close, 779 + .fsync = cifs_strict_fsync, 780 + .flush = cifs_flush, 781 + .mmap = cifs_file_strict_mmap, 784 782 .splice_read = generic_file_splice_read, 785 783 .llseek = cifs_llseek, 786 784 #ifdef CONFIG_CIFS_POSIX
+10 -3
fs/cifs/cifsfs.h
··· 61 61 struct dentry *); 62 62 extern int cifs_revalidate_file(struct file *filp); 63 63 extern int cifs_revalidate_dentry(struct dentry *); 64 + extern void cifs_invalidate_mapping(struct inode *inode); 64 65 extern int cifs_getattr(struct vfsmount *, struct dentry *, struct kstat *); 65 66 extern int cifs_setattr(struct dentry *, struct iattr *); 66 67 ··· 73 72 /* Functions related to files and directories */ 74 73 extern const struct file_operations cifs_file_ops; 75 74 extern 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 */ 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; 78 79 extern int cifs_open(struct inode *inode, struct file *file); 79 80 extern int cifs_close(struct inode *inode, struct file *file); 80 81 extern int cifs_closedir(struct inode *inode, struct file *file); 81 82 extern ssize_t cifs_user_read(struct file *file, char __user *read_data, 82 - size_t read_size, loff_t *poffset); 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); 83 86 extern ssize_t cifs_user_write(struct file *file, const char __user *write_data, 84 87 size_t write_size, loff_t *poffset); 85 88 extern int cifs_lock(struct file *, int, struct file_lock *); 86 89 extern int cifs_fsync(struct file *, int); 90 + extern int cifs_strict_fsync(struct file *, int); 87 91 extern int cifs_flush(struct file *, fl_owner_t id); 88 92 extern int cifs_file_mmap(struct file * , struct vm_area_struct *); 93 + extern int cifs_file_strict_mmap(struct file * , struct vm_area_struct *); 89 94 extern const struct file_operations cifs_dir_ops; 90 95 extern int cifs_dir_open(struct inode *inode, struct file *file); 91 96 extern int cifs_readdir(struct file *file, void *direntry, filldir_t filldir);
+14 -22
fs/cifs/cifsglob.h
··· 161 161 int srv_count; /* reference counter */ 162 162 /* 15 character server name + 0x20 16th byte indicating type = srv */ 163 163 char server_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL]; 164 + enum statusEnum tcpStatus; /* what we think the status is */ 164 165 char *hostname; /* hostname portion of UNC string */ 165 166 struct socket *ssocket; 166 167 struct sockaddr_storage dstaddr; ··· 169 168 wait_queue_head_t response_q; 170 169 wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/ 171 170 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 171 bool noblocksnd; /* use blocking sendmsg */ 179 172 bool noautotune; /* do not autotune send buf sizes */ 180 173 bool tcp_nodelay; 181 174 atomic_t inFlight; /* number of requests on the wire to server */ 182 - #ifdef CONFIG_CIFS_STATS2 183 - atomic_t inSend; /* requests trying to send */ 184 - atomic_t num_waiters; /* blocked waiting to get in sendrecv */ 185 - #endif 186 - enum statusEnum tcpStatus; /* what we think the status is */ 187 175 struct mutex srv_mutex; 188 176 struct task_struct *tsk; 189 177 char server_GUID[16]; 190 178 char secMode; 179 + bool session_estab; /* mark when very first sess is established */ 180 + u16 dialect; /* dialect index that server chose */ 191 181 enum securityEnum secType; 192 182 unsigned int maxReq; /* Clients should submit no more */ 193 183 /* than maxReq distinct unanswered SMBs to the server when using */ ··· 191 199 unsigned int max_vcs; /* maximum number of smb sessions, at least 192 200 those that can be specified uniquely with 193 201 vcnumbers */ 194 - char sessid[4]; /* unique token id for this session */ 195 - /* (returned on Negotiate */ 196 202 int capabilities; /* allow selective disabling of caps by smb sess */ 197 203 int timeAdj; /* Adjust for difference in server time zone in sec */ 198 204 __u16 CurrentMid; /* multiplex id - rotating counter */ ··· 200 210 __u32 sequence_number; /* for signing, protected by srv_mutex */ 201 211 struct session_key session_key; 202 212 unsigned long lstrp; /* when we got last response from this server */ 203 - u16 dialect; /* dialect index that server chose */ 204 213 struct cifs_secmech secmech; /* crypto sec mech functs, descriptors */ 205 214 /* extended security flavors that server supports */ 215 + bool sec_ntlmssp; /* supports NTLMSSP */ 216 + bool sec_kerberosu2u; /* supports U2U Kerberos */ 206 217 bool sec_kerberos; /* supports plain Kerberos */ 207 218 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 219 struct delayed_work echo; /* echo ping workqueue job */ 212 220 #ifdef CONFIG_CIFS_FSCACHE 213 221 struct fscache_cookie *fscache; /* client index cache cookie */ 222 + #endif 223 + #ifdef CONFIG_CIFS_STATS2 224 + atomic_t inSend; /* requests trying to send */ 225 + atomic_t num_waiters; /* blocked waiting to get in sendrecv */ 214 226 #endif 215 227 }; 216 228 ··· 439 447 /* BB add in lists for dirty pages i.e. write caching info for oplock */ 440 448 struct list_head openFileList; 441 449 __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 */ 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 */ 447 455 u64 server_eof; /* current file size on server */ 448 456 u64 uniqueid; /* server inode number */ 449 457 u64 createtime; /* creation time on server */
+43 -4
fs/cifs/cifspdu.h
··· 23 23 #define _CIFSPDU_H 24 24 25 25 #include <net/sock.h> 26 + #include <asm/unaligned.h> 26 27 #include "smbfsctl.h" 27 28 28 29 #ifdef CONFIG_CIFS_WEAK_PW_HASH ··· 427 426 __u16 Mid; 428 427 __u8 WordCount; 429 428 } __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))) 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 + 433 434 /* 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) 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 __u16 439 + 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 __u16 448 + 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 void 457 + 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 void 466 + 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 + } 435 472 436 473 /* 437 474 * Computer Name Length (since Netbios name was length 16 with last byte 0x20)
+25 -29
fs/cifs/cifssmb.c
··· 331 331 332 332 static int validate_t2(struct smb_t2_rsp *pSMB) 333 333 { 334 - int rc = -EINVAL; 335 - int total_size; 336 - char *pBCC; 334 + unsigned int total_size; 337 335 338 - /* check for plausible wct, bcc and t2 data and parm sizes */ 336 + /* check for plausible wct */ 337 + if (pSMB->hdr.WordCount < 10) 338 + goto vt2_err; 339 + 339 340 /* 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 - } 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: 361 358 cifs_dump_mem("Invalid transact2 SMB: ", (char *)pSMB, 362 359 sizeof(struct smb_t2_rsp) + 16); 363 - return rc; 360 + return -EINVAL; 364 361 } 362 + 365 363 int 366 364 CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) 367 365 { ··· 450 452 server->maxBuf = min((__u32)le16_to_cpu(rsp->MaxBufSize), 451 453 (__u32)CIFSMaxBufSize + MAX_CIFS_HDR_SIZE); 452 454 server->max_vcs = le16_to_cpu(rsp->MaxNumberVcs); 453 - GETU32(server->sessid) = le32_to_cpu(rsp->SessionKey); 454 455 /* even though we do not use raw we might as well set this 455 456 accurately, in case we ever find a need for it */ 456 457 if ((le16_to_cpu(rsp->RawMode) & RAW_ENABLE) == RAW_ENABLE) { ··· 563 566 (__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE); 564 567 server->max_rw = le32_to_cpu(pSMBr->MaxRawSize); 565 568 cFYI(DBG2, "Max buf = %d", ses->server->maxBuf); 566 - GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey); 567 569 server->capabilities = le32_to_cpu(pSMBr->Capabilities); 568 570 server->timeAdj = (int)(__s16)le16_to_cpu(pSMBr->ServerTimeZone); 569 571 server->timeAdj *= 60; ··· 5607 5611 } 5608 5612 5609 5613 /* make sure list_len doesn't go past end of SMB */ 5610 - end_of_smb = (char *)pByteArea(&pSMBr->hdr) + BCC(&pSMBr->hdr); 5614 + end_of_smb = (char *)pByteArea(&pSMBr->hdr) + get_bcc(&pSMBr->hdr); 5611 5615 if ((char *)ea_response_data + list_len > end_of_smb) { 5612 5616 cFYI(1, "EA list appears to go beyond SMB"); 5613 5617 rc = -EIO;
+19 -24
fs/cifs/connect.c
··· 232 232 static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize) 233 233 { 234 234 struct smb_t2_rsp *pSMBt; 235 - int total_data_size; 236 - int data_in_this_rsp; 237 235 int remaining; 236 + __u16 total_data_size, data_in_this_rsp; 238 237 239 238 if (pSMB->Command != SMB_COM_TRANSACTION2) 240 239 return 0; ··· 247 248 248 249 pSMBt = (struct smb_t2_rsp *)pSMB; 249 250 250 - total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount); 251 - data_in_this_rsp = le16_to_cpu(pSMBt->t2_rsp.DataCount); 251 + total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount); 252 + data_in_this_rsp = get_unaligned_le16(&pSMBt->t2_rsp.DataCount); 252 253 253 254 remaining = total_data_size - data_in_this_rsp; 254 255 ··· 274 275 { 275 276 struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond; 276 277 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 278 char *data_area_of_target; 282 279 char *data_area_of_buf2; 283 - __u16 byte_count; 280 + int remaining; 281 + __u16 byte_count, total_data_size, total_in_buf, total_in_buf2; 284 282 285 - total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount); 283 + total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount); 286 284 287 - if (total_data_size != le16_to_cpu(pSMB2->t2_rsp.TotalDataCount)) { 285 + if (total_data_size != 286 + get_unaligned_le16(&pSMB2->t2_rsp.TotalDataCount)) 288 287 cFYI(1, "total data size of primary and secondary t2 differ"); 289 - } 290 288 291 - total_in_buf = le16_to_cpu(pSMBt->t2_rsp.DataCount); 289 + total_in_buf = get_unaligned_le16(&pSMBt->t2_rsp.DataCount); 292 290 293 291 remaining = total_data_size - total_in_buf; 294 292 ··· 295 299 if (remaining == 0) /* nothing to do, ignore */ 296 300 return 0; 297 301 298 - total_in_buf2 = le16_to_cpu(pSMB2->t2_rsp.DataCount); 302 + total_in_buf2 = get_unaligned_le16(&pSMB2->t2_rsp.DataCount); 299 303 if (remaining < total_in_buf2) { 300 304 cFYI(1, "transact2 2nd response contains too much data"); 301 305 } 302 306 303 307 /* find end of first SMB data area */ 304 308 data_area_of_target = (char *)&pSMBt->hdr.Protocol + 305 - le16_to_cpu(pSMBt->t2_rsp.DataOffset); 309 + get_unaligned_le16(&pSMBt->t2_rsp.DataOffset); 306 310 /* validate target area */ 307 311 308 - data_area_of_buf2 = (char *) &pSMB2->hdr.Protocol + 309 - le16_to_cpu(pSMB2->t2_rsp.DataOffset); 312 + data_area_of_buf2 = (char *)&pSMB2->hdr.Protocol + 313 + get_unaligned_le16(&pSMB2->t2_rsp.DataOffset); 310 314 311 315 data_area_of_target += total_in_buf; 312 316 313 317 /* copy second buffer into end of first buffer */ 314 318 memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2); 315 319 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)); 320 + put_unaligned_le16(total_in_buf, &pSMBt->t2_rsp.DataCount); 321 + byte_count = get_bcc_le(pTargetSMB); 318 322 byte_count += total_in_buf2; 319 - BCC_LE(pTargetSMB) = cpu_to_le16(byte_count); 323 + put_bcc_le(byte_count, pTargetSMB); 320 324 321 325 byte_count = pTargetSMB->smb_buf_length; 322 326 byte_count += total_in_buf2; ··· 330 334 return 0; /* we are done */ 331 335 } else /* more responses to go */ 332 336 return 1; 333 - 334 337 } 335 338 336 339 static void ··· 2932 2937 TCONX_RSP *pSMBr; 2933 2938 unsigned char *bcc_ptr; 2934 2939 int rc = 0; 2935 - int length, bytes_left; 2936 - __u16 count; 2940 + int length; 2941 + __u16 bytes_left, count; 2937 2942 2938 2943 if (ses == NULL) 2939 2944 return -EIO; ··· 3027 3032 tcon->need_reconnect = false; 3028 3033 tcon->tid = smb_buffer_response->Tid; 3029 3034 bcc_ptr = pByteArea(smb_buffer_response); 3030 - bytes_left = BCC(smb_buffer_response); 3035 + bytes_left = get_bcc(smb_buffer_response); 3031 3036 length = strnlen(bcc_ptr, bytes_left - 2); 3032 3037 if (smb_buffer->Flags2 & SMBFLG2_UNICODE) 3033 3038 is_unicode = true;
+130 -45
fs/cifs/file.c
··· 287 287 struct inode *inode = cifs_file->dentry->d_inode; 288 288 struct cifsTconInfo *tcon = tlink_tcon(cifs_file->tlink); 289 289 struct cifsInodeInfo *cifsi = CIFS_I(inode); 290 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 290 291 struct cifsLockInfo *li, *tmp; 291 292 292 293 spin_lock(&cifs_file_list_lock); ··· 303 302 if (list_empty(&cifsi->openFileList)) { 304 303 cFYI(1, "closing last open instance for inode %p", 305 304 cifs_file->dentry->d_inode); 305 + 306 + /* in strict cache mode we need invalidate mapping on the last 307 + close because it may cause a error when we open this file 308 + 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 + 306 312 cifs_set_oplock_level(cifsi, 0); 307 313 } 308 314 spin_unlock(&cifs_file_list_lock); ··· 1528 1520 return rc; 1529 1521 } 1530 1522 1531 - int cifs_fsync(struct file *file, int datasync) 1523 + int cifs_strict_fsync(struct file *file, int datasync) 1532 1524 { 1533 1525 int xid; 1534 1526 int rc = 0; 1535 1527 struct cifsTconInfo *tcon; 1536 1528 struct cifsFileInfo *smbfile = file->private_data; 1537 1529 struct inode *inode = file->f_path.dentry->d_inode; 1530 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 1538 1531 1539 1532 xid = GetXid(); 1540 1533 1541 1534 cFYI(1, "Sync file - name: %s datasync: 0x%x", 1542 1535 file->f_path.dentry->d_name.name, datasync); 1543 1536 1544 - rc = filemap_write_and_wait(inode->i_mapping); 1545 - if (rc == 0) { 1546 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 1537 + if (!CIFS_I(inode)->clientCanCacheRead) 1538 + cifs_invalidate_mapping(inode); 1547 1539 1548 - tcon = tlink_tcon(smbfile->tlink); 1549 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) 1550 - rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); 1551 - } 1540 + 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); 1552 1564 1553 1565 FreeXid(xid); 1554 1566 return rc; ··· 1619 1591 return rc; 1620 1592 } 1621 1593 1622 - ssize_t cifs_user_read(struct file *file, char __user *read_data, 1623 - size_t read_size, loff_t *poffset) 1594 + static ssize_t 1595 + cifs_iovec_read(struct file *file, const struct iovec *iov, 1596 + unsigned long nr_segs, loff_t *poffset) 1624 1597 { 1625 - int rc = -EACCES; 1626 - unsigned int bytes_read = 0; 1627 - unsigned int total_read = 0; 1628 - unsigned int current_read_size; 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; 1629 1603 struct cifs_sb_info *cifs_sb; 1630 1604 struct cifsTconInfo *pTcon; 1631 - int xid; 1632 1605 struct cifsFileInfo *open_file; 1633 - char *smb_read_data; 1634 - char __user *current_offset; 1635 1606 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; 1636 1615 1637 1616 xid = GetXid(); 1638 1617 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1639 1618 1640 - if (file->private_data == NULL) { 1641 - rc = -EBADF; 1642 - FreeXid(xid); 1643 - return rc; 1644 - } 1645 1619 open_file = file->private_data; 1646 1620 pTcon = tlink_tcon(open_file->tlink); 1647 1621 1648 1622 if ((file->f_flags & O_ACCMODE) == O_WRONLY) 1649 1623 cFYI(1, "attempting read on write only file instance"); 1650 1624 1651 - for (total_read = 0, current_offset = read_data; 1652 - read_size > total_read; 1653 - total_read += bytes_read, current_offset += bytes_read) { 1654 - current_read_size = min_t(const int, read_size - total_read, 1655 - cifs_sb->rsize); 1625 + 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); 1656 1627 rc = -EAGAIN; 1657 - smb_read_data = NULL; 1628 + read_data = NULL; 1629 + 1658 1630 while (rc == -EAGAIN) { 1659 1631 int buf_type = CIFS_NO_BUFFER; 1660 1632 if (open_file->invalidHandle) { ··· 1662 1634 if (rc != 0) 1663 1635 break; 1664 1636 } 1665 - rc = CIFSSMBRead(xid, pTcon, 1666 - open_file->netfid, 1667 - current_read_size, *poffset, 1668 - &bytes_read, &smb_read_data, 1669 - &buf_type); 1670 - pSMBr = (struct smb_com_read_rsp *)smb_read_data; 1671 - if (smb_read_data) { 1672 - if (copy_to_user(current_offset, 1673 - smb_read_data + 1674 - 4 /* RFC1001 length field */ + 1675 - le16_to_cpu(pSMBr->DataOffset), 1676 - bytes_read)) 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)) 1677 1646 rc = -EFAULT; 1678 - 1679 1647 if (buf_type == CIFS_SMALL_BUFFER) 1680 - cifs_small_buf_release(smb_read_data); 1648 + cifs_small_buf_release(read_data); 1681 1649 else if (buf_type == CIFS_LARGE_BUFFER) 1682 - cifs_buf_release(smb_read_data); 1683 - smb_read_data = NULL; 1650 + cifs_buf_release(read_data); 1651 + read_data = NULL; 1652 + iov_offset += bytes_read; 1684 1653 } 1685 1654 } 1655 + 1686 1656 if (rc || (bytes_read == 0)) { 1687 1657 if (total_read) { 1688 1658 break; ··· 1693 1667 *poffset += bytes_read; 1694 1668 } 1695 1669 } 1670 + 1696 1671 FreeXid(xid); 1697 1672 return total_read; 1698 1673 } 1699 1674 1675 + 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 time 1709 + * if we don't have level II oplock because the server can delay mtime 1710 + * change - so we can't make a decision about inode invalidating. 1711 + * And we can also fail with pagereading if there are mandatory locks 1712 + * on pages affected by this read but not on the region from pos to 1713 + * pos+len-1. 1714 + */ 1715 + 1716 + return cifs_user_readv(iocb, iov, nr_segs, pos); 1717 + } 1700 1718 1701 1719 static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, 1702 - loff_t *poffset) 1720 + loff_t *poffset) 1703 1721 { 1704 1722 int rc = -EACCES; 1705 1723 unsigned int bytes_read = 0; ··· 1809 1739 } 1810 1740 FreeXid(xid); 1811 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; 1812 1757 } 1813 1758 1814 1759 int cifs_file_mmap(struct file *file, struct vm_area_struct *vma)
+6 -2
fs/cifs/inode.c
··· 44 44 inode->i_fop = &cifs_file_direct_nobrl_ops; 45 45 else 46 46 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 + else 51 + inode->i_fop = &cifs_file_strict_ops; 47 52 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) 48 53 inode->i_fop = &cifs_file_nobrl_ops; 49 54 else { /* not direct, send byte range locks */ 50 55 inode->i_fop = &cifs_file_ops; 51 56 } 52 - 53 57 54 58 /* check if server can support readpages */ 55 59 if (cifs_sb_master_tcon(cifs_sb)->ses->server->maxBuf < ··· 1683 1679 /* 1684 1680 * Zap the cache. Called when invalid_mapping flag is set. 1685 1681 */ 1686 - static void 1682 + void 1687 1683 cifs_invalidate_mapping(struct inode *inode) 1688 1684 { 1689 1685 int rc;
-71
fs/cifs/misc.c
··· 637 637 return; 638 638 } 639 639 640 - /* Convert 16 bit Unicode pathname to wire format from string in current code 641 - page. Conversion may involve remapping up the seven characters that are 642 - only legal in POSIX-like OS (if they are present in the string). Path 643 - names are little endian 16 bit Unicode on the wire */ 644 - int 645 - 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 until 681 - all the calls to build_path_from_dentry 682 - 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, which 690 - at least in some cases servers as wild card */ 691 - if (charlen < 1) { 692 - target[j] = cpu_to_le16(0x003f); 693 - charlen = 1; 694 - } else 695 - target[j] = cpu_to_le16(temp); 696 - len_remaining -= charlen; 697 - /* character may take more than one byte in the 698 - the source string, but will take exactly two 699 - 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 - 711 640 void 712 641 cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb) 713 642 {
+2 -2
fs/cifs/netmisc.c
··· 916 916 smbCalcSize(struct smb_hdr *ptr) 917 917 { 918 918 return (sizeof(struct smb_hdr) + (2 * ptr->WordCount) + 919 - 2 /* size of the bcc field */ + BCC(ptr)); 919 + 2 /* size of the bcc field */ + get_bcc(ptr)); 920 920 } 921 921 922 922 unsigned int 923 923 smbCalcSize_LE(struct smb_hdr *ptr) 924 924 { 925 925 return (sizeof(struct smb_hdr) + (2 * ptr->WordCount) + 926 - 2 /* size of the bcc field */ + le16_to_cpu(BCC_LE(ptr))); 926 + 2 /* size of the bcc field */ + get_bcc_le(ptr)); 927 927 } 928 928 929 929 /* The following are taken from fs/ntfs/util.c */
+6 -7
fs/cifs/sess.c
··· 277 277 } 278 278 279 279 static void 280 - decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifsSesInfo *ses, 280 + decode_unicode_ssetup(char **pbcc_area, __u16 bleft, struct cifsSesInfo *ses, 281 281 const struct nls_table *nls_cp) 282 282 { 283 283 int len; ··· 323 323 return; 324 324 } 325 325 326 - static int decode_ascii_ssetup(char **pbcc_area, int bleft, 326 + static int decode_ascii_ssetup(char **pbcc_area, __u16 bleft, 327 327 struct cifsSesInfo *ses, 328 328 const struct nls_table *nls_cp) 329 329 { ··· 575 575 char *str_area; 576 576 SESSION_SETUP_ANDX *pSMB; 577 577 __u32 capabilities; 578 - int count; 578 + __u16 count; 579 579 int resp_buf_type; 580 580 struct kvec iov[3]; 581 581 enum securityEnum type; 582 - __u16 action; 583 - int bytes_remaining; 582 + __u16 action, bytes_remaining; 584 583 struct key *spnego_key = NULL; 585 584 __le32 phase = NtLmNegotiate; /* NTLMSSP, if needed, is multistage */ 586 585 u16 blob_len; ··· 875 876 count = iov[1].iov_len + iov[2].iov_len; 876 877 smb_buf->smb_buf_length += count; 877 878 878 - BCC_LE(smb_buf) = cpu_to_le16(count); 879 + put_bcc_le(count, smb_buf); 879 880 880 881 rc = SendReceive2(xid, ses, iov, 3 /* num_iovecs */, &resp_buf_type, 881 882 CIFS_LOG_ERROR); ··· 909 910 cFYI(1, "UID = %d ", ses->Suid); 910 911 /* response can have either 3 or 4 word count - Samba sends 3 */ 911 912 /* and lanman response is 3 */ 912 - bytes_remaining = BCC(smb_buf); 913 + bytes_remaining = get_bcc(smb_buf); 913 914 bcc_ptr = pByteArea(smb_buf); 914 915 915 916 if (smb_buf->WordCount == 4) {
+4 -5
fs/cifs/transport.c
··· 484 484 in_buf->smb_buf_length = sizeof(struct smb_hdr) - 4 + 2; 485 485 in_buf->Command = SMB_COM_NT_CANCEL; 486 486 in_buf->WordCount = 0; 487 - BCC_LE(in_buf) = 0; 487 + put_bcc_le(0, in_buf); 488 488 489 489 mutex_lock(&server->srv_mutex); 490 490 rc = cifs_sign_smb(in_buf, server, &mid->sequence_number); ··· 632 632 if (receive_len >= sizeof(struct smb_hdr) - 4 633 633 /* do not count RFC1001 header */ + 634 634 (2 * midQ->resp_buf->WordCount) + 2 /* bcc */ ) 635 - BCC(midQ->resp_buf) = 636 - le16_to_cpu(BCC_LE(midQ->resp_buf)); 635 + put_bcc(get_bcc_le(midQ->resp_buf), midQ->resp_buf); 637 636 if ((flags & CIFS_NO_RESP) == 0) 638 637 midQ->resp_buf = NULL; /* mark it so buf will 639 638 not be freed by ··· 775 776 if (receive_len >= sizeof(struct smb_hdr) - 4 776 777 /* do not count RFC1001 header */ + 777 778 (2 * out_buf->WordCount) + 2 /* bcc */ ) 778 - BCC(out_buf) = le16_to_cpu(BCC_LE(out_buf)); 779 + put_bcc(get_bcc_le(midQ->resp_buf), midQ->resp_buf); 779 780 } else { 780 781 rc = -EIO; 781 782 cERROR(1, "Bad MID state?"); ··· 976 977 if (receive_len >= sizeof(struct smb_hdr) - 4 977 978 /* do not count RFC1001 header */ + 978 979 (2 * out_buf->WordCount) + 2 /* bcc */ ) 979 - BCC(out_buf) = le16_to_cpu(BCC_LE(out_buf)); 980 + put_bcc(get_bcc_le(out_buf), out_buf); 980 981 981 982 out: 982 983 delete_mid(midQ);