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

cifs: remove useless parameter 'is_fsctl' from SMB2_ioctl()

SMB2_ioctl() is always called with is_fsctl = true, so doesn't make any
sense to have it at all.

Thus, always set SMB2_0_IOCTL_IS_FSCTL flag on the request.

Also, as per MS-SMB2 3.3.5.15 "Receiving an SMB2 IOCTL Request", servers
must fail the request if the request flags is zero anyway.

Signed-off-by: Enzo Matsumiya <ematsumiya@suse.de>
Reviewed-by: Tom Talpey <tom@talpey.com>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Enzo Matsumiya and committed by
Steve French
400d0ad6 68ed1449

+24 -36
-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) {
+13 -22
fs/cifs/smb2ops.c
··· 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);
+9 -11
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) { ··· 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);
+2 -2
fs/cifs/smb2proto.h
··· 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,