Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cifs: Add a tracepoint to log EIO errors

Add a tracepoint to log EIO errors and give it the capacity to convey up to
two integers of information. This is then wrapped with three functions:

int smb_EIO(enum smb_eio_trace trace)
int smb_EIO1(enum smb_eio_trace trace, unsigned long info)
int smb_EIO2(enum smb_eio_trace trace, unsigned long info,
unsigned long info2)

depending on how many bits of info are desired to be logged with any
particular trace. The functions all return -EIO and can be used in place
of -EIO.

The trace argument is an enum value that gets translated to a string when
the trace is printed.

This makes is easier to log EIO instances when the client is under high
load than turning on a printk wrapper such as cifs_dbg(). Granted, EIO
could have its own separate EIO printing since EIO shouldn't happen.

Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
cc: linux-cifs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

David Howells and committed by
Steve French
f80ac7ed 3a7b6d0a

+610 -313
+1 -1
fs/smb/client/cached_dir.c
··· 176 176 server = cifs_pick_channel(ses); 177 177 178 178 if (!server->ops->new_lease_key) 179 - return -EIO; 179 + return smb_EIO(smb_eio_trace_no_lease_key); 180 180 181 181 utf16_path = cifs_convert_path_to_utf16(path, cifs_sb); 182 182 if (!utf16_path)
+6 -4
fs/smb/client/cifsacl.c
··· 300 300 __func__, sidtype == SIDOWNER ? 'u' : 'g', cid); 301 301 goto out_revert_creds; 302 302 } else if (sidkey->datalen < CIFS_SID_BASE_SIZE) { 303 - rc = -EIO; 303 + rc = smb_EIO1(smb_eio_trace_malformed_sid_key, sidkey->datalen); 304 304 cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%hu)\n", 305 305 __func__, sidkey->datalen); 306 306 goto invalidate_key; ··· 317 317 318 318 ksid_size = CIFS_SID_BASE_SIZE + (ksid->num_subauth * sizeof(__le32)); 319 319 if (ksid_size > sidkey->datalen) { 320 - rc = -EIO; 320 + rc = smb_EIO2(smb_eio_trace_malformed_ksid_key, 321 + ksid_size, sidkey->datalen); 321 322 cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%hu, ksid_size=%u)\n", 322 323 __func__, sidkey->datalen, ksid_size); 323 324 goto invalidate_key; ··· 353 352 if (unlikely(psid->num_subauth > SID_MAX_SUB_AUTHORITIES)) { 354 353 cifs_dbg(FYI, "%s: %u subauthorities is too many!\n", 355 354 __func__, psid->num_subauth); 356 - return -EIO; 355 + return smb_EIO2(smb_eio_trace_sid_too_many_auth, 356 + psid->num_subauth, SID_MAX_SUB_AUTHORITIES); 357 357 } 358 358 359 359 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL) || ··· 1229 1227 __u32 dacloffset; 1230 1228 1231 1229 if (pntsd == NULL) 1232 - return -EIO; 1230 + return smb_EIO(smb_eio_trace_null_pointers); 1233 1231 1234 1232 owner_sid_ptr = (struct smb_sid *)((char *)pntsd + 1235 1233 le32_to_cpu(pntsd->osidoffset));
+8 -5
fs/smb/client/cifsencrypt.c
··· 75 75 struct cifs_calc_sig_ctx *ctx) 76 76 { 77 77 struct iov_iter tmp_iter = *iter; 78 - int err = -EIO; 78 + size_t did; 79 + int err; 79 80 80 - if (iterate_and_advance_kernel(&tmp_iter, maxsize, ctx, &err, 81 - cifs_sig_step) != maxsize) 82 - return err; 81 + did = iterate_and_advance_kernel(&tmp_iter, maxsize, ctx, &err, 82 + cifs_sig_step); 83 + if (did != maxsize) 84 + return smb_EIO2(smb_eio_trace_sig_iter, did, maxsize); 83 85 return 0; 84 86 } 85 87 ··· 98 96 iov_iter_kvec(&iter, ITER_SOURCE, rqst->rq_iov, rqst->rq_nvec, size); 99 97 100 98 if (iov_iter_count(&iter) <= 4) 101 - return -EIO; 99 + return smb_EIO2(smb_eio_trace_sig_data_too_small, 100 + iov_iter_count(&iter), 4); 102 101 103 102 rc = cifs_sig_iter(&iter, iov_iter_count(&iter), ctx); 104 103 if (rc < 0)
-88
fs/smb/client/cifsglob.h
··· 2206 2206 dst->FileNameLength = src->FileNameLength; 2207 2207 } 2208 2208 2209 - static inline int cifs_get_num_sgs(const struct smb_rqst *rqst, 2210 - int num_rqst, 2211 - const u8 *sig) 2212 - { 2213 - unsigned int len, skip; 2214 - unsigned int nents = 0; 2215 - unsigned long addr; 2216 - size_t data_size; 2217 - int i, j; 2218 - 2219 - /* 2220 - * The first rqst has a transform header where the first 20 bytes are 2221 - * not part of the encrypted blob. 2222 - */ 2223 - skip = 20; 2224 - 2225 - /* Assumes the first rqst has a transform header as the first iov. 2226 - * I.e. 2227 - * rqst[0].rq_iov[0] is transform header 2228 - * rqst[0].rq_iov[1+] data to be encrypted/decrypted 2229 - * rqst[1+].rq_iov[0+] data to be encrypted/decrypted 2230 - */ 2231 - for (i = 0; i < num_rqst; i++) { 2232 - data_size = iov_iter_count(&rqst[i].rq_iter); 2233 - 2234 - /* We really don't want a mixture of pinned and unpinned pages 2235 - * in the sglist. It's hard to keep track of which is what. 2236 - * Instead, we convert to a BVEC-type iterator higher up. 2237 - */ 2238 - if (data_size && 2239 - WARN_ON_ONCE(user_backed_iter(&rqst[i].rq_iter))) 2240 - return -EIO; 2241 - 2242 - /* We also don't want to have any extra refs or pins to clean 2243 - * up in the sglist. 2244 - */ 2245 - if (data_size && 2246 - WARN_ON_ONCE(iov_iter_extract_will_pin(&rqst[i].rq_iter))) 2247 - return -EIO; 2248 - 2249 - for (j = 0; j < rqst[i].rq_nvec; j++) { 2250 - struct kvec *iov = &rqst[i].rq_iov[j]; 2251 - 2252 - addr = (unsigned long)iov->iov_base + skip; 2253 - if (is_vmalloc_or_module_addr((void *)addr)) { 2254 - len = iov->iov_len - skip; 2255 - nents += DIV_ROUND_UP(offset_in_page(addr) + len, 2256 - PAGE_SIZE); 2257 - } else { 2258 - nents++; 2259 - } 2260 - skip = 0; 2261 - } 2262 - if (data_size) 2263 - nents += iov_iter_npages(&rqst[i].rq_iter, INT_MAX); 2264 - } 2265 - nents += DIV_ROUND_UP(offset_in_page(sig) + SMB2_SIGNATURE_SIZE, PAGE_SIZE); 2266 - return nents; 2267 - } 2268 - 2269 - /* We can not use the normal sg_set_buf() as we will sometimes pass a 2270 - * stack object as buf. 2271 - */ 2272 - static inline void cifs_sg_set_buf(struct sg_table *sgtable, 2273 - const void *buf, 2274 - unsigned int buflen) 2275 - { 2276 - unsigned long addr = (unsigned long)buf; 2277 - unsigned int off = offset_in_page(addr); 2278 - 2279 - addr &= PAGE_MASK; 2280 - if (is_vmalloc_or_module_addr((void *)addr)) { 2281 - do { 2282 - unsigned int len = min_t(unsigned int, buflen, PAGE_SIZE - off); 2283 - 2284 - sg_set_page(&sgtable->sgl[sgtable->nents++], 2285 - vmalloc_to_page((void *)addr), len, off); 2286 - 2287 - off = 0; 2288 - addr += PAGE_SIZE; 2289 - buflen -= len; 2290 - } while (buflen); 2291 - } else { 2292 - sg_set_page(&sgtable->sgl[sgtable->nents++], 2293 - virt_to_page((void *)addr), buflen, off); 2294 - } 2295 - } 2296 - 2297 2209 #define CIFS_OPARMS(_cifs_sb, _tcon, _path, _da, _cd, _co, _mode) \ 2298 2210 ((struct cifs_open_parms) { \ 2299 2211 .tcon = _tcon, \
+106
fs/smb/client/cifsproto.h
··· 786 786 memset(data, 0, sizeof(*data)); 787 787 } 788 788 789 + static inline int smb_EIO(enum smb_eio_trace trace) 790 + { 791 + trace_smb3_eio(trace, 0, 0); 792 + return -EIO; 793 + } 794 + 795 + static inline int smb_EIO1(enum smb_eio_trace trace, unsigned long info) 796 + { 797 + trace_smb3_eio(trace, info, 0); 798 + return -EIO; 799 + } 800 + 801 + static inline int smb_EIO2(enum smb_eio_trace trace, unsigned long info, unsigned long info2) 802 + { 803 + trace_smb3_eio(trace, info, info2); 804 + return -EIO; 805 + } 806 + 807 + static inline int cifs_get_num_sgs(const struct smb_rqst *rqst, 808 + int num_rqst, 809 + const u8 *sig) 810 + { 811 + unsigned int len, skip; 812 + unsigned int nents = 0; 813 + unsigned long addr; 814 + size_t data_size; 815 + int i, j; 816 + 817 + /* 818 + * The first rqst has a transform header where the first 20 bytes are 819 + * not part of the encrypted blob. 820 + */ 821 + skip = 20; 822 + 823 + /* Assumes the first rqst has a transform header as the first iov. 824 + * I.e. 825 + * rqst[0].rq_iov[0] is transform header 826 + * rqst[0].rq_iov[1+] data to be encrypted/decrypted 827 + * rqst[1+].rq_iov[0+] data to be encrypted/decrypted 828 + */ 829 + for (i = 0; i < num_rqst; i++) { 830 + data_size = iov_iter_count(&rqst[i].rq_iter); 831 + 832 + /* We really don't want a mixture of pinned and unpinned pages 833 + * in the sglist. It's hard to keep track of which is what. 834 + * Instead, we convert to a BVEC-type iterator higher up. 835 + */ 836 + if (data_size && 837 + WARN_ON_ONCE(user_backed_iter(&rqst[i].rq_iter))) 838 + return smb_EIO(smb_eio_trace_user_iter); 839 + 840 + /* We also don't want to have any extra refs or pins to clean 841 + * up in the sglist. 842 + */ 843 + if (data_size && 844 + WARN_ON_ONCE(iov_iter_extract_will_pin(&rqst[i].rq_iter))) 845 + return smb_EIO(smb_eio_trace_extract_will_pin); 846 + 847 + for (j = 0; j < rqst[i].rq_nvec; j++) { 848 + struct kvec *iov = &rqst[i].rq_iov[j]; 849 + 850 + addr = (unsigned long)iov->iov_base + skip; 851 + if (is_vmalloc_or_module_addr((void *)addr)) { 852 + len = iov->iov_len - skip; 853 + nents += DIV_ROUND_UP(offset_in_page(addr) + len, 854 + PAGE_SIZE); 855 + } else { 856 + nents++; 857 + } 858 + skip = 0; 859 + } 860 + if (data_size) 861 + nents += iov_iter_npages(&rqst[i].rq_iter, INT_MAX); 862 + } 863 + nents += DIV_ROUND_UP(offset_in_page(sig) + SMB2_SIGNATURE_SIZE, PAGE_SIZE); 864 + return nents; 865 + } 866 + 867 + /* We can not use the normal sg_set_buf() as we will sometimes pass a 868 + * stack object as buf. 869 + */ 870 + static inline void cifs_sg_set_buf(struct sg_table *sgtable, 871 + const void *buf, 872 + unsigned int buflen) 873 + { 874 + unsigned long addr = (unsigned long)buf; 875 + unsigned int off = offset_in_page(addr); 876 + 877 + addr &= PAGE_MASK; 878 + if (is_vmalloc_or_module_addr((void *)addr)) { 879 + do { 880 + unsigned int len = min_t(unsigned int, buflen, PAGE_SIZE - off); 881 + 882 + sg_set_page(&sgtable->sgl[sgtable->nents++], 883 + vmalloc_to_page((void *)addr), len, off); 884 + 885 + off = 0; 886 + addr += PAGE_SIZE; 887 + buflen -= len; 888 + } while (buflen); 889 + } else { 890 + sg_set_page(&sgtable->sgl[sgtable->nents++], 891 + virt_to_page((void *)addr), buflen, off); 892 + } 893 + } 894 + 789 895 #endif /* _CIFSPROTO_H */
+94 -53
fs/smb/client/cifssmb.c
··· 373 373 374 374 count = get_bcc(&pSMBr->hdr); 375 375 if (count < SMB1_CLIENT_GUID_SIZE) 376 - return -EIO; 376 + return smb_EIO2(smb_eio_trace_neg_sec_blob_too_small, 377 + count, SMB1_CLIENT_GUID_SIZE); 377 378 378 379 spin_lock(&cifs_tcp_ses_lock); 379 380 if (server->srv_count > 1) { ··· 433 432 434 433 if (!server) { 435 434 WARN(1, "%s: server is NULL!\n", __func__); 436 - return -EIO; 435 + return smb_EIO(smb_eio_trace_null_pointers); 437 436 } 438 437 439 438 rc = smb_init(SMB_COM_NEGOTIATE, 0, NULL /* no tcon yet */ , ··· 517 516 server->negflavor = CIFS_NEGFLAVOR_EXTENDED; 518 517 rc = decode_ext_sec_blob(ses, pSMBr); 519 518 } else if (server->sec_mode & SECMODE_PW_ENCRYPT) { 520 - rc = -EIO; /* no crypt key only if plain text pwd */ 519 + /* no crypt key only if plain text pwd */ 520 + rc = smb_EIO(smb_eio_trace_neg_no_crypt_key); 521 521 } else { 522 522 server->negflavor = CIFS_NEGFLAVOR_UNENCAP; 523 523 server->capabilities &= ~CAP_EXTENDED_SECURITY; ··· 544 542 545 543 /* BB: do we need to check this? These should never be NULL. */ 546 544 if ((tcon->ses == NULL) || (tcon->ses->server == NULL)) 547 - return -EIO; 545 + return smb_EIO(smb_eio_trace_null_pointers); 548 546 549 547 /* 550 548 * No need to return error on this operation if tid invalidated and ··· 555 553 spin_lock(&tcon->ses->chan_lock); 556 554 if ((tcon->need_reconnect) || CIFS_ALL_CHANS_NEED_RECONNECT(tcon->ses)) { 557 555 spin_unlock(&tcon->ses->chan_lock); 558 - return -EIO; 556 + return smb_EIO(smb_eio_trace_tdis_in_reconnect); 559 557 } 560 558 spin_unlock(&tcon->ses->chan_lock); 561 559 ··· 652 650 * should probably be a BUG() 653 651 */ 654 652 if (!ses || !ses->server) 655 - return -EIO; 653 + return smb_EIO(smb_eio_trace_null_pointers); 656 654 657 655 mutex_lock(&ses->session_mutex); 658 656 spin_lock(&ses->chan_lock); ··· 982 980 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 983 981 984 982 if (rc || get_bcc(&pSMBr->hdr) < sizeof(OPEN_PSX_RSP)) { 985 - rc = -EIO; /* bad smb */ 983 + rc = smb_EIO2(smb_eio_trace_create_rsp_too_small, 984 + get_bcc(&pSMBr->hdr), sizeof(OPEN_PSX_RSP)); 986 985 goto psx_create_err; 987 986 } 988 987 ··· 1374 1371 break; 1375 1372 case MID_RESPONSE_MALFORMED: 1376 1373 trace_netfs_sreq(&rdata->subreq, netfs_sreq_trace_io_malformed); 1377 - rdata->result = -EIO; 1374 + rdata->result = smb_EIO(smb_eio_trace_read_rsp_malformed); 1378 1375 break; 1379 1376 default: 1380 1377 trace_netfs_sreq(&rdata->subreq, netfs_sreq_trace_io_unknown); 1381 - rdata->result = -EIO; 1378 + rdata->result = smb_EIO1(smb_eio_trace_read_mid_state_unknown, 1379 + mid->mid_state); 1382 1380 break; 1383 1381 } 1384 1382 ··· 1450 1446 wct = 10; /* old style read */ 1451 1447 if ((rdata->subreq.start >> 32) > 0) { 1452 1448 /* can not handle this big offset for old */ 1453 - return -EIO; 1449 + return smb_EIO(smb_eio_trace_read_too_far); 1454 1450 } 1455 1451 } 1456 1452 ··· 1525 1521 wct = 10; /* old style read */ 1526 1522 if ((offset >> 32) > 0) { 1527 1523 /* can not handle this big offset for old */ 1528 - return -EIO; 1524 + return smb_EIO(smb_eio_trace_read_too_far); 1529 1525 } 1530 1526 } 1531 1527 ··· 1580 1576 || (data_length > count)) { 1581 1577 cifs_dbg(FYI, "bad length %d for count %d\n", 1582 1578 data_length, count); 1583 - rc = -EIO; 1579 + rc = smb_EIO2(smb_eio_trace_read_overlarge, 1580 + data_length, count); 1584 1581 *nbytes = 0; 1585 1582 } else { 1586 1583 pReadData = (char *) (&pSMBr->hdr.Protocol) + ··· 1640 1635 wct = 12; 1641 1636 if ((offset >> 32) > 0) { 1642 1637 /* can not handle big offset for old srv */ 1643 - return -EIO; 1638 + return smb_EIO(smb_eio_trace_write_too_far); 1644 1639 } 1645 1640 } 1646 1641 ··· 1791 1786 break; 1792 1787 case MID_RESPONSE_MALFORMED: 1793 1788 trace_netfs_sreq(&wdata->subreq, netfs_sreq_trace_io_malformed); 1794 - result = -EIO; 1789 + result = smb_EIO(smb_eio_trace_write_rsp_malformed); 1795 1790 break; 1796 1791 default: 1797 1792 trace_netfs_sreq(&wdata->subreq, netfs_sreq_trace_io_unknown); 1798 - result = -EIO; 1793 + result = smb_EIO1(smb_eio_trace_write_mid_state_unknown, 1794 + mid->mid_state); 1799 1795 break; 1800 1796 } 1801 1797 ··· 1831 1825 wct = 12; 1832 1826 if (wdata->subreq.start >> 32 > 0) { 1833 1827 /* can not handle big offset for old srv */ 1834 - rc = -EIO; 1828 + rc = smb_EIO(smb_eio_trace_write_too_far); 1835 1829 goto out; 1836 1830 } 1837 1831 } ··· 1923 1917 wct = 12; 1924 1918 if ((offset >> 32) > 0) { 1925 1919 /* can not handle big offset for old srv */ 1926 - return -EIO; 1920 + return smb_EIO(smb_eio_trace_write_too_far); 1927 1921 } 1928 1922 } 1929 1923 rc = small_smb_init(SMB_COM_WRITE_ANDX, wct, tcon, (void **) &pSMB); ··· 1979 1973 cifs_dbg(FYI, "Send error Write2 = %d\n", rc); 1980 1974 } else if (resp_buf_type == 0) { 1981 1975 /* presumably this can not happen, but best to be safe */ 1982 - rc = -EIO; 1976 + rc = smb_EIO1(smb_eio_trace_write_bad_buf_type, resp_buf_type); 1983 1977 } else { 1984 1978 WRITE_RSP *pSMBr = (WRITE_RSP *)rsp_iov.iov_base; 1985 1979 *nbytes = le16_to_cpu(pSMBr->CountHigh); ··· 2215 2209 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 2216 2210 2217 2211 if (rc || get_bcc(&pSMBr->hdr) < sizeof(*parm_data)) { 2218 - rc = -EIO; /* bad smb */ 2212 + rc = smb_EIO2(smb_eio_trace_lock_bcc_too_small, 2213 + get_bcc(&pSMBr->hdr), sizeof(*parm_data)); 2219 2214 goto plk_err_exit; 2220 2215 } 2221 2216 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 2222 2217 data_count = le16_to_cpu(pSMBr->t2.DataCount); 2223 2218 if (data_count < sizeof(struct cifs_posix_lock)) { 2224 - rc = -EIO; 2219 + rc = smb_EIO2(smb_eio_trace_lock_data_too_small, 2220 + data_count, sizeof(struct cifs_posix_lock)); 2225 2221 goto plk_err_exit; 2226 2222 } 2227 2223 parm_data = (struct cifs_posix_lock *) ··· 2782 2774 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 2783 2775 /* BB also check enough total bytes returned */ 2784 2776 if (rc || get_bcc(&pSMBr->hdr) < 2) 2785 - rc = -EIO; 2777 + rc = smb_EIO2(smb_eio_trace_qsym_bcc_too_small, 2778 + get_bcc(&pSMBr->hdr), 2); 2786 2779 else { 2787 2780 bool is_unicode; 2788 2781 u16 count = le16_to_cpu(pSMBr->t2.DataCount); ··· 2885 2876 data_count = le32_to_cpu(io_rsp->DataCount); 2886 2877 if (get_bcc(&io_rsp->hdr) < 2 || data_offset > 512 || 2887 2878 !data_count || data_count > 2048) { 2888 - rc = -EIO; 2879 + rc = smb_EIO2(smb_eio_trace_qreparse_sizes_wrong, 2880 + get_bcc(&io_rsp->hdr), data_count); 2889 2881 goto error; 2890 2882 } 2891 2883 2892 2884 /* SetupCount must be 1, otherwise offset to ByteCount is incorrect. */ 2893 2885 if (io_rsp->SetupCount != 1) { 2894 - rc = -EIO; 2886 + rc = smb_EIO2(smb_eio_trace_qreparse_setup_count, 2887 + io_rsp->SetupCount, 1); 2895 2888 goto error; 2896 2889 } 2897 2890 ··· 2903 2892 * Check that we have full FSCTL_GET_REPARSE_POINT buffer. 2904 2893 */ 2905 2894 if (data_count != le16_to_cpu(io_rsp->ReturnedDataLen)) { 2906 - rc = -EIO; 2895 + rc = smb_EIO2(smb_eio_trace_qreparse_ret_datalen, 2896 + data_count, le16_to_cpu(io_rsp->ReturnedDataLen)); 2907 2897 goto error; 2908 2898 } 2909 2899 2910 2900 end = 2 + get_bcc(&io_rsp->hdr) + (__u8 *)&io_rsp->ByteCount; 2911 2901 start = (__u8 *)&io_rsp->hdr.Protocol + data_offset; 2912 2902 if (start >= end) { 2913 - rc = -EIO; 2903 + rc = smb_EIO2(smb_eio_trace_qreparse_data_area, 2904 + (unsigned long)start - (unsigned long)io_rsp, 2905 + (unsigned long)end - (unsigned long)io_rsp); 2914 2906 goto error; 2915 2907 } 2916 2908 ··· 2922 2908 len = sizeof(*buf); 2923 2909 if (data_count < len || 2924 2910 data_count < le16_to_cpu(buf->ReparseDataLength) + len) { 2925 - rc = -EIO; 2911 + rc = smb_EIO2(smb_eio_trace_qreparse_rep_datalen, 2912 + data_count, le16_to_cpu(buf->ReparseDataLength) + len); 2926 2913 goto error; 2927 2914 } 2928 2915 ··· 3367 3352 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 3368 3353 /* BB also check enough total bytes returned */ 3369 3354 if (rc || get_bcc(&pSMBr->hdr) < 2) 3370 - rc = -EIO; /* bad smb */ 3355 + rc = smb_EIO2(smb_eio_trace_getacl_bcc_too_small, 3356 + get_bcc(&pSMBr->hdr), 2); 3371 3357 else { 3372 3358 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 3373 3359 __u16 count = le16_to_cpu(pSMBr->t2.DataCount); ··· 3541 3525 if (rc || get_bcc(&pSMBr->hdr) < 2) 3542 3526 /* If rc should we check for EOPNOSUPP and 3543 3527 disable the srvino flag? or in caller? */ 3544 - rc = -EIO; /* bad smb */ 3528 + rc = smb_EIO2(smb_eio_trace_getextattr_bcc_too_small, 3529 + get_bcc(&pSMBr->hdr), 2); 3545 3530 else { 3546 3531 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 3547 3532 __u16 count = le16_to_cpu(pSMBr->t2.DataCount); ··· 3550 3533 3551 3534 if (count != 16) { 3552 3535 cifs_dbg(FYI, "Invalid size ret in GetExtAttr\n"); 3553 - rc = -EIO; 3536 + rc = smb_EIO2(smb_eio_trace_getextattr_inv_size, 3537 + count, 16); 3554 3538 goto GetExtAttrOut; 3555 3539 } 3556 3540 pfinfo = (struct file_chattr_info *) ··· 3718 3700 pSMBr, parm, *acl_inf); 3719 3701 3720 3702 if (le32_to_cpu(pSMBr->ParameterCount) != 4) { 3721 - rc = -EIO; /* bad smb */ 3703 + rc = smb_EIO2(smb_eio_trace_getcifsacl_param_count, 3704 + le32_to_cpu(pSMBr->ParameterCount), 4); 3722 3705 *pbuflen = 0; 3723 3706 goto qsec_out; 3724 3707 } ··· 3877 3858 data->EndOfFile = data->AllocationSize; 3878 3859 data->Attributes = 3879 3860 cpu_to_le32(le16_to_cpu(pSMBr->attr)); 3880 - } else 3881 - rc = -EIO; /* bad buffer passed in */ 3861 + } else { 3862 + /* bad buffer passed in */ 3863 + rc = smb_EIO(smb_eio_trace_null_pointers); 3864 + } 3882 3865 3883 3866 cifs_buf_release(pSMB); 3884 3867 ··· 3942 3921 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 3943 3922 3944 3923 if (rc) /* BB add auto retry on EOPNOTSUPP? */ 3945 - rc = -EIO; 3924 + rc = smb_EIO2(smb_eio_trace_qfileinfo_invalid, 3925 + get_bcc(&pSMBr->hdr), 40); 3946 3926 else if (get_bcc(&pSMBr->hdr) < 40) 3947 - rc = -EIO; /* bad smb */ 3927 + rc = smb_EIO2(smb_eio_trace_qfileinfo_bcc_too_small, 3928 + get_bcc(&pSMBr->hdr), 40); 3948 3929 else if (pFindData) { 3949 3930 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 3950 3931 memcpy((char *) pFindData, ··· 4031 4008 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 4032 4009 4033 4010 if (rc) /* BB add auto retry on EOPNOTSUPP? */ 4034 - rc = -EIO; 4011 + rc = smb_EIO2(smb_eio_trace_qpathinfo_invalid, 4012 + get_bcc(&pSMBr->hdr), 40); 4035 4013 else if (!legacy && get_bcc(&pSMBr->hdr) < 40) 4036 - rc = -EIO; /* bad smb */ 4014 + rc = smb_EIO2(smb_eio_trace_qpathinfo_bcc_too_small, 4015 + get_bcc(&pSMBr->hdr), 40); 4037 4016 else if (legacy && get_bcc(&pSMBr->hdr) < 24) 4038 - rc = -EIO; /* 24 or 26 expected but we do not read 4039 - last field */ 4017 + /* 24 or 26 expected but we do not read last field */ 4018 + rc = smb_EIO2(smb_eio_trace_qpathinfo_bcc_too_small, 4019 + get_bcc(&pSMBr->hdr), 24); 4040 4020 else if (data) { 4041 4021 int size; 4042 4022 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); ··· 4119 4093 4120 4094 if (rc || get_bcc(&pSMBr->hdr) < sizeof(FILE_UNIX_BASIC_INFO)) { 4121 4095 cifs_dbg(VFS, "Malformed FILE_UNIX_BASIC_INFO response. Unix Extensions can be disabled on mount by specifying the nosfu mount option.\n"); 4122 - rc = -EIO; /* bad smb */ 4096 + rc = smb_EIO2(smb_eio_trace_unixqfileinfo_bcc_too_small, 4097 + get_bcc(&pSMBr->hdr), sizeof(FILE_UNIX_BASIC_INFO)); 4123 4098 } else { 4124 4099 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 4125 4100 memcpy((char *) pFindData, ··· 4204 4177 4205 4178 if (rc || get_bcc(&pSMBr->hdr) < sizeof(FILE_UNIX_BASIC_INFO)) { 4206 4179 cifs_dbg(VFS, "Malformed FILE_UNIX_BASIC_INFO response. Unix Extensions can be disabled on mount by specifying the nosfu mount option.\n"); 4207 - rc = -EIO; /* bad smb */ 4180 + rc = smb_EIO2(smb_eio_trace_unixqpathinfo_bcc_too_small, 4181 + get_bcc(&pSMBr->hdr), sizeof(FILE_UNIX_BASIC_INFO)); 4208 4182 } else { 4209 4183 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 4210 4184 memcpy((char *) pFindData, ··· 4608 4580 if (rc || get_bcc(&pSMBr->hdr) < 2) 4609 4581 /* If rc should we check for EOPNOSUPP and 4610 4582 disable the srvino flag? or in caller? */ 4611 - rc = -EIO; /* bad smb */ 4583 + rc = smb_EIO2(smb_eio_trace_getsrvinonum_bcc_too_small, 4584 + get_bcc(&pSMBr->hdr), 2); 4612 4585 else { 4613 4586 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 4614 4587 __u16 count = le16_to_cpu(pSMBr->t2.DataCount); ··· 4617 4588 /* BB Do we need a cast or hash here ? */ 4618 4589 if (count < 8) { 4619 4590 cifs_dbg(FYI, "Invalid size ret in QryIntrnlInf\n"); 4620 - rc = -EIO; 4591 + rc = smb_EIO2(smb_eio_trace_getsrvinonum_size, 4592 + count, 8); 4621 4593 goto GetInodeNumOut; 4622 4594 } 4623 4595 pfinfo = (struct file_internal_info *) ··· 4727 4697 4728 4698 /* BB Also check if enough total bytes returned? */ 4729 4699 if (rc || get_bcc(&pSMBr->hdr) < 17) { 4730 - rc = -EIO; /* bad smb */ 4700 + rc = smb_EIO2(smb_eio_trace_getdfsrefer_bcc_too_small, 4701 + get_bcc(&pSMBr->hdr), 17); 4731 4702 goto GetDFSRefExit; 4732 4703 } 4733 4704 ··· 4804 4773 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 4805 4774 4806 4775 if (rc || get_bcc(&pSMBr->hdr) < 18) 4807 - rc = -EIO; /* bad smb */ 4776 + rc = smb_EIO2(smb_eio_trace_oldqfsinfo_bcc_too_small, 4777 + get_bcc(&pSMBr->hdr), 18); 4808 4778 else { 4809 4779 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 4810 4780 cifs_dbg(FYI, "qfsinf resp BCC: %d Offset %d\n", ··· 4894 4862 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 4895 4863 4896 4864 if (rc || get_bcc(&pSMBr->hdr) < 24) 4897 - rc = -EIO; /* bad smb */ 4865 + rc = smb_EIO2(smb_eio_trace_qfsinfo_bcc_too_small, 4866 + get_bcc(&pSMBr->hdr), 24); 4898 4867 else { 4899 4868 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 4900 4869 ··· 4985 4952 4986 4953 if (rc || get_bcc(&pSMBr->hdr) < 13) { 4987 4954 /* BB also check if enough bytes returned */ 4988 - rc = -EIO; /* bad smb */ 4955 + rc = smb_EIO2(smb_eio_trace_qfsattrinfo_bcc_too_small, 4956 + get_bcc(&pSMBr->hdr), 13); 4989 4957 } else { 4990 4958 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 4991 4959 response_data = ··· 5059 5025 5060 5026 if (rc || get_bcc(&pSMBr->hdr) < 5061 5027 sizeof(FILE_SYSTEM_DEVICE_INFO)) 5062 - rc = -EIO; /* bad smb */ 5028 + rc = smb_EIO2(smb_eio_trace_qfsdevinfo_bcc_too_small, 5029 + get_bcc(&pSMBr->hdr), 5030 + sizeof(FILE_SYSTEM_DEVICE_INFO)); 5063 5031 else { 5064 5032 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 5065 5033 response_data = ··· 5132 5096 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 5133 5097 5134 5098 if (rc || get_bcc(&pSMBr->hdr) < 13) { 5135 - rc = -EIO; /* bad smb */ 5099 + rc = smb_EIO2(smb_eio_trace_qfsunixinfo_bcc_too_small, 5100 + get_bcc(&pSMBr->hdr), 13); 5136 5101 } else { 5137 5102 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 5138 5103 response_data = ··· 5281 5244 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 5282 5245 5283 5246 if (rc || get_bcc(&pSMBr->hdr) < 13) { 5284 - rc = -EIO; /* bad smb */ 5247 + rc = smb_EIO2(smb_eio_trace_qfsposixinfo_bcc_too_small, 5248 + get_bcc(&pSMBr->hdr), 13); 5285 5249 } else { 5286 5250 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 5287 5251 response_data = ··· 6082 6044 6083 6045 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 6084 6046 if (rc || get_bcc(&pSMBr->hdr) < 4) { 6085 - rc = -EIO; /* bad smb */ 6047 + rc = smb_EIO2(smb_eio_trace_qalleas_bcc_too_small, 6048 + get_bcc(&pSMBr->hdr), 4); 6086 6049 goto QAllEAsOut; 6087 6050 } 6088 6051 ··· 6113 6074 end_of_smb = (char *)pByteArea(&pSMBr->hdr) + get_bcc(&pSMBr->hdr); 6114 6075 if ((char *)ea_response_data + list_len > end_of_smb) { 6115 6076 cifs_dbg(FYI, "EA list appears to go beyond SMB\n"); 6116 - rc = -EIO; 6077 + rc = smb_EIO2(smb_eio_trace_qalleas_overlong, 6078 + (unsigned long)ea_response_data + list_len - (unsigned long)pSMBr, 6079 + (unsigned long)end_of_smb - (unsigned long)pSMBr); 6117 6080 goto QAllEAsOut; 6118 6081 } 6119 6082 ··· 6132 6091 /* make sure we can read name_len and value_len */ 6133 6092 if (list_len < 0) { 6134 6093 cifs_dbg(FYI, "EA entry goes beyond length of list\n"); 6135 - rc = -EIO; 6094 + rc = smb_EIO1(smb_eio_trace_qalleas_ea_overlong, list_len); 6136 6095 goto QAllEAsOut; 6137 6096 } 6138 6097 ··· 6141 6100 list_len -= name_len + 1 + value_len; 6142 6101 if (list_len < 0) { 6143 6102 cifs_dbg(FYI, "EA entry goes beyond length of list\n"); 6144 - rc = -EIO; 6103 + rc = smb_EIO1(smb_eio_trace_qalleas_ea_overlong, list_len); 6145 6104 goto QAllEAsOut; 6146 6105 } 6147 6106
+4 -4
fs/smb/client/cifstransport.c
··· 227 227 int rc = 0; 228 228 229 229 if (WARN_ON_ONCE(in_len > 0xffffff)) 230 - return -EIO; 230 + return smb_EIO1(smb_eio_trace_tx_too_long, in_len); 231 231 if (ses == NULL) { 232 232 cifs_dbg(VFS, "Null smb session\n"); 233 - return -EIO; 233 + return smb_EIO(smb_eio_trace_null_pointers); 234 234 } 235 235 server = ses->server; 236 236 if (server == NULL) { 237 237 cifs_dbg(VFS, "Null tcp session\n"); 238 - return -EIO; 238 + return smb_EIO(smb_eio_trace_null_pointers); 239 239 } 240 240 241 241 /* Ensure that we do not send more than 50 overlapping requests ··· 245 245 if (in_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) { 246 246 cifs_server_dbg(VFS, "Invalid length, greater than maximum frame, %d\n", 247 247 in_len); 248 - return -EIO; 248 + return smb_EIO1(smb_eio_trace_tx_too_long, in_len); 249 249 } 250 250 251 251 rc = cifs_send_recv(xid, ses, ses->server,
+1 -1
fs/smb/client/compress.c
··· 310 310 iter = rq->rq_iter; 311 311 312 312 if (!copy_from_iter_full(src, slen, &iter)) { 313 - ret = -EIO; 313 + ret = smb_EIO(smb_eio_trace_compress_copy); 314 314 goto err_free; 315 315 } 316 316
+6 -5
fs/smb/client/connect.c
··· 3240 3240 if (be16_to_cpu(resp.length) != 0) { 3241 3241 cifs_dbg(VFS, "RFC 1002 positive session response but with invalid non-zero length %u\n", 3242 3242 be16_to_cpu(resp.length)); 3243 - return -EIO; 3243 + return smb_EIO(smb_eio_trace_rx_pos_sess_resp); 3244 3244 } 3245 3245 cifs_dbg(FYI, "RFC 1002 positive session response"); 3246 3246 break; ··· 3279 3279 break; 3280 3280 case RFC1002_INSUFFICIENT_RESOURCE: 3281 3281 /* remote server resource error */ 3282 + smb_EIO(smb_eio_trace_rx_insuff_res); 3282 3283 rc = -EREMOTEIO; 3283 3284 break; 3284 3285 case RFC1002_UNSPECIFIED_ERROR: 3285 3286 default: 3286 3287 /* other/unknown error */ 3287 - rc = -EIO; 3288 + rc = smb_EIO(smb_eio_trace_rx_unspec_error); 3288 3289 break; 3289 3290 } 3290 3291 } else { 3291 3292 cifs_dbg(VFS, "RFC 1002 negative session response\n"); 3292 - rc = -EIO; 3293 + rc = smb_EIO(smb_eio_trace_rx_neg_sess_resp); 3293 3294 } 3294 3295 return rc; 3295 3296 case RFC1002_RETARGET_SESSION_RESPONSE: ··· 3312 3311 return -EMULTIHOP; 3313 3312 default: 3314 3313 cifs_dbg(VFS, "RFC 1002 unknown response type 0x%x\n", resp.type); 3315 - return -EIO; 3314 + return smb_EIO1(smb_eio_trace_rx_unknown_resp, resp.type); 3316 3315 } 3317 3316 3318 3317 server->with_rfc1001 = true; ··· 4002 4001 __u16 bytes_left, count; 4003 4002 4004 4003 if (ses == NULL) 4005 - return -EIO; 4004 + return smb_EIO(smb_eio_trace_null_pointers); 4006 4005 4007 4006 smb_buffer = cifs_buf_get(); 4008 4007 if (smb_buffer == NULL)
+3 -3
fs/smb/client/dir.c
··· 471 471 struct cifs_open_info_data buf = {}; 472 472 473 473 if (unlikely(cifs_forced_shutdown(CIFS_SB(inode->i_sb)))) 474 - return -EIO; 474 + return smb_EIO(smb_eio_trace_forced_shutdown); 475 475 476 476 /* 477 477 * Posix open is only called (at lookup time) for file create now. For ··· 589 589 inode, direntry, direntry); 590 590 591 591 if (unlikely(cifs_forced_shutdown(CIFS_SB(inode->i_sb)))) { 592 - rc = -EIO; 592 + rc = smb_EIO(smb_eio_trace_forced_shutdown); 593 593 goto out_free_xid; 594 594 } 595 595 ··· 631 631 632 632 cifs_sb = CIFS_SB(inode->i_sb); 633 633 if (unlikely(cifs_forced_shutdown(cifs_sb))) 634 - return -EIO; 634 + return smb_EIO(smb_eio_trace_forced_shutdown); 635 635 636 636 tlink = cifs_sb_tlink(cifs_sb); 637 637 if (IS_ERR(tlink))
+3 -3
fs/smb/client/file.c
··· 118 118 int rc; 119 119 120 120 if (cifs_forced_shutdown(sbi)) { 121 - rc = -EIO; 121 + rc = smb_EIO(smb_eio_trace_forced_shutdown); 122 122 goto fail; 123 123 } 124 124 ··· 286 286 req->pid = req->cfile->pid; 287 287 } else if (rreq->origin != NETFS_WRITEBACK) { 288 288 WARN_ON_ONCE(1); 289 - return -EIO; 289 + return smb_EIO1(smb_eio_trace_not_netfs_writeback, rreq->origin); 290 290 } 291 291 292 292 return 0; ··· 1036 1036 cifs_sb = CIFS_SB(inode->i_sb); 1037 1037 if (unlikely(cifs_forced_shutdown(cifs_sb))) { 1038 1038 free_xid(xid); 1039 - return -EIO; 1039 + return smb_EIO(smb_eio_trace_forced_shutdown); 1040 1040 } 1041 1041 1042 1042 tlink = cifs_sb_tlink(cifs_sb);
+7 -7
fs/smb/client/inode.c
··· 1952 1952 cifs_dbg(FYI, "cifs_unlink, dir=0x%p, dentry=0x%p\n", dir, dentry); 1953 1953 1954 1954 if (unlikely(cifs_forced_shutdown(cifs_sb))) 1955 - return -EIO; 1955 + return smb_EIO(smb_eio_trace_forced_shutdown); 1956 1956 1957 1957 /* Unhash dentry in advance to prevent any concurrent opens */ 1958 1958 spin_lock(&dentry->d_lock); ··· 2268 2268 2269 2269 cifs_sb = CIFS_SB(inode->i_sb); 2270 2270 if (unlikely(cifs_forced_shutdown(cifs_sb))) 2271 - return ERR_PTR(-EIO); 2271 + return ERR_PTR(smb_EIO(smb_eio_trace_forced_shutdown)); 2272 2272 tlink = cifs_sb_tlink(cifs_sb); 2273 2273 if (IS_ERR(tlink)) 2274 2274 return ERR_CAST(tlink); ··· 2354 2354 2355 2355 cifs_sb = CIFS_SB(inode->i_sb); 2356 2356 if (unlikely(cifs_forced_shutdown(cifs_sb))) { 2357 - rc = -EIO; 2357 + rc = smb_EIO(smb_eio_trace_forced_shutdown); 2358 2358 goto rmdir_exit; 2359 2359 } 2360 2360 ··· 2516 2516 2517 2517 cifs_sb = CIFS_SB(source_dir->i_sb); 2518 2518 if (unlikely(cifs_forced_shutdown(cifs_sb))) 2519 - return -EIO; 2519 + return smb_EIO(smb_eio_trace_forced_shutdown); 2520 2520 2521 2521 /* 2522 2522 * Prevent any concurrent opens on the target by unhashing the dentry. ··· 2901 2901 int rc; 2902 2902 2903 2903 if (unlikely(cifs_forced_shutdown(CIFS_SB(inode->i_sb)))) 2904 - return -EIO; 2904 + return smb_EIO(smb_eio_trace_forced_shutdown); 2905 2905 2906 2906 /* 2907 2907 * We need to be sure that all dirty pages are written and the server ··· 2976 2976 int rc; 2977 2977 2978 2978 if (unlikely(cifs_forced_shutdown(cifs_sb))) 2979 - return -EIO; 2979 + return smb_EIO(smb_eio_trace_forced_shutdown); 2980 2980 2981 2981 /* 2982 2982 * We need to be sure that all dirty pages are written as they ··· 3468 3468 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */ 3469 3469 3470 3470 if (unlikely(cifs_forced_shutdown(cifs_sb))) 3471 - return -EIO; 3471 + return smb_EIO(smb_eio_trace_forced_shutdown); 3472 3472 /* 3473 3473 * Avoid setting [cm]time with O_TRUNC to prevent the server from 3474 3474 * disabling automatic timestamp updates as specified in
+6 -4
fs/smb/client/link.c
··· 160 160 goto out; 161 161 162 162 if (bytes_written != CIFS_MF_SYMLINK_FILE_SIZE) 163 - rc = -EIO; 163 + rc = smb_EIO2(smb_eio_trace_symlink_file_size, 164 + bytes_written, CIFS_MF_SYMLINK_FILE_SIZE); 164 165 out: 165 166 kfree(buf); 166 167 return rc; ··· 425 424 426 425 /* Make sure we wrote all of the symlink data */ 427 426 if ((rc == 0) && (*pbytes_written != CIFS_MF_SYMLINK_FILE_SIZE)) 428 - rc = -EIO; 427 + rc = smb_EIO2(smb_eio_trace_short_symlink_write, 428 + *pbytes_written, CIFS_MF_SYMLINK_FILE_SIZE); 429 429 430 430 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); 431 431 ··· 453 451 struct cifsInodeInfo *cifsInode; 454 452 455 453 if (unlikely(cifs_forced_shutdown(cifs_sb))) 456 - return -EIO; 454 + return smb_EIO(smb_eio_trace_forced_shutdown); 457 455 458 456 tlink = cifs_sb_tlink(cifs_sb); 459 457 if (IS_ERR(tlink)) ··· 555 553 struct inode *newinode = NULL; 556 554 557 555 if (unlikely(cifs_forced_shutdown(cifs_sb))) 558 - return -EIO; 556 + return smb_EIO(smb_eio_trace_forced_shutdown); 559 557 560 558 page = alloc_dentry_path(); 561 559 if (!page)
+12 -6
fs/smb/client/misc.c
··· 379 379 return 0; 380 380 } 381 381 cifs_dbg(VFS, "rcvd invalid byte count (bcc)\n"); 382 + return smb_EIO1(smb_eio_trace_rx_inv_bcc, tmp[sizeof(struct smb_hdr)]); 382 383 } else { 383 384 cifs_dbg(VFS, "Length less than smb header size\n"); 385 + return smb_EIO2(smb_eio_trace_rx_too_short, 386 + total_read, smb->WordCount); 384 387 } 385 - return -EIO; 386 388 } else if (total_read < sizeof(*smb) + 2 * smb->WordCount) { 387 389 cifs_dbg(VFS, "%s: can't read BCC due to invalid WordCount(%u)\n", 388 390 __func__, smb->WordCount); 389 - return -EIO; 391 + return smb_EIO2(smb_eio_trace_rx_check_rsp, 392 + total_read, 2 + sizeof(struct smb_hdr)); 390 393 } 391 394 392 395 /* otherwise, there is enough to get to the BCC */ 393 396 if (check_smb_hdr(smb)) 394 - return -EIO; 397 + return smb_EIO1(smb_eio_trace_rx_rfc1002_magic, *(u32 *)smb->Protocol); 395 398 clc_len = smbCalcSize(smb); 396 399 397 400 if (rfclen != total_read) { 398 401 cifs_dbg(VFS, "Length read does not match RFC1001 length %d/%d\n", 399 402 rfclen, total_read); 400 - return -EIO; 403 + return smb_EIO2(smb_eio_trace_rx_check_rsp, 404 + total_read, rfclen); 401 405 } 402 406 403 407 if (rfclen != clc_len) { ··· 418 414 if (rfclen < clc_len) { 419 415 cifs_dbg(VFS, "RFC1001 size %u smaller than SMB for mid=%u\n", 420 416 rfclen, mid); 421 - return -EIO; 417 + return smb_EIO2(smb_eio_trace_rx_calc_len_too_big, 418 + rfclen, clc_len); 422 419 } else if (rfclen > clc_len + 512) { 423 420 /* 424 421 * Some servers (Windows XP in particular) send more ··· 432 427 */ 433 428 cifs_dbg(VFS, "RFC1001 size %u more than 512 bytes larger than SMB for mid=%u\n", 434 429 rfclen, mid); 435 - return -EIO; 430 + return smb_EIO2(smb_eio_trace_rx_overlong, 431 + rfclen, clc_len + 512); 436 432 } 437 433 } 438 434 return 0;
+4
fs/smb/client/netmisc.c
··· 885 885 /* generic corrective action e.g. reconnect SMB session on 886 886 * ERRbaduid could be added */ 887 887 888 + if (rc == -EIO) 889 + smb_EIO2(smb_eio_trace_smb1_received_error, 890 + le32_to_cpu(smb->Status.CifsError), 891 + le16_to_cpu(smb->Flags2)); 888 892 return rc; 889 893 } 890 894
+1 -1
fs/smb/client/readdir.c
··· 775 775 776 776 if (cfile->srch_inf.ntwrk_buf_start == NULL) { 777 777 cifs_dbg(VFS, "ntwrk_buf_start is NULL during readdir\n"); 778 - return -EIO; 778 + return smb_EIO(smb_eio_trace_null_pointers); 779 779 } 780 780 781 781 end_of_smb = cfile->srch_inf.ntwrk_buf_start +
+33 -20
fs/smb/client/reparse.c
··· 732 732 len = le16_to_cpu(buf->ReparseDataLength); 733 733 if (len < sizeof(buf->InodeType)) { 734 734 cifs_dbg(VFS, "srv returned malformed nfs buffer\n"); 735 - return -EIO; 735 + return smb_EIO2(smb_eio_trace_reparse_nfs_too_short, 736 + len, sizeof(buf->InodeType)); 736 737 } 737 738 738 739 len -= sizeof(buf->InodeType); ··· 742 741 case NFS_SPECFILE_LNK: 743 742 if (len == 0 || (len % 2)) { 744 743 cifs_dbg(VFS, "srv returned malformed nfs symlink buffer\n"); 745 - return -EIO; 744 + return smb_EIO1(smb_eio_trace_reparse_nfs_symbuf, len); 746 745 } 747 746 /* 748 747 * Check that buffer does not contain UTF-16 null codepoint ··· 750 749 */ 751 750 if (UniStrnlen((wchar_t *)buf->DataBuffer, len/2) != len/2) { 752 751 cifs_dbg(VFS, "srv returned null byte in nfs symlink target location\n"); 753 - return -EIO; 752 + return smb_EIO1(smb_eio_trace_reparse_nfs_nul, len); 754 753 } 755 754 data->symlink_target = cifs_strndup_from_utf16(buf->DataBuffer, 756 755 len, true, ··· 765 764 /* DataBuffer for block and char devices contains two 32-bit numbers */ 766 765 if (len != 8) { 767 766 cifs_dbg(VFS, "srv returned malformed nfs buffer for type: 0x%llx\n", type); 768 - return -EIO; 767 + return smb_EIO1(smb_eio_trace_reparse_nfs_dev, len); 769 768 } 770 769 break; 771 770 case NFS_SPECFILE_FIFO: ··· 773 772 /* DataBuffer for fifos and sockets is empty */ 774 773 if (len != 0) { 775 774 cifs_dbg(VFS, "srv returned malformed nfs buffer for type: 0x%llx\n", type); 776 - return -EIO; 775 + return smb_EIO1(smb_eio_trace_reparse_nfs_sockfifo, len); 777 776 } 778 777 break; 779 778 default: ··· 797 796 int abs_path_len; 798 797 char *abs_path; 799 798 int levels; 800 - int rc; 799 + int rc, ulen; 801 800 int i; 802 801 803 802 /* Check that length it valid */ 804 803 if (!len || (len % 2)) { 805 804 cifs_dbg(VFS, "srv returned malformed symlink buffer\n"); 806 - rc = -EIO; 805 + rc = smb_EIO1(smb_eio_trace_reparse_native_nul, len); 807 806 goto out; 808 807 } 809 808 ··· 811 810 * Check that buffer does not contain UTF-16 null codepoint 812 811 * because Linux cannot process symlink with null byte. 813 812 */ 814 - if (UniStrnlen((wchar_t *)buf, len/2) != len/2) { 813 + ulen = UniStrnlen((wchar_t *)buf, len/2); 814 + if (ulen != len/2) { 815 815 cifs_dbg(VFS, "srv returned null byte in native symlink target location\n"); 816 - rc = -EIO; 816 + rc = smb_EIO2(smb_eio_trace_reparse_native_nul, ulen, len); 817 817 goto out; 818 818 } 819 819 ··· 998 996 len = le16_to_cpu(sym->SubstituteNameLength); 999 997 if (offs + 20 > plen || offs + len + 20 > plen) { 1000 998 cifs_dbg(VFS, "srv returned malformed symlink buffer\n"); 1001 - return -EIO; 999 + return smb_EIO2(smb_eio_trace_reparse_native_sym_len, 1000 + offs << 16 | len, plen); 1002 1001 } 1003 1002 1004 1003 return smb2_parse_native_symlink(&data->symlink_target, ··· 1022 1019 1023 1020 if (len <= data_offset) { 1024 1021 cifs_dbg(VFS, "srv returned malformed wsl symlink buffer\n"); 1025 - return -EIO; 1022 + return smb_EIO2(smb_eio_trace_reparse_wsl_symbuf, 1023 + len, data_offset); 1026 1024 } 1027 1025 1028 1026 /* MS-FSCC 2.1.2.7 defines layout of the Target field only for Version 2. */ 1029 - if (le32_to_cpu(buf->Version) != 2) { 1030 - cifs_dbg(VFS, "srv returned unsupported wsl symlink version %u\n", le32_to_cpu(buf->Version)); 1031 - return -EIO; 1027 + u32 version = le32_to_cpu(buf->Version); 1028 + 1029 + if (version != 2) { 1030 + cifs_dbg(VFS, "srv returned unsupported wsl symlink version %u\n", version); 1031 + return smb_EIO1(smb_eio_trace_reparse_wsl_ver, version); 1032 1032 } 1033 1033 1034 1034 /* Target for Version 2 is in UTF-8 but without trailing null-term byte */ ··· 1040 1034 * Check that buffer does not contain null byte 1041 1035 * because Linux cannot process symlink with null byte. 1042 1036 */ 1043 - if (strnlen(buf->Target, symname_utf8_len) != symname_utf8_len) { 1037 + size_t ulen = strnlen(buf->Target, symname_utf8_len); 1038 + 1039 + if (ulen != symname_utf8_len) { 1044 1040 cifs_dbg(VFS, "srv returned null byte in wsl symlink target location\n"); 1045 - return -EIO; 1041 + return smb_EIO2(smb_eio_trace_reparse_wsl_ver, 1042 + ulen, symname_utf8_len); 1046 1043 } 1047 1044 symname_utf16 = kzalloc(symname_utf8_len * 2, GFP_KERNEL); 1048 1045 if (!symname_utf16) ··· 1092 1083 case IO_REPARSE_TAG_AF_UNIX: 1093 1084 case IO_REPARSE_TAG_LX_FIFO: 1094 1085 case IO_REPARSE_TAG_LX_CHR: 1095 - case IO_REPARSE_TAG_LX_BLK: 1096 - if (le16_to_cpu(buf->ReparseDataLength) != 0) { 1086 + case IO_REPARSE_TAG_LX_BLK: { 1087 + u16 dlen = le16_to_cpu(buf->ReparseDataLength); 1088 + 1089 + if (dlen != 0) { 1090 + u32 rtag = le32_to_cpu(buf->ReparseTag); 1097 1091 cifs_dbg(VFS, "srv returned malformed buffer for reparse point: 0x%08x\n", 1098 - le32_to_cpu(buf->ReparseTag)); 1099 - return -EIO; 1092 + rtag); 1093 + return smb_EIO2(smb_eio_trace_reparse_data_len, dlen, rtag); 1100 1094 } 1101 1095 return 0; 1096 + } 1102 1097 default: 1103 1098 return -EOPNOTSUPP; 1104 1099 }
+4 -4
fs/smb/client/sess.c
··· 1503 1503 smb_buf = (struct smb_hdr *)sess_data->iov[0].iov_base; 1504 1504 1505 1505 if (smb_buf->WordCount != 3) { 1506 - rc = -EIO; 1506 + rc = smb_EIO1(smb_eio_trace_sess_nl2_wcc, smb_buf->WordCount); 1507 1507 cifs_dbg(VFS, "bad word count %d\n", smb_buf->WordCount); 1508 1508 goto out; 1509 1509 } ··· 1629 1629 smb_buf = (struct smb_hdr *)sess_data->iov[0].iov_base; 1630 1630 1631 1631 if (smb_buf->WordCount != 4) { 1632 - rc = -EIO; 1632 + rc = smb_EIO1(smb_eio_trace_sess_krb_wcc, smb_buf->WordCount); 1633 1633 cifs_dbg(VFS, "bad word count %d\n", smb_buf->WordCount); 1634 1634 goto out_put_spnego_key; 1635 1635 } ··· 1790 1790 cifs_dbg(FYI, "rawntlmssp session setup challenge phase\n"); 1791 1791 1792 1792 if (smb_buf->WordCount != 4) { 1793 - rc = -EIO; 1793 + rc = smb_EIO1(smb_eio_trace_sess_rawnl_neg_wcc, smb_buf->WordCount); 1794 1794 cifs_dbg(VFS, "bad word count %d\n", smb_buf->WordCount); 1795 1795 goto out_free_ntlmsspblob; 1796 1796 } ··· 1880 1880 pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base; 1881 1881 smb_buf = (struct smb_hdr *)sess_data->iov[0].iov_base; 1882 1882 if (smb_buf->WordCount != 4) { 1883 - rc = -EIO; 1883 + rc = smb_EIO1(smb_eio_trace_sess_rawnl_auth_wcc, smb_buf->WordCount); 1884 1884 cifs_dbg(VFS, "bad word count %d\n", smb_buf->WordCount); 1885 1885 goto out_free_ntlmsspblob; 1886 1886 }
+3 -3
fs/smb/client/smb2file.c
··· 76 76 return 0; 77 77 78 78 if (!*target) 79 - return -EIO; 79 + return smb_EIO(smb_eio_trace_null_pointers); 80 80 81 81 len = strlen(*target); 82 82 if (!len) 83 - return -EIO; 83 + return smb_EIO1(smb_eio_trace_sym_target_len, len); 84 84 85 85 /* 86 86 * If this is directory symlink and it does not have trailing slash then ··· 104 104 * both Windows and Linux systems. So return an error for such symlink. 105 105 */ 106 106 if (!directory && (*target)[len-1] == '/') 107 - return -EIO; 107 + return smb_EIO(smb_eio_trace_sym_slash); 108 108 109 109 return 0; 110 110 }
+8 -4
fs/smb/client/smb2inode.c
··· 31 31 struct reparse_data_buffer *buf; 32 32 struct smb2_ioctl_rsp *io = iov->iov_base; 33 33 u32 off, count, len; 34 + u16 rdlen; 34 35 35 36 count = le32_to_cpu(io->OutputCount); 36 37 off = le32_to_cpu(io->OutputOffset); 37 38 if (check_add_overflow(off, count, &len) || len > iov->iov_len) 38 - return ERR_PTR(-EIO); 39 + return ERR_PTR(smb_EIO2(smb_eio_trace_reparse_overlong, 40 + off, count)); 39 41 40 42 buf = (struct reparse_data_buffer *)((u8 *)io + off); 41 43 len = sizeof(*buf); 42 - if (count < len || count < le16_to_cpu(buf->ReparseDataLength) + len) 43 - return ERR_PTR(-EIO); 44 + rdlen = le16_to_cpu(buf->ReparseDataLength); 45 + 46 + if (count < len || count < rdlen + len) 47 + return ERR_PTR(smb_EIO2(smb_eio_trace_reparse_rdlen, count, rdlen)); 44 48 return buf; 45 49 } 46 50 ··· 1639 1635 } else { 1640 1636 cifs_tcon_dbg(FYI, "%s: failed to rename '%s' to '%s': %d\n", 1641 1637 __func__, full_path, to_name, rc); 1642 - rc = -EIO; 1638 + rc = smb_EIO1(smb_eio_trace_pend_del_fail, rc); 1643 1639 } 1644 1640 out: 1645 1641 cifs_put_tlink(tlink);
+3
fs/smb/client/smb2maperror.c
··· 9 9 */ 10 10 #include <linux/errno.h> 11 11 #include "cifsglob.h" 12 + #include "cifsproto.h" 12 13 #include "cifs_debug.h" 13 14 #include "smb2pdu.h" 14 15 #include "smb2proto.h" ··· 2478 2477 le16_to_cpu(shdr->Command), 2479 2478 le64_to_cpu(shdr->MessageId), 2480 2479 le32_to_cpu(smb2err), rc); 2480 + if (rc == -EIO) 2481 + smb_EIO1(smb_eio_trace_smb2_received_error, le32_to_cpu(smb2err)); 2481 2482 return rc; 2482 2483 }
+25 -16
fs/smb/client/smb2ops.c
··· 1046 1046 1047 1047 if (src_size < 8 + name_len + 1 + value_len) { 1048 1048 cifs_dbg(FYI, "EA entry goes beyond length of list\n"); 1049 - rc = -EIO; 1049 + rc = smb_EIO2(smb_eio_trace_ea_overrun, 1050 + src_size, 8 + name_len + 1 + value_len); 1050 1051 goto out; 1051 1052 } 1052 1053 ··· 1608 1607 } 1609 1608 1610 1609 if (!ses || !server) { 1611 - rc = -EIO; 1610 + rc = smb_EIO(smb_eio_trace_null_pointers); 1612 1611 goto free_vars; 1613 1612 } 1614 1613 ··· 1943 1942 if (unlikely(ret_data_len != sizeof(*cc_rsp))) { 1944 1943 cifs_tcon_dbg(VFS, "Copychunk invalid response: size %u/%zu\n", 1945 1944 ret_data_len, sizeof(*cc_rsp)); 1946 - rc = -EIO; 1945 + rc = smb_EIO1(smb_eio_trace_copychunk_inv_rsp, ret_data_len); 1947 1946 goto out; 1948 1947 } 1949 1948 ··· 1953 1952 1954 1953 if (rc == 0) { 1955 1954 /* Check if server claimed to write more than we asked */ 1956 - if (unlikely(!bytes_written || bytes_written > copy_bytes || 1957 - !chunks_written || chunks_written > chunks)) { 1958 - cifs_tcon_dbg(VFS, "Copychunk invalid response: bytes written %u/%u, chunks written %u/%u\n", 1959 - bytes_written, copy_bytes, chunks_written, chunks); 1960 - rc = -EIO; 1955 + if (unlikely(!bytes_written || bytes_written > copy_bytes)) { 1956 + cifs_tcon_dbg(VFS, "Copychunk invalid response: bytes written %u/%u\n", 1957 + bytes_written, copy_bytes); 1958 + rc = smb_EIO2(smb_eio_trace_copychunk_overcopy_b, 1959 + bytes_written, copy_bytes); 1960 + goto out; 1961 + } 1962 + if (unlikely(!chunks_written || chunks_written > chunks)) { 1963 + cifs_tcon_dbg(VFS, "Copychunk invalid response: chunks written %u/%u\n", 1964 + chunks_written, chunks); 1965 + rc = smb_EIO2(smb_eio_trace_copychunk_overcopy_c, 1966 + chunks_written, chunks); 1961 1967 goto out; 1962 1968 } 1963 1969 ··· 3135 3127 } 3136 3128 3137 3129 if (!rc && !dfs_rsp) 3138 - rc = -EIO; 3130 + rc = smb_EIO(smb_eio_trace_dfsref_no_rsp); 3139 3131 if (rc) { 3140 3132 if (!is_retryable_error(rc) && rc != -ENOENT && rc != -EOPNOTSUPP) 3141 3133 cifs_tcon_dbg(FYI, "%s: ioctl error: rc=%d\n", __func__, rc); ··· 4563 4555 buffer, 0, 0, size); 4564 4556 4565 4557 if (!cifs_copy_iter_to_folioq(&old->rq_iter, size, buffer)) { 4566 - rc = -EIO; 4558 + rc = smb_EIO1(smb_eio_trace_tx_copy_iter_to_buf, size); 4567 4559 goto err_free; 4568 4560 } 4569 4561 } ··· 4664 4656 n = copy_folio_to_iter(folio, skip, len, iter); 4665 4657 if (n != len) { 4666 4658 cifs_dbg(VFS, "%s: something went wrong\n", __func__); 4667 - return -EIO; 4659 + return smb_EIO2(smb_eio_trace_rx_copy_to_iter, 4660 + n, len); 4668 4661 } 4669 4662 data_size -= n; 4670 4663 skip = 0; ··· 4748 4739 /* data_offset is beyond the end of smallbuf */ 4749 4740 cifs_dbg(FYI, "%s: data offset (%u) beyond end of smallbuf\n", 4750 4741 __func__, data_offset); 4751 - rdata->result = -EIO; 4742 + rdata->result = smb_EIO1(smb_eio_trace_rx_overlong, data_offset); 4752 4743 if (is_offloaded) 4753 4744 mid->mid_state = MID_RESPONSE_MALFORMED; 4754 4745 else ··· 4767 4758 /* data offset is beyond the 1st page of response */ 4768 4759 cifs_dbg(FYI, "%s: data offset (%u) beyond 1st page of response\n", 4769 4760 __func__, data_offset); 4770 - rdata->result = -EIO; 4761 + rdata->result = smb_EIO1(smb_eio_trace_rx_overpage, data_offset); 4771 4762 if (is_offloaded) 4772 4763 mid->mid_state = MID_RESPONSE_MALFORMED; 4773 4764 else ··· 4777 4768 4778 4769 if (data_len > buffer_len - pad_len) { 4779 4770 /* data_len is corrupt -- discard frame */ 4780 - rdata->result = -EIO; 4771 + rdata->result = smb_EIO1(smb_eio_trace_rx_bad_datalen, data_len); 4781 4772 if (is_offloaded) 4782 4773 mid->mid_state = MID_RESPONSE_MALFORMED; 4783 4774 else ··· 4802 4793 WARN_ONCE(buffer, "read data can be either in buf or in buffer"); 4803 4794 copied = copy_to_iter(buf + data_offset, data_len, &rdata->subreq.io_iter); 4804 4795 if (copied == 0) 4805 - return -EIO; 4796 + return smb_EIO2(smb_eio_trace_rx_copy_to_iter, copied, data_len); 4806 4797 rdata->got_bytes = copied; 4807 4798 } else { 4808 4799 /* read response payload cannot be in both buf and pages */ 4809 4800 WARN_ONCE(1, "buf can not contain only a part of read data"); 4810 - rdata->result = -EIO; 4801 + rdata->result = smb_EIO(smb_eio_trace_rx_both_buf); 4811 4802 if (is_offloaded) 4812 4803 mid->mid_state = MID_RESPONSE_MALFORMED; 4813 4804 else
+109 -70
fs/smb/client/smb2pdu.c
··· 249 249 250 250 ses = tcon->ses; 251 251 if (!ses) 252 - return -EIO; 252 + return smb_EIO(smb_eio_trace_null_pointers); 253 253 spin_lock(&ses->ses_lock); 254 254 if (ses->ses_status == SES_EXITING) { 255 255 spin_unlock(&ses->ses_lock); 256 - return -EIO; 256 + return smb_EIO(smb_eio_trace_sess_exiting); 257 257 } 258 258 spin_unlock(&ses->ses_lock); 259 259 if (!ses->server || !server) 260 - return -EIO; 260 + return smb_EIO(smb_eio_trace_null_pointers); 261 261 262 262 spin_lock(&server->srv_lock); 263 263 if (server->tcpStatus == CifsNeedReconnect) { ··· 1061 1061 1062 1062 if (!server) { 1063 1063 WARN(1, "%s: server is NULL!\n", __func__); 1064 - return -EIO; 1064 + return smb_EIO(smb_eio_trace_null_pointers); 1065 1065 } 1066 1066 1067 1067 rc = smb2_plain_req_init(SMB2_NEGOTIATE, NULL, server, ··· 1142 1142 } else if (rc != 0) 1143 1143 goto neg_exit; 1144 1144 1145 - rc = -EIO; 1145 + u16 dialect = le16_to_cpu(rsp->DialectRevision); 1146 1146 if (strcmp(server->vals->version_string, 1147 1147 SMB3ANY_VERSION_STRING) == 0) { 1148 - if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) { 1148 + switch (dialect) { 1149 + case SMB20_PROT_ID: 1149 1150 cifs_server_dbg(VFS, 1150 1151 "SMB2 dialect returned but not requested\n"); 1152 + rc = smb_EIO2(smb_eio_trace_neg_unreq_dialect, dialect, 3); 1151 1153 goto neg_exit; 1152 - } else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) { 1154 + case SMB21_PROT_ID: 1153 1155 cifs_server_dbg(VFS, 1154 1156 "SMB2.1 dialect returned but not requested\n"); 1157 + rc = smb_EIO2(smb_eio_trace_neg_unreq_dialect, dialect, 3); 1155 1158 goto neg_exit; 1156 - } else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) { 1159 + case SMB311_PROT_ID: 1157 1160 /* ops set to 3.0 by default for default so update */ 1158 1161 server->ops = &smb311_operations; 1159 1162 server->vals = &smb311_values; 1163 + break; 1164 + default: 1165 + break; 1160 1166 } 1161 1167 } else if (strcmp(server->vals->version_string, 1162 - SMBDEFAULT_VERSION_STRING) == 0) { 1163 - if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) { 1168 + SMBDEFAULT_VERSION_STRING) == 0) { 1169 + switch (dialect) { 1170 + case SMB20_PROT_ID: 1164 1171 cifs_server_dbg(VFS, 1165 1172 "SMB2 dialect returned but not requested\n"); 1173 + rc = smb_EIO2(smb_eio_trace_neg_unreq_dialect, dialect, 0); 1166 1174 goto neg_exit; 1167 - } else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) { 1175 + case SMB21_PROT_ID: 1168 1176 /* ops set to 3.0 by default for default so update */ 1169 1177 server->ops = &smb21_operations; 1170 1178 server->vals = &smb21_values; 1171 - } else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) { 1179 + break; 1180 + case SMB311_PROT_ID: 1172 1181 server->ops = &smb311_operations; 1173 1182 server->vals = &smb311_values; 1183 + break; 1184 + default: 1185 + break; 1174 1186 } 1175 - } else if (le16_to_cpu(rsp->DialectRevision) != 1176 - server->vals->protocol_id) { 1187 + } else if (dialect != server->vals->protocol_id) { 1177 1188 /* if requested single dialect ensure returned dialect matched */ 1178 1189 cifs_server_dbg(VFS, "Invalid 0x%x dialect returned: not requested\n", 1179 - le16_to_cpu(rsp->DialectRevision)); 1190 + dialect); 1191 + rc = smb_EIO2(smb_eio_trace_neg_unreq_dialect, 1192 + dialect, server->vals->protocol_id); 1180 1193 goto neg_exit; 1181 1194 } 1182 1195 1183 1196 cifs_dbg(FYI, "mode 0x%x\n", rsp->SecurityMode); 1184 1197 1185 - if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) 1198 + switch (dialect) { 1199 + case SMB20_PROT_ID: 1186 1200 cifs_dbg(FYI, "negotiated smb2.0 dialect\n"); 1187 - else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) 1201 + break; 1202 + case SMB21_PROT_ID: 1188 1203 cifs_dbg(FYI, "negotiated smb2.1 dialect\n"); 1189 - else if (rsp->DialectRevision == cpu_to_le16(SMB30_PROT_ID)) 1204 + break; 1205 + case SMB30_PROT_ID: 1190 1206 cifs_dbg(FYI, "negotiated smb3.0 dialect\n"); 1191 - else if (rsp->DialectRevision == cpu_to_le16(SMB302_PROT_ID)) 1207 + break; 1208 + case SMB302_PROT_ID: 1192 1209 cifs_dbg(FYI, "negotiated smb3.02 dialect\n"); 1193 - else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) 1210 + break; 1211 + case SMB311_PROT_ID: 1194 1212 cifs_dbg(FYI, "negotiated smb3.1.1 dialect\n"); 1195 - else { 1213 + break; 1214 + default: 1196 1215 cifs_server_dbg(VFS, "Invalid dialect returned by server 0x%x\n", 1197 - le16_to_cpu(rsp->DialectRevision)); 1216 + dialect); 1217 + rc = smb_EIO1(smb_eio_trace_neg_inval_dialect, dialect); 1198 1218 goto neg_exit; 1199 1219 } 1200 1220 1201 1221 rc = 0; 1202 - server->dialect = le16_to_cpu(rsp->DialectRevision); 1222 + server->dialect = dialect; 1203 1223 1204 1224 /* 1205 1225 * Keep a copy of the hash after negprot. This hash will be ··· 1275 1255 if (rc == 1) 1276 1256 rc = 0; 1277 1257 else if (rc == 0) 1278 - rc = -EIO; 1258 + rc = smb_EIO1(smb_eio_trace_neg_decode_token, rc); 1279 1259 } 1280 1260 1281 - if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) { 1261 + if (server->dialect == SMB311_PROT_ID) { 1282 1262 if (rsp->NegotiateContextCount) 1283 1263 rc = smb311_decode_neg_context(rsp, server, 1284 1264 rsp_iov.iov_len); ··· 1391 1371 } else if (rc != 0) { 1392 1372 cifs_tcon_dbg(VFS, "validate protocol negotiate failed: %d\n", 1393 1373 rc); 1394 - rc = -EIO; 1374 + rc = smb_EIO1(smb_eio_trace_neg_info_fail, rc); 1395 1375 goto out_free_inbuf; 1396 1376 } 1397 1377 1398 - rc = -EIO; 1399 1378 if (rsplen != sizeof(*pneg_rsp)) { 1400 1379 cifs_tcon_dbg(VFS, "Invalid protocol negotiate response size: %d\n", 1401 1380 rsplen); 1402 1381 1403 1382 /* relax check since Mac returns max bufsize allowed on ioctl */ 1404 - if (rsplen > CIFSMaxBufSize || rsplen < sizeof(*pneg_rsp)) 1383 + if (rsplen > CIFSMaxBufSize || rsplen < sizeof(*pneg_rsp)) { 1384 + rc = smb_EIO1(smb_eio_trace_neg_bad_rsplen, rsplen); 1405 1385 goto out_free_rsp; 1386 + } 1406 1387 } 1407 1388 1408 1389 /* check validate negotiate info response matches what we got earlier */ 1409 - if (pneg_rsp->Dialect != cpu_to_le16(server->dialect)) 1410 - goto vneg_out; 1390 + u16 dialect = le16_to_cpu(pneg_rsp->Dialect); 1411 1391 1412 - if (pneg_rsp->SecurityMode != cpu_to_le16(server->sec_mode)) 1392 + if (dialect != server->dialect) { 1393 + rc = smb_EIO2(smb_eio_trace_neg_info_dialect, 1394 + dialect, server->dialect); 1413 1395 goto vneg_out; 1396 + } 1397 + 1398 + u16 sec_mode = le16_to_cpu(pneg_rsp->SecurityMode); 1399 + 1400 + if (sec_mode != server->sec_mode) { 1401 + rc = smb_EIO2(smb_eio_trace_neg_info_sec_mode, 1402 + sec_mode, server->sec_mode); 1403 + goto vneg_out; 1404 + } 1414 1405 1415 1406 /* do not validate server guid because not saved at negprot time yet */ 1407 + u32 caps = le32_to_cpu(pneg_rsp->Capabilities); 1416 1408 1417 - if ((le32_to_cpu(pneg_rsp->Capabilities) | SMB2_NT_FIND | 1418 - SMB2_LARGE_FILES) != server->capabilities) 1409 + if ((caps | SMB2_NT_FIND | 1410 + SMB2_LARGE_FILES) != server->capabilities) { 1411 + rc = smb_EIO2(smb_eio_trace_neg_info_caps, 1412 + caps, server->capabilities); 1419 1413 goto vneg_out; 1414 + } 1420 1415 1421 1416 /* validate negotiate successful */ 1422 1417 rc = 0; ··· 1793 1758 if (rc) 1794 1759 goto out; 1795 1760 1796 - if (offsetof(struct smb2_sess_setup_rsp, Buffer) != 1797 - le16_to_cpu(rsp->SecurityBufferOffset)) { 1798 - cifs_dbg(VFS, "Invalid security buffer offset %d\n", 1799 - le16_to_cpu(rsp->SecurityBufferOffset)); 1800 - rc = -EIO; 1761 + u16 boff = le16_to_cpu(rsp->SecurityBufferOffset); 1762 + 1763 + if (offsetof(struct smb2_sess_setup_rsp, Buffer) != boff) { 1764 + cifs_dbg(VFS, "Invalid security buffer offset %d\n", boff); 1765 + rc = smb_EIO1(smb_eio_trace_sess_buf_off, boff); 1801 1766 goto out; 1802 1767 } 1803 1768 rc = decode_ntlmssp_challenge(rsp->Buffer, ··· 1951 1916 1952 1917 if (!server) { 1953 1918 WARN(1, "%s: server is NULL!\n", __func__); 1954 - return -EIO; 1919 + return smb_EIO(smb_eio_trace_null_pointers); 1955 1920 } 1956 1921 1957 1922 sess_data = kzalloc(sizeof(struct SMB2_sess_data), GFP_KERNEL); ··· 2001 1966 2002 1967 cifs_dbg(FYI, "disconnect session %p\n", ses); 2003 1968 2004 - if (ses && (ses->server)) 2005 - server = ses->server; 2006 - else 2007 - return -EIO; 1969 + if (!ses || !ses->server) 1970 + return smb_EIO(smb_eio_trace_null_pointers); 1971 + server = ses->server; 2008 1972 2009 1973 /* no need to send SMB logoff if uid already closed due to reconnect */ 2010 1974 spin_lock(&ses->chan_lock); ··· 2082 2048 cifs_dbg(FYI, "TCON\n"); 2083 2049 2084 2050 if (!server || !tree) 2085 - return -EIO; 2051 + return smb_EIO(smb_eio_trace_null_pointers); 2086 2052 2087 2053 unc_path = kmalloc(MAX_SHARENAME_LENGTH * 2, GFP_KERNEL); 2088 2054 if (unc_path == NULL) ··· 2220 2186 cifs_dbg(FYI, "Tree Disconnect\n"); 2221 2187 2222 2188 if (!ses || !(ses->server)) 2223 - return -EIO; 2189 + return smb_EIO(smb_eio_trace_null_pointers); 2224 2190 2225 2191 trace_smb3_tdis_enter(xid, tcon->tid, ses->Suid, tcon->tree_name); 2226 2192 spin_lock(&ses->chan_lock); ··· 2890 2856 return -ENOMEM; 2891 2857 2892 2858 if (!ses || !server) { 2893 - rc = -EIO; 2859 + rc = smb_EIO(smb_eio_trace_null_pointers); 2894 2860 goto err_free_path; 2895 2861 } 2896 2862 ··· 3007 2973 */ 3008 2974 rsp = (struct smb2_create_rsp *)rsp_iov.iov_base; 3009 2975 if (rsp == NULL) { 3010 - rc = -EIO; 2976 + rc = smb_EIO(smb_eio_trace_mkdir_no_rsp); 3011 2977 kfree(pc_buf); 3012 2978 goto err_free_req; 3013 2979 } ··· 3245 3211 3246 3212 cifs_dbg(FYI, "create/open\n"); 3247 3213 if (!ses || !server) 3248 - return -EIO; 3214 + return smb_EIO(smb_eio_trace_null_pointers); 3249 3215 3250 3216 if (smb3_encryption_required(tcon)) 3251 3217 flags |= CIFS_TRANSFORM_REQ; ··· 3451 3417 int retries = 0, cur_sleep = 1; 3452 3418 3453 3419 if (!tcon) 3454 - return -EIO; 3420 + return smb_EIO(smb_eio_trace_null_pointers); 3455 3421 3456 3422 ses = tcon->ses; 3457 3423 if (!ses) 3458 - return -EIO; 3424 + return smb_EIO(smb_eio_trace_null_pointers); 3459 3425 3460 3426 replay_again: 3461 3427 /* reinitialize for possible replay */ ··· 3463 3429 server = cifs_pick_channel(ses); 3464 3430 3465 3431 if (!server) 3466 - return -EIO; 3432 + return smb_EIO(smb_eio_trace_null_pointers); 3467 3433 3468 3434 cifs_dbg(FYI, "SMB2 IOCTL\n"); 3469 3435 ··· 3526 3492 * warning) 3527 3493 */ 3528 3494 if (rsp == NULL) { 3529 - rc = -EIO; 3495 + rc = smb_EIO(smb_eio_trace_ioctl_no_rsp); 3530 3496 goto ioctl_exit; 3531 3497 } 3532 3498 ··· 3537 3503 goto ioctl_exit; /* server returned no data */ 3538 3504 else if (*plen > rsp_iov.iov_len || *plen > 0xFF00) { 3539 3505 cifs_tcon_dbg(VFS, "srv returned invalid ioctl length: %d\n", *plen); 3506 + rc = smb_EIO2(smb_eio_trace_ioctl_data_len, *plen, rsp_iov.iov_len); 3540 3507 *plen = 0; 3541 - rc = -EIO; 3542 3508 goto ioctl_exit; 3543 3509 } 3544 3510 3545 - if (rsp_iov.iov_len - *plen < le32_to_cpu(rsp->OutputOffset)) { 3546 - cifs_tcon_dbg(VFS, "Malformed ioctl resp: len %d offset %d\n", *plen, 3547 - le32_to_cpu(rsp->OutputOffset)); 3511 + u32 outoff = le32_to_cpu(rsp->OutputOffset); 3512 + 3513 + if (rsp_iov.iov_len - *plen < outoff) { 3514 + cifs_tcon_dbg(VFS, "Malformed ioctl resp: len %d offset %d\n", 3515 + *plen, outoff); 3516 + rc = smb_EIO2(smb_eio_trace_ioctl_out_off, rsp_iov.iov_len - *plen, outoff); 3548 3517 *plen = 0; 3549 - rc = -EIO; 3550 3518 goto ioctl_exit; 3551 3519 } 3552 3520 ··· 3656 3620 cifs_dbg(FYI, "Close\n"); 3657 3621 3658 3622 if (!ses || !server) 3659 - return -EIO; 3623 + return smb_EIO(smb_eio_trace_null_pointers); 3660 3624 3661 3625 if (smb3_encryption_required(tcon)) 3662 3626 flags |= CIFS_TRANSFORM_REQ; ··· 3853 3817 cifs_dbg(FYI, "Query Info\n"); 3854 3818 3855 3819 if (!ses) 3856 - return -EIO; 3820 + return smb_EIO(smb_eio_trace_null_pointers); 3857 3821 3858 3822 replay_again: 3859 3823 /* reinitialize for possible replay */ ··· 3862 3826 server = cifs_pick_channel(ses); 3863 3827 3864 3828 if (!server) 3865 - return -EIO; 3829 + return smb_EIO(smb_eio_trace_null_pointers); 3866 3830 3867 3831 if (smb3_encryption_required(tcon)) 3868 3832 flags |= CIFS_TRANSFORM_REQ; ··· 4047 4011 4048 4012 cifs_dbg(FYI, "change notify\n"); 4049 4013 if (!ses || !server) 4050 - return -EIO; 4014 + return smb_EIO(smb_eio_trace_null_pointers); 4051 4015 4052 4016 if (smb3_encryption_required(tcon)) 4053 4017 flags |= CIFS_TRANSFORM_REQ; ··· 4383 4347 4384 4348 cifs_dbg(FYI, "flush\n"); 4385 4349 if (!ses || !(ses->server)) 4386 - return -EIO; 4350 + return smb_EIO(smb_eio_trace_null_pointers); 4387 4351 4388 4352 if (smb3_encryption_required(tcon)) 4389 4353 flags |= CIFS_TRANSFORM_REQ; ··· 4618 4582 trace_netfs_sreq(&rdata->subreq, netfs_sreq_trace_io_malformed); 4619 4583 credits.value = le16_to_cpu(shdr->CreditRequest); 4620 4584 credits.instance = server->reconnect_instance; 4621 - rdata->result = -EIO; 4585 + rdata->result = smb_EIO(smb_eio_trace_read_rsp_malformed); 4622 4586 break; 4623 4587 default: 4624 4588 trace_netfs_sreq(&rdata->subreq, netfs_sreq_trace_io_unknown); 4625 - rdata->result = -EIO; 4589 + rdata->result = smb_EIO1(smb_eio_trace_read_mid_state_unknown, 4590 + mid->mid_state); 4626 4591 break; 4627 4592 } 4628 4593 #ifdef CONFIG_CIFS_SMB_DIRECT ··· 4832 4795 (*nbytes > io_parms->length)) { 4833 4796 cifs_dbg(FYI, "bad length %d for count %d\n", 4834 4797 *nbytes, io_parms->length); 4835 - rc = -EIO; 4798 + rc = smb_EIO2(smb_eio_trace_read_overlarge, 4799 + *nbytes, io_parms->length); 4836 4800 *nbytes = 0; 4837 4801 } 4838 4802 ··· 4919 4881 trace_netfs_sreq(&wdata->subreq, netfs_sreq_trace_io_malformed); 4920 4882 credits.value = le16_to_cpu(rsp->hdr.CreditRequest); 4921 4883 credits.instance = server->reconnect_instance; 4922 - result = -EIO; 4884 + result = smb_EIO(smb_eio_trace_write_rsp_malformed); 4923 4885 break; 4924 4886 default: 4925 4887 trace_netfs_sreq(&wdata->subreq, netfs_sreq_trace_io_unknown); 4926 - result = -EIO; 4888 + result = smb_EIO1(smb_eio_trace_write_mid_state_unknown, 4889 + mid->mid_state); 4927 4890 break; 4928 4891 } 4929 4892 #ifdef CONFIG_CIFS_SMB_DIRECT ··· 5567 5528 server = cifs_pick_channel(ses); 5568 5529 5569 5530 if (!ses || !(ses->server)) 5570 - return -EIO; 5531 + return smb_EIO(smb_eio_trace_null_pointers); 5571 5532 5572 5533 if (smb3_encryption_required(tcon)) 5573 5534 flags |= CIFS_TRANSFORM_REQ; ··· 5702 5663 server = cifs_pick_channel(ses); 5703 5664 5704 5665 if (!ses || !server) 5705 - return -EIO; 5666 + return smb_EIO(smb_eio_trace_null_pointers); 5706 5667 5707 5668 if (!num) 5708 5669 return -EINVAL; ··· 5899 5860 cifs_dbg(FYI, "Query FSInfo level %d\n", level); 5900 5861 5901 5862 if ((tcon->ses == NULL) || server == NULL) 5902 - return -EIO; 5863 + return smb_EIO(smb_eio_trace_null_pointers); 5903 5864 5904 5865 rc = smb2_plain_req_init(SMB2_QUERY_INFO, tcon, server, 5905 5866 (void **) &req, &total_len);
+1 -1
fs/smb/client/smb2transport.c
··· 153 153 memcpy(key, ses->auth_key.response, 154 154 SMB2_NTLMV2_SESSKEY_SIZE); 155 155 } else { 156 - rc = -EIO; 156 + rc = smb_EIO(smb_eio_trace_no_auth_key); 157 157 } 158 158 break; 159 159 default:
+149
fs/smb/client/trace.h
··· 20 20 /* 21 21 * Specify enums for tracing information. 22 22 */ 23 + #define smb_eio_traces \ 24 + EM(smb_eio_trace_compress_copy, "compress_copy") \ 25 + EM(smb_eio_trace_copychunk_inv_rsp, "copychunk_inv_rsp") \ 26 + EM(smb_eio_trace_copychunk_overcopy_b, "copychunk_overcopy_b") \ 27 + EM(smb_eio_trace_copychunk_overcopy_c, "copychunk_overcopy_c") \ 28 + EM(smb_eio_trace_create_rsp_too_small, "create_rsp_too_small") \ 29 + EM(smb_eio_trace_dfsref_no_rsp, "dfsref_no_rsp") \ 30 + EM(smb_eio_trace_ea_overrun, "ea_overrun") \ 31 + EM(smb_eio_trace_extract_will_pin, "extract_will_pin") \ 32 + EM(smb_eio_trace_forced_shutdown, "forced_shutdown") \ 33 + EM(smb_eio_trace_getacl_bcc_too_small, "getacl_bcc_too_small") \ 34 + EM(smb_eio_trace_getcifsacl_param_count, "getcifsacl_param_count") \ 35 + EM(smb_eio_trace_getdfsrefer_bcc_too_small, "getdfsrefer_bcc_too_small") \ 36 + EM(smb_eio_trace_getextattr_bcc_too_small, "getextattr_bcc_too_small") \ 37 + EM(smb_eio_trace_getextattr_inv_size, "getextattr_inv_size") \ 38 + EM(smb_eio_trace_getsrvinonum_bcc_too_small, "getsrvinonum_bcc_too_small") \ 39 + EM(smb_eio_trace_getsrvinonum_size, "getsrvinonum_size") \ 40 + EM(smb_eio_trace_ioctl_data_len, "ioctl_data_len") \ 41 + EM(smb_eio_trace_ioctl_no_rsp, "ioctl_no_rsp") \ 42 + EM(smb_eio_trace_ioctl_out_off, "ioctl_out_off") \ 43 + EM(smb_eio_trace_lock_bcc_too_small, "lock_bcc_too_small") \ 44 + EM(smb_eio_trace_lock_data_too_small, "lock_data_too_small") \ 45 + EM(smb_eio_trace_malformed_ksid_key, "malformed_ksid_key") \ 46 + EM(smb_eio_trace_malformed_sid_key, "malformed_sid_key") \ 47 + EM(smb_eio_trace_mkdir_no_rsp, "mkdir_no_rsp") \ 48 + EM(smb_eio_trace_neg_bad_rsplen, "neg_bad_rsplen") \ 49 + EM(smb_eio_trace_neg_decode_token, "neg_decode_token") \ 50 + EM(smb_eio_trace_neg_info_caps, "neg_info_caps") \ 51 + EM(smb_eio_trace_neg_info_dialect, "neg_info_dialect") \ 52 + EM(smb_eio_trace_neg_info_fail, "neg_info_fail") \ 53 + EM(smb_eio_trace_neg_info_sec_mode, "neg_info_sec_mode") \ 54 + EM(smb_eio_trace_neg_inval_dialect, "neg_inval_dialect") \ 55 + EM(smb_eio_trace_neg_no_crypt_key, "neg_no_crypt_key") \ 56 + EM(smb_eio_trace_neg_sec_blob_too_small, "neg_sec_blob_too_small") \ 57 + EM(smb_eio_trace_neg_unreq_dialect, "neg_unreq_dialect") \ 58 + EM(smb_eio_trace_no_auth_key, "no_auth_key") \ 59 + EM(smb_eio_trace_no_lease_key, "no_lease_key") \ 60 + EM(smb_eio_trace_not_netfs_writeback, "not_netfs_writeback") \ 61 + EM(smb_eio_trace_null_pointers, "null_pointers") \ 62 + EM(smb_eio_trace_oldqfsinfo_bcc_too_small, "oldqfsinfo_bcc_too_small") \ 63 + EM(smb_eio_trace_pend_del_fail, "pend_del_fail") \ 64 + EM(smb_eio_trace_qalleas_bcc_too_small, "qalleas_bcc_too_small") \ 65 + EM(smb_eio_trace_qalleas_ea_overlong, "qalleas_ea_overlong") \ 66 + EM(smb_eio_trace_qalleas_overlong, "qalleas_overlong") \ 67 + EM(smb_eio_trace_qfileinfo_bcc_too_small, "qfileinfo_bcc_too_small") \ 68 + EM(smb_eio_trace_qfileinfo_invalid, "qfileinfo_invalid") \ 69 + EM(smb_eio_trace_qfsattrinfo_bcc_too_small, "qfsattrinfo_bcc_too_small") \ 70 + EM(smb_eio_trace_qfsdevinfo_bcc_too_small, "qfsdevinfo_bcc_too_small") \ 71 + EM(smb_eio_trace_qfsinfo_bcc_too_small, "qfsinfo_bcc_too_small") \ 72 + EM(smb_eio_trace_qfsposixinfo_bcc_too_small, "qfsposixinfo_bcc_too_small") \ 73 + EM(smb_eio_trace_qfsunixinfo_bcc_too_small, "qfsunixinfo_bcc_too_small") \ 74 + EM(smb_eio_trace_qpathinfo_bcc_too_small, "qpathinfo_bcc_too_small") \ 75 + EM(smb_eio_trace_qpathinfo_invalid, "qpathinfo_invalid") \ 76 + EM(smb_eio_trace_qreparse_data_area, "qreparse_data_area") \ 77 + EM(smb_eio_trace_qreparse_rep_datalen, "qreparse_rep_datalen") \ 78 + EM(smb_eio_trace_qreparse_ret_datalen, "qreparse_ret_datalen") \ 79 + EM(smb_eio_trace_qreparse_setup_count, "qreparse_setup_count") \ 80 + EM(smb_eio_trace_qreparse_sizes_wrong, "qreparse_sizes_wrong") \ 81 + EM(smb_eio_trace_qsym_bcc_too_small, "qsym_bcc_too_small") \ 82 + EM(smb_eio_trace_read_mid_state_unknown, "read_mid_state_unknown") \ 83 + EM(smb_eio_trace_read_overlarge, "read_overlarge") \ 84 + EM(smb_eio_trace_read_rsp_malformed, "read_rsp_malformed") \ 85 + EM(smb_eio_trace_read_rsp_short, "read_rsp_short") \ 86 + EM(smb_eio_trace_read_too_far, "read_too_far") \ 87 + EM(smb_eio_trace_reparse_data_len, "reparse_data_len") \ 88 + EM(smb_eio_trace_reparse_native_len, "reparse_native_len") \ 89 + EM(smb_eio_trace_reparse_native_nul, "reparse_native_nul") \ 90 + EM(smb_eio_trace_reparse_native_sym_len, "reparse_native_sym_len") \ 91 + EM(smb_eio_trace_reparse_nfs_dev, "reparse_nfs_dev") \ 92 + EM(smb_eio_trace_reparse_nfs_nul, "reparse_nfs_nul") \ 93 + EM(smb_eio_trace_reparse_nfs_sockfifo, "reparse_nfs_sockfifo") \ 94 + EM(smb_eio_trace_reparse_nfs_symbuf, "reparse_nfs_symbuf") \ 95 + EM(smb_eio_trace_reparse_nfs_too_short, "reparse_nfs_too_short") \ 96 + EM(smb_eio_trace_reparse_overlong, "reparse_overlong") \ 97 + EM(smb_eio_trace_reparse_rdlen, "reparse_rdlen") \ 98 + EM(smb_eio_trace_reparse_wsl_nul, "reparse_wsl_nul") \ 99 + EM(smb_eio_trace_reparse_wsl_symbuf, "reparse_wsl_symbuf") \ 100 + EM(smb_eio_trace_reparse_wsl_ver, "reparse_wsl_ver") \ 101 + EM(smb_eio_trace_rx_b_read_short, "rx_b_read_short") \ 102 + EM(smb_eio_trace_rx_bad_datalen, "rx_bad_datalen") \ 103 + EM(smb_eio_trace_rx_both_buf, "rx_both_buf") \ 104 + EM(smb_eio_trace_rx_calc_len_too_big, "rx_calc_len_too_big") \ 105 + EM(smb_eio_trace_rx_check_rsp, "rx_check_rsp") \ 106 + EM(smb_eio_trace_rx_copy_to_iter, "rx_copy_to_iter") \ 107 + EM(smb_eio_trace_rx_insuff_res, "rx_insuff_res") \ 108 + EM(smb_eio_trace_rx_inv_bcc, "rx_inv_bcc") \ 109 + EM(smb_eio_trace_rx_mid_unready, "rx_mid_unready") \ 110 + EM(smb_eio_trace_rx_neg_sess_resp, "rx_neg_sess_resp") \ 111 + EM(smb_eio_trace_rx_overlong, "rx_overlong") \ 112 + EM(smb_eio_trace_rx_overpage, "rx_overpage") \ 113 + EM(smb_eio_trace_rx_pos_sess_resp, "rx_pos_sess_resp") \ 114 + EM(smb_eio_trace_rx_rfc1002_magic, "rx_rfc1002_magic") \ 115 + EM(smb_eio_trace_rx_sync_mid_invalid, "rx_sync_mid_invalid") \ 116 + EM(smb_eio_trace_rx_sync_mid_malformed, "rx_sync_mid_malformed") \ 117 + EM(smb_eio_trace_rx_too_short, "rx_too_short") \ 118 + EM(smb_eio_trace_rx_trans2_extract, "rx_trans2_extract") \ 119 + EM(smb_eio_trace_rx_unknown_resp, "rx_unknown_resp") \ 120 + EM(smb_eio_trace_rx_unspec_error, "rx_unspec_error") \ 121 + EM(smb_eio_trace_sess_buf_off, "sess_buf_off") \ 122 + EM(smb_eio_trace_sess_exiting, "sess_exiting") \ 123 + EM(smb_eio_trace_sess_krb_wcc, "sess_krb_wcc") \ 124 + EM(smb_eio_trace_sess_nl2_wcc, "sess_nl2_wcc") \ 125 + EM(smb_eio_trace_sess_rawnl_auth_wcc, "sess_rawnl_auth_wcc") \ 126 + EM(smb_eio_trace_sess_rawnl_neg_wcc, "sess_rawnl_neg_wcc") \ 127 + EM(smb_eio_trace_short_symlink_write, "short_symlink_write") \ 128 + EM(smb_eio_trace_sid_too_many_auth, "sid_too_many_auth") \ 129 + EM(smb_eio_trace_sig_data_too_small, "sig_data_too_small") \ 130 + EM(smb_eio_trace_sig_iter, "sig_iter") \ 131 + EM(smb_eio_trace_smb1_received_error, "smb1_received_error") \ 132 + EM(smb_eio_trace_smb2_received_error, "smb2_received_error") \ 133 + EM(smb_eio_trace_sym_slash, "sym_slash") \ 134 + EM(smb_eio_trace_sym_target_len, "sym_target_len") \ 135 + EM(smb_eio_trace_symlink_file_size, "symlink_file_size") \ 136 + EM(smb_eio_trace_tdis_in_reconnect, "tdis_in_reconnect") \ 137 + EM(smb_eio_trace_tx_chained_async, "tx_chained_async") \ 138 + EM(smb_eio_trace_tx_compress_failed, "tx_compress_failed") \ 139 + EM(smb_eio_trace_tx_copy_iter_to_buf, "tx_copy_iter_to_buf") \ 140 + EM(smb_eio_trace_tx_copy_to_buf, "tx_copy_to_buf") \ 141 + EM(smb_eio_trace_tx_max_compound, "tx_max_compound") \ 142 + EM(smb_eio_trace_tx_miscopy_to_buf, "tx_miscopy_to_buf") \ 143 + EM(smb_eio_trace_tx_need_transform, "tx_need_transform") \ 144 + EM(smb_eio_trace_tx_too_long, "sr_too_long") \ 145 + EM(smb_eio_trace_unixqfileinfo_bcc_too_small, "unixqfileinfo_bcc_too_small") \ 146 + EM(smb_eio_trace_unixqpathinfo_bcc_too_small, "unixqpathinfo_bcc_too_small") \ 147 + EM(smb_eio_trace_user_iter, "user_iter") \ 148 + EM(smb_eio_trace_write_bad_buf_type, "write_bad_buf_type") \ 149 + EM(smb_eio_trace_write_mid_state_unknown, "write_mid_state_unknown") \ 150 + EM(smb_eio_trace_write_rsp_malformed, "write_rsp_malformed") \ 151 + E_(smb_eio_trace_write_too_far, "write_too_far") 152 + 23 153 #define smb3_rw_credits_traces \ 24 154 EM(cifs_trace_rw_credits_call_readv_adjust, "rd-call-adj") \ 25 155 EM(cifs_trace_rw_credits_call_writev_adjust, "wr-call-adj") \ ··· 209 79 #define EM(a, b) a, 210 80 #define E_(a, b) a 211 81 82 + enum smb_eio_trace { smb_eio_traces } __mode(byte); 212 83 enum smb3_rw_credits_trace { smb3_rw_credits_traces } __mode(byte); 213 84 enum smb3_tcon_ref_trace { smb3_tcon_ref_traces } __mode(byte); 214 85 ··· 223 92 #define EM(a, b) TRACE_DEFINE_ENUM(a); 224 93 #define E_(a, b) TRACE_DEFINE_ENUM(a); 225 94 95 + smb_eio_traces; 226 96 smb3_rw_credits_traces; 227 97 smb3_tcon_ref_traces; 228 98 ··· 1748 1616 __entry->server_credits, __entry->in_flight) 1749 1617 ); 1750 1618 1619 + TRACE_EVENT(smb3_eio, 1620 + TP_PROTO(enum smb_eio_trace trace, unsigned long info, unsigned long info2), 1621 + TP_ARGS(trace, info, info2), 1622 + TP_STRUCT__entry( 1623 + __field(enum smb_eio_trace, trace) 1624 + __field(unsigned long, info) 1625 + __field(unsigned long, info2) 1626 + ), 1627 + TP_fast_assign( 1628 + __entry->trace = trace; 1629 + __entry->info = info; 1630 + __entry->info2 = info2; 1631 + ), 1632 + TP_printk("%s info=%lx,%lx", 1633 + __print_symbolic(__entry->trace, smb_eio_traces), 1634 + __entry->info, __entry->info2) 1635 + ); 1751 1636 1752 1637 #undef EM 1753 1638 #undef E_
+12 -9
fs/smb/client/transport.c
··· 402 402 return __smb_send_rqst(server, num_rqst, rqst); 403 403 404 404 if (WARN_ON_ONCE(num_rqst > MAX_COMPOUND - 1)) 405 - return -EIO; 405 + return smb_EIO1(smb_eio_trace_tx_max_compound, num_rqst); 406 406 407 407 if (!server->ops->init_transform_rq) { 408 408 cifs_server_dbg(VFS, "Encryption requested but transform callback is missing\n"); 409 - return -EIO; 409 + return smb_EIO(smb_eio_trace_tx_need_transform); 410 410 } 411 411 412 412 new_rqst[0].rq_iov = &iov; ··· 753 753 rc = -EAGAIN; 754 754 break; 755 755 case MID_RESPONSE_MALFORMED: 756 - rc = -EIO; 756 + rc = smb_EIO(smb_eio_trace_rx_sync_mid_malformed); 757 757 break; 758 758 case MID_SHUTDOWN: 759 759 rc = -EHOSTDOWN; ··· 769 769 spin_unlock(&server->mid_queue_lock); 770 770 cifs_server_dbg(VFS, "%s: invalid mid state mid=%llu state=%d\n", 771 771 __func__, mid->mid, mid->mid_state); 772 - rc = -EIO; 772 + rc = smb_EIO1(smb_eio_trace_rx_sync_mid_invalid, mid->mid_state); 773 773 goto sync_mid_done; 774 774 } 775 775 spin_unlock(&server->mid_queue_lock); ··· 883 883 884 884 if (!ses || !ses->server || !server) { 885 885 cifs_dbg(VFS, "Null session\n"); 886 - return -EIO; 886 + return smb_EIO(smb_eio_trace_null_pointers); 887 887 } 888 888 889 889 spin_lock(&server->srv_lock); ··· 1043 1043 1044 1044 if (!mid[i]->resp_buf || 1045 1045 mid[i]->mid_state != MID_RESPONSE_READY) { 1046 - rc = -EIO; 1046 + rc = smb_EIO1(smb_eio_trace_rx_mid_unready, mid[i]->mid_state); 1047 1047 cifs_dbg(FYI, "Bad MID state?\n"); 1048 1048 goto out; 1049 1049 } ··· 1215 1215 cifs_dbg(FYI, "%s: server returned short header. got=%u expected=%zu\n", 1216 1216 __func__, server->total_read, 1217 1217 server->vals->read_rsp_size); 1218 - rdata->result = -EIO; 1218 + rdata->result = smb_EIO2(smb_eio_trace_read_rsp_short, 1219 + server->total_read, server->vals->read_rsp_size); 1219 1220 return cifs_readv_discard(server, mid); 1220 1221 } 1221 1222 ··· 1234 1233 /* data_offset is beyond the end of smallbuf */ 1235 1234 cifs_dbg(FYI, "%s: data offset (%u) beyond end of smallbuf\n", 1236 1235 __func__, data_offset); 1237 - rdata->result = -EIO; 1236 + rdata->result = smb_EIO1(smb_eio_trace_read_overlarge, 1237 + data_offset); 1238 1238 return cifs_readv_discard(server, mid); 1239 1239 } 1240 1240 ··· 1260 1258 data_len = server->ops->read_data_length(buf, use_rdma_mr); 1261 1259 if (!use_rdma_mr && (data_offset + data_len > buflen)) { 1262 1260 /* data_len is corrupt -- discard frame */ 1263 - rdata->result = -EIO; 1261 + rdata->result = smb_EIO2(smb_eio_trace_read_rsp_malformed, 1262 + data_offset + data_len, buflen); 1264 1263 return cifs_readv_discard(server, mid); 1265 1264 } 1266 1265
+1 -1
fs/smb/client/xattr.c
··· 397 397 void *page; 398 398 399 399 if (unlikely(cifs_forced_shutdown(cifs_sb))) 400 - return -EIO; 400 + return smb_EIO(smb_eio_trace_forced_shutdown); 401 401 402 402 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) 403 403 return -EOPNOTSUPP;