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

Merge tag '6.0-rc1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs client fixes from Steve French:

- memory leak fix

- two small cleanups

- trivial strlcpy removal

- update missing entry for cifs headers in MAINTAINERS file

* tag '6.0-rc1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
cifs: move from strlcpy with unused retval to strscpy
cifs: Fix memory leak on the deferred close
cifs: remove useless parameter 'is_fsctl' from SMB2_ioctl()
cifs: remove unused server parameter from calc_smb_size()
cifs: missing directory in MAINTAINERS file

+45 -52
+1
MAINTAINERS
··· 5145 5145 F: Documentation/admin-guide/cifs/ 5146 5146 F: fs/cifs/ 5147 5147 F: fs/smbfs_common/ 5148 + F: include/uapi/linux/cifs 5148 5149 5149 5150 COMPACTPCI HOTPLUG CORE 5150 5151 M: Scott Murray <scott@spiteful.org>
+1 -1
fs/cifs/cifs_debug.c
··· 42 42 smb->Command, smb->Status.CifsError, 43 43 smb->Flags, smb->Flags2, smb->Mid, smb->Pid); 44 44 cifs_dbg(VFS, "smb buf %p len %u\n", smb, 45 - server->ops->calc_smb_size(smb, server)); 45 + server->ops->calc_smb_size(smb)); 46 46 #endif /* CONFIG_CIFS_DEBUG2 */ 47 47 } 48 48
+1 -1
fs/cifs/cifsglob.h
··· 417 417 int (*close_dir)(const unsigned int, struct cifs_tcon *, 418 418 struct cifs_fid *); 419 419 /* calculate a size of SMB message */ 420 - unsigned int (*calc_smb_size)(void *buf, struct TCP_Server_Info *ptcpi); 420 + unsigned int (*calc_smb_size)(void *buf); 421 421 /* check for STATUS_PENDING and process the response if yes */ 422 422 bool (*is_status_pending)(char *buf, struct TCP_Server_Info *server); 423 423 /* check for STATUS_NETWORK_SESSION_EXPIRED */
+1 -1
fs/cifs/cifsproto.h
··· 151 151 extern struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *, bool); 152 152 extern int cifs_get_readable_path(struct cifs_tcon *tcon, const char *name, 153 153 struct cifsFileInfo **ret_file); 154 - extern unsigned int smbCalcSize(void *buf, struct TCP_Server_Info *server); 154 + extern unsigned int smbCalcSize(void *buf); 155 155 extern int decode_negTokenInit(unsigned char *security_blob, int length, 156 156 struct TCP_Server_Info *server); 157 157 extern int cifs_convert_address(struct sockaddr *dst, const char *src, int len);
+1 -1
fs/cifs/cifsroot.c
··· 59 59 pr_err("Root-CIFS: UNC path too long\n"); 60 60 return 1; 61 61 } 62 - strlcpy(root_dev, line, len); 62 + strscpy(root_dev, line, len); 63 63 srvaddr = parse_srvaddr(&line[2], s); 64 64 if (*s) { 65 65 int n = snprintf(root_opts,
+1 -1
fs/cifs/connect.c
··· 3994 3994 } 3995 3995 bcc_ptr += length + 1; 3996 3996 bytes_left -= (length + 1); 3997 - strlcpy(tcon->treeName, tree, sizeof(tcon->treeName)); 3997 + strscpy(tcon->treeName, tree, sizeof(tcon->treeName)); 3998 3998 3999 3999 /* mostly informational -- no need to fail on error here */ 4000 4000 kfree(tcon->nativeFileSystem);
+7 -1
fs/cifs/misc.c
··· 354 354 /* otherwise, there is enough to get to the BCC */ 355 355 if (check_smb_hdr(smb)) 356 356 return -EIO; 357 - clc_len = smbCalcSize(smb, server); 357 + clc_len = smbCalcSize(smb); 358 358 359 359 if (4 + rfclen != total_read) { 360 360 cifs_dbg(VFS, "Length read does not match RFC1001 length %d\n", ··· 737 737 list_for_each_entry(cfile, &cifs_inode->openFileList, flist) { 738 738 if (delayed_work_pending(&cfile->deferred)) { 739 739 if (cancel_delayed_work(&cfile->deferred)) { 740 + cifs_del_deferred_close(cfile); 741 + 740 742 tmp_list = kmalloc(sizeof(struct file_list), GFP_ATOMIC); 741 743 if (tmp_list == NULL) 742 744 break; ··· 768 766 list_for_each_entry(cfile, &tcon->openFileList, tlist) { 769 767 if (delayed_work_pending(&cfile->deferred)) { 770 768 if (cancel_delayed_work(&cfile->deferred)) { 769 + cifs_del_deferred_close(cfile); 770 + 771 771 tmp_list = kmalloc(sizeof(struct file_list), GFP_ATOMIC); 772 772 if (tmp_list == NULL) 773 773 break; ··· 803 799 if (strstr(full_path, path)) { 804 800 if (delayed_work_pending(&cfile->deferred)) { 805 801 if (cancel_delayed_work(&cfile->deferred)) { 802 + cifs_del_deferred_close(cfile); 803 + 806 804 tmp_list = kmalloc(sizeof(struct file_list), GFP_ATOMIC); 807 805 if (tmp_list == NULL) 808 806 break;
+1 -1
fs/cifs/netmisc.c
··· 909 909 * portion, the number of word parameters and the data portion of the message 910 910 */ 911 911 unsigned int 912 - smbCalcSize(void *buf, struct TCP_Server_Info *server) 912 + smbCalcSize(void *buf) 913 913 { 914 914 struct smb_hdr *ptr = buf; 915 915 return (sizeof(struct smb_hdr) + (2 * ptr->WordCount) +
+2 -4
fs/cifs/readdir.c
··· 806 806 807 807 end_of_smb = cfile->srch_inf.ntwrk_buf_start + 808 808 server->ops->calc_smb_size( 809 - cfile->srch_inf.ntwrk_buf_start, 810 - server); 809 + cfile->srch_inf.ntwrk_buf_start); 811 810 812 811 cur_ent = cfile->srch_inf.srch_entries_start; 813 812 first_entry_in_buffer = cfile->srch_inf.index_of_last_entry ··· 1160 1161 cifs_dbg(FYI, "loop through %d times filling dir for net buf %p\n", 1161 1162 num_to_fill, cifsFile->srch_inf.ntwrk_buf_start); 1162 1163 max_len = tcon->ses->server->ops->calc_smb_size( 1163 - cifsFile->srch_inf.ntwrk_buf_start, 1164 - tcon->ses->server); 1164 + cifsFile->srch_inf.ntwrk_buf_start); 1165 1165 end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + max_len; 1166 1166 1167 1167 tmp_buf = kmalloc(UNICODE_NAME_MAX, GFP_KERNEL);
-1
fs/cifs/smb2file.c
··· 61 61 nr_ioctl_req.Reserved = 0; 62 62 rc = SMB2_ioctl(xid, oparms->tcon, fid->persistent_fid, 63 63 fid->volatile_fid, FSCTL_LMR_REQUEST_RESILIENCY, 64 - true /* is_fsctl */, 65 64 (char *)&nr_ioctl_req, sizeof(nr_ioctl_req), 66 65 CIFSMaxBufSize, NULL, NULL /* no return info */); 67 66 if (rc == -EOPNOTSUPP) {
+2 -2
fs/cifs/smb2misc.c
··· 222 222 } 223 223 } 224 224 225 - calc_len = smb2_calc_size(buf, server); 225 + calc_len = smb2_calc_size(buf); 226 226 227 227 /* For SMB2_IOCTL, OutputOffset and OutputLength are optional, so might 228 228 * be 0, and not a real miscalculation */ ··· 410 410 * portion, the number of word parameters and the data portion of the message. 411 411 */ 412 412 unsigned int 413 - smb2_calc_size(void *buf, struct TCP_Server_Info *srvr) 413 + smb2_calc_size(void *buf) 414 414 { 415 415 struct smb2_pdu *pdu = buf; 416 416 struct smb2_hdr *shdr = &pdu->hdr;
+14 -23
fs/cifs/smb2ops.c
··· 387 387 shdr->Command, shdr->Status, shdr->Flags, shdr->MessageId, 388 388 shdr->Id.SyncId.ProcessId); 389 389 cifs_server_dbg(VFS, "smb buf %p len %u\n", buf, 390 - server->ops->calc_smb_size(buf, server)); 390 + server->ops->calc_smb_size(buf)); 391 391 #endif 392 392 } 393 393 ··· 681 681 struct cifs_ses *ses = tcon->ses; 682 682 683 683 rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID, 684 - FSCTL_QUERY_NETWORK_INTERFACE_INFO, true /* is_fsctl */, 684 + FSCTL_QUERY_NETWORK_INTERFACE_INFO, 685 685 NULL /* no data input */, 0 /* no data input */, 686 686 CIFSMaxBufSize, (char **)&out_buf, &ret_data_len); 687 687 if (rc == -EOPNOTSUPP) { ··· 1323 1323 struct resume_key_req *res_key; 1324 1324 1325 1325 rc = SMB2_ioctl(xid, tcon, persistent_fid, volatile_fid, 1326 - FSCTL_SRV_REQUEST_RESUME_KEY, true /* is_fsctl */, 1327 - NULL, 0 /* no input */, CIFSMaxBufSize, 1328 - (char **)&res_key, &ret_data_len); 1326 + FSCTL_SRV_REQUEST_RESUME_KEY, NULL, 0 /* no input */, 1327 + CIFSMaxBufSize, (char **)&res_key, &ret_data_len); 1329 1328 1330 1329 if (rc == -EOPNOTSUPP) { 1331 1330 pr_warn_once("Server share %s does not support copy range\n", tcon->treeName); ··· 1466 1467 rqst[1].rq_nvec = SMB2_IOCTL_IOV_SIZE; 1467 1468 1468 1469 rc = SMB2_ioctl_init(tcon, server, &rqst[1], COMPOUND_FID, COMPOUND_FID, 1469 - qi.info_type, true, buffer, qi.output_buffer_length, 1470 + qi.info_type, buffer, qi.output_buffer_length, 1470 1471 CIFSMaxBufSize - MAX_SMB2_CREATE_RESPONSE_SIZE - 1471 1472 MAX_SMB2_CLOSE_RESPONSE_SIZE); 1472 1473 free_req1_func = SMB2_ioctl_free; ··· 1642 1643 retbuf = NULL; 1643 1644 rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid, 1644 1645 trgtfile->fid.volatile_fid, FSCTL_SRV_COPYCHUNK_WRITE, 1645 - true /* is_fsctl */, (char *)pcchunk, 1646 - sizeof(struct copychunk_ioctl), CIFSMaxBufSize, 1647 - (char **)&retbuf, &ret_data_len); 1646 + (char *)pcchunk, sizeof(struct copychunk_ioctl), 1647 + CIFSMaxBufSize, (char **)&retbuf, &ret_data_len); 1648 1648 if (rc == 0) { 1649 1649 if (ret_data_len != 1650 1650 sizeof(struct copychunk_ioctl_rsp)) { ··· 1803 1805 1804 1806 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, 1805 1807 cfile->fid.volatile_fid, FSCTL_SET_SPARSE, 1806 - true /* is_fctl */, 1807 1808 &setsparse, 1, CIFSMaxBufSize, NULL, NULL); 1808 1809 if (rc) { 1809 1810 tcon->broken_sparse_sup = true; ··· 1885 1888 rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid, 1886 1889 trgtfile->fid.volatile_fid, 1887 1890 FSCTL_DUPLICATE_EXTENTS_TO_FILE, 1888 - true /* is_fsctl */, 1889 1891 (char *)&dup_ext_buf, 1890 1892 sizeof(struct duplicate_extents_to_file), 1891 1893 CIFSMaxBufSize, NULL, ··· 1919 1923 return SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, 1920 1924 cfile->fid.volatile_fid, 1921 1925 FSCTL_SET_INTEGRITY_INFORMATION, 1922 - true /* is_fsctl */, 1923 1926 (char *)&integr_info, 1924 1927 sizeof(struct fsctl_set_integrity_information_req), 1925 1928 CIFSMaxBufSize, NULL, ··· 1971 1976 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, 1972 1977 cfile->fid.volatile_fid, 1973 1978 FSCTL_SRV_ENUMERATE_SNAPSHOTS, 1974 - true /* is_fsctl */, 1975 1979 NULL, 0 /* no input data */, max_response_size, 1976 1980 (char **)&retbuf, 1977 1981 &ret_data_len); ··· 2693 2699 do { 2694 2700 rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID, 2695 2701 FSCTL_DFS_GET_REFERRALS, 2696 - true /* is_fsctl */, 2697 2702 (char *)dfs_req, dfs_req_size, CIFSMaxBufSize, 2698 2703 (char **)&dfs_rsp, &dfs_rsp_size); 2699 2704 if (!is_retryable_error(rc)) ··· 2899 2906 2900 2907 rc = SMB2_ioctl_init(tcon, server, 2901 2908 &rqst[1], fid.persistent_fid, 2902 - fid.volatile_fid, FSCTL_GET_REPARSE_POINT, 2903 - true /* is_fctl */, NULL, 0, 2909 + fid.volatile_fid, FSCTL_GET_REPARSE_POINT, NULL, 0, 2904 2910 CIFSMaxBufSize - 2905 2911 MAX_SMB2_CREATE_RESPONSE_SIZE - 2906 2912 MAX_SMB2_CLOSE_RESPONSE_SIZE); ··· 3079 3087 3080 3088 rc = SMB2_ioctl_init(tcon, server, 3081 3089 &rqst[1], COMPOUND_FID, 3082 - COMPOUND_FID, FSCTL_GET_REPARSE_POINT, 3083 - true /* is_fctl */, NULL, 0, 3090 + COMPOUND_FID, FSCTL_GET_REPARSE_POINT, NULL, 0, 3084 3091 CIFSMaxBufSize - 3085 3092 MAX_SMB2_CREATE_RESPONSE_SIZE - 3086 3093 MAX_SMB2_CLOSE_RESPONSE_SIZE); ··· 3349 3358 fsctl_buf.BeyondFinalZero = cpu_to_le64(offset + len); 3350 3359 3351 3360 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, 3352 - cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA, true, 3361 + cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA, 3353 3362 (char *)&fsctl_buf, 3354 3363 sizeof(struct file_zero_data_information), 3355 3364 0, NULL, NULL); ··· 3412 3421 3413 3422 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, 3414 3423 cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA, 3415 - true /* is_fctl */, (char *)&fsctl_buf, 3424 + (char *)&fsctl_buf, 3416 3425 sizeof(struct file_zero_data_information), 3417 3426 CIFSMaxBufSize, NULL, NULL); 3418 3427 free_xid(xid); ··· 3472 3481 in_data.length = cpu_to_le64(len); 3473 3482 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, 3474 3483 cfile->fid.volatile_fid, 3475 - FSCTL_QUERY_ALLOCATED_RANGES, true, 3484 + FSCTL_QUERY_ALLOCATED_RANGES, 3476 3485 (char *)&in_data, sizeof(in_data), 3477 3486 1024 * sizeof(struct file_allocated_range_buffer), 3478 3487 (char **)&out_data, &out_data_len); ··· 3793 3802 3794 3803 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, 3795 3804 cfile->fid.volatile_fid, 3796 - FSCTL_QUERY_ALLOCATED_RANGES, true, 3805 + FSCTL_QUERY_ALLOCATED_RANGES, 3797 3806 (char *)&in_data, sizeof(in_data), 3798 3807 sizeof(struct file_allocated_range_buffer), 3799 3808 (char **)&out_data, &out_data_len); ··· 3853 3862 3854 3863 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, 3855 3864 cfile->fid.volatile_fid, 3856 - FSCTL_QUERY_ALLOCATED_RANGES, true, 3865 + FSCTL_QUERY_ALLOCATED_RANGES, 3857 3866 (char *)&in_data, sizeof(in_data), 3858 3867 1024 * sizeof(struct file_allocated_range_buffer), 3859 3868 (char **)&out_data, &out_data_len);
+10 -12
fs/cifs/smb2pdu.c
··· 1173 1173 } 1174 1174 1175 1175 rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID, 1176 - FSCTL_VALIDATE_NEGOTIATE_INFO, true /* is_fsctl */, 1176 + FSCTL_VALIDATE_NEGOTIATE_INFO, 1177 1177 (char *)pneg_inbuf, inbuflen, CIFSMaxBufSize, 1178 1178 (char **)&pneg_rsp, &rsplen); 1179 1179 if (rc == -EOPNOTSUPP) { ··· 1928 1928 tcon->capabilities = rsp->Capabilities; /* we keep caps little endian */ 1929 1929 tcon->maximal_access = le32_to_cpu(rsp->MaximalAccess); 1930 1930 tcon->tid = le32_to_cpu(rsp->hdr.Id.SyncId.TreeId); 1931 - strlcpy(tcon->treeName, tree, sizeof(tcon->treeName)); 1931 + strscpy(tcon->treeName, tree, sizeof(tcon->treeName)); 1932 1932 1933 1933 if ((rsp->Capabilities & SMB2_SHARE_CAP_DFS) && 1934 1934 ((tcon->share_flags & SHI1005_FLAGS_DFS) == 0)) ··· 3056 3056 SMB2_ioctl_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server, 3057 3057 struct smb_rqst *rqst, 3058 3058 u64 persistent_fid, u64 volatile_fid, u32 opcode, 3059 - bool is_fsctl, char *in_data, u32 indatalen, 3059 + char *in_data, u32 indatalen, 3060 3060 __u32 max_response_size) 3061 3061 { 3062 3062 struct smb2_ioctl_req *req; ··· 3131 3131 req->hdr.CreditCharge = 3132 3132 cpu_to_le16(DIV_ROUND_UP(max(indatalen, max_response_size), 3133 3133 SMB2_MAX_BUFFER_SIZE)); 3134 - if (is_fsctl) 3135 - req->Flags = cpu_to_le32(SMB2_0_IOCTL_IS_FSCTL); 3136 - else 3137 - req->Flags = 0; 3134 + /* always an FSCTL (for now) */ 3135 + req->Flags = cpu_to_le32(SMB2_0_IOCTL_IS_FSCTL); 3138 3136 3139 3137 /* validate negotiate request must be signed - see MS-SMB2 3.2.5.5 */ 3140 3138 if (opcode == FSCTL_VALIDATE_NEGOTIATE_INFO) ··· 3159 3161 */ 3160 3162 int 3161 3163 SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, 3162 - u64 volatile_fid, u32 opcode, bool is_fsctl, 3163 - char *in_data, u32 indatalen, u32 max_out_data_len, 3164 - char **out_data, u32 *plen /* returned data len */) 3164 + u64 volatile_fid, u32 opcode, char *in_data, u32 indatalen, 3165 + u32 max_out_data_len, char **out_data, 3166 + u32 *plen /* returned data len */) 3165 3167 { 3166 3168 struct smb_rqst rqst; 3167 3169 struct smb2_ioctl_rsp *rsp = NULL; ··· 3203 3205 3204 3206 rc = SMB2_ioctl_init(tcon, server, 3205 3207 &rqst, persistent_fid, volatile_fid, opcode, 3206 - is_fsctl, in_data, indatalen, max_out_data_len); 3208 + in_data, indatalen, max_out_data_len); 3207 3209 if (rc) 3208 3210 goto ioctl_exit; 3209 3211 ··· 3295 3297 cpu_to_le16(COMPRESSION_FORMAT_DEFAULT); 3296 3298 3297 3299 rc = SMB2_ioctl(xid, tcon, persistent_fid, volatile_fid, 3298 - FSCTL_SET_COMPRESSION, true /* is_fsctl */, 3300 + FSCTL_SET_COMPRESSION, 3299 3301 (char *)&fsctl_input /* data input */, 3300 3302 2 /* in data len */, CIFSMaxBufSize /* max out data */, 3301 3303 &ret_data /* out data */, NULL);
+3 -3
fs/cifs/smb2proto.h
··· 23 23 extern int map_smb2_to_linux_error(char *buf, bool log_err); 24 24 extern int smb2_check_message(char *buf, unsigned int length, 25 25 struct TCP_Server_Info *server); 26 - extern unsigned int smb2_calc_size(void *buf, struct TCP_Server_Info *server); 26 + extern unsigned int smb2_calc_size(void *buf); 27 27 extern char *smb2_get_data_area_len(int *off, int *len, 28 28 struct smb2_hdr *shdr); 29 29 extern __le16 *cifs_convert_path_to_utf16(const char *from, ··· 137 137 extern void SMB2_open_free(struct smb_rqst *rqst); 138 138 extern int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, 139 139 u64 persistent_fid, u64 volatile_fid, u32 opcode, 140 - bool is_fsctl, char *in_data, u32 indatalen, u32 maxoutlen, 140 + char *in_data, u32 indatalen, u32 maxoutlen, 141 141 char **out_data, u32 *plen /* returned data len */); 142 142 extern int SMB2_ioctl_init(struct cifs_tcon *tcon, 143 143 struct TCP_Server_Info *server, 144 144 struct smb_rqst *rqst, 145 145 u64 persistent_fid, u64 volatile_fid, u32 opcode, 146 - bool is_fsctl, char *in_data, u32 indatalen, 146 + char *in_data, u32 indatalen, 147 147 __u32 max_response_size); 148 148 extern void SMB2_ioctl_free(struct smb_rqst *rqst); 149 149 extern int SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,