Skip to content

Commit 400d0ad

Browse files
ematsumiyasmfrench
authored andcommitted
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 <[email protected]> Reviewed-by: Tom Talpey <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 68ed144 commit 400d0ad

File tree

4 files changed

+24
-36
lines changed

4 files changed

+24
-36
lines changed

fs/cifs/smb2file.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
6161
nr_ioctl_req.Reserved = 0;
6262
rc = SMB2_ioctl(xid, oparms->tcon, fid->persistent_fid,
6363
fid->volatile_fid, FSCTL_LMR_REQUEST_RESILIENCY,
64-
true /* is_fsctl */,
6564
(char *)&nr_ioctl_req, sizeof(nr_ioctl_req),
6665
CIFSMaxBufSize, NULL, NULL /* no return info */);
6766
if (rc == -EOPNOTSUPP) {

fs/cifs/smb2ops.c

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon)
681681
struct cifs_ses *ses = tcon->ses;
682682

683683
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,
685685
NULL /* no data input */, 0 /* no data input */,
686686
CIFSMaxBufSize, (char **)&out_buf, &ret_data_len);
687687
if (rc == -EOPNOTSUPP) {
@@ -1323,9 +1323,8 @@ SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon,
13231323
struct resume_key_req *res_key;
13241324

13251325
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);
13291328

13301329
if (rc == -EOPNOTSUPP) {
13311330
pr_warn_once("Server share %s does not support copy range\n", tcon->treeName);
@@ -1467,7 +1466,7 @@ smb2_ioctl_query_info(const unsigned int xid,
14671466
rqst[1].rq_nvec = SMB2_IOCTL_IOV_SIZE;
14681467

14691468
rc = SMB2_ioctl_init(tcon, server, &rqst[1], COMPOUND_FID, COMPOUND_FID,
1470-
qi.info_type, true, buffer, qi.output_buffer_length,
1469+
qi.info_type, buffer, qi.output_buffer_length,
14711470
CIFSMaxBufSize - MAX_SMB2_CREATE_RESPONSE_SIZE -
14721471
MAX_SMB2_CLOSE_RESPONSE_SIZE);
14731472
free_req1_func = SMB2_ioctl_free;
@@ -1643,9 +1642,8 @@ smb2_copychunk_range(const unsigned int xid,
16431642
retbuf = NULL;
16441643
rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid,
16451644
trgtfile->fid.volatile_fid, FSCTL_SRV_COPYCHUNK_WRITE,
1646-
true /* is_fsctl */, (char *)pcchunk,
1647-
sizeof(struct copychunk_ioctl), CIFSMaxBufSize,
1648-
(char **)&retbuf, &ret_data_len);
1645+
(char *)pcchunk, sizeof(struct copychunk_ioctl),
1646+
CIFSMaxBufSize, (char **)&retbuf, &ret_data_len);
16491647
if (rc == 0) {
16501648
if (ret_data_len !=
16511649
sizeof(struct copychunk_ioctl_rsp)) {
@@ -1805,7 +1803,6 @@ static bool smb2_set_sparse(const unsigned int xid, struct cifs_tcon *tcon,
18051803

18061804
rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
18071805
cfile->fid.volatile_fid, FSCTL_SET_SPARSE,
1808-
true /* is_fctl */,
18091806
&setsparse, 1, CIFSMaxBufSize, NULL, NULL);
18101807
if (rc) {
18111808
tcon->broken_sparse_sup = true;
@@ -1888,7 +1885,6 @@ smb2_duplicate_extents(const unsigned int xid,
18881885
rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid,
18891886
trgtfile->fid.volatile_fid,
18901887
FSCTL_DUPLICATE_EXTENTS_TO_FILE,
1891-
true /* is_fsctl */,
18921888
(char *)&dup_ext_buf,
18931889
sizeof(struct duplicate_extents_to_file),
18941890
CIFSMaxBufSize, NULL,
@@ -1923,7 +1919,6 @@ smb3_set_integrity(const unsigned int xid, struct cifs_tcon *tcon,
19231919
return SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
19241920
cfile->fid.volatile_fid,
19251921
FSCTL_SET_INTEGRITY_INFORMATION,
1926-
true /* is_fsctl */,
19271922
(char *)&integr_info,
19281923
sizeof(struct fsctl_set_integrity_information_req),
19291924
CIFSMaxBufSize, NULL,
@@ -1976,7 +1971,6 @@ smb3_enum_snapshots(const unsigned int xid, struct cifs_tcon *tcon,
19761971
rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
19771972
cfile->fid.volatile_fid,
19781973
FSCTL_SRV_ENUMERATE_SNAPSHOTS,
1979-
true /* is_fsctl */,
19801974
NULL, 0 /* no input data */, max_response_size,
19811975
(char **)&retbuf,
19821976
&ret_data_len);
@@ -2699,7 +2693,6 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses,
26992693
do {
27002694
rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
27012695
FSCTL_DFS_GET_REFERRALS,
2702-
true /* is_fsctl */,
27032696
(char *)dfs_req, dfs_req_size, CIFSMaxBufSize,
27042697
(char **)&dfs_rsp, &dfs_rsp_size);
27052698
if (!is_retryable_error(rc))
@@ -2906,8 +2899,7 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
29062899

29072900
rc = SMB2_ioctl_init(tcon, server,
29082901
&rqst[1], fid.persistent_fid,
2909-
fid.volatile_fid, FSCTL_GET_REPARSE_POINT,
2910-
true /* is_fctl */, NULL, 0,
2902+
fid.volatile_fid, FSCTL_GET_REPARSE_POINT, NULL, 0,
29112903
CIFSMaxBufSize -
29122904
MAX_SMB2_CREATE_RESPONSE_SIZE -
29132905
MAX_SMB2_CLOSE_RESPONSE_SIZE);
@@ -3087,8 +3079,7 @@ smb2_query_reparse_tag(const unsigned int xid, struct cifs_tcon *tcon,
30873079

30883080
rc = SMB2_ioctl_init(tcon, server,
30893081
&rqst[1], COMPOUND_FID,
3090-
COMPOUND_FID, FSCTL_GET_REPARSE_POINT,
3091-
true /* is_fctl */, NULL, 0,
3082+
COMPOUND_FID, FSCTL_GET_REPARSE_POINT, NULL, 0,
30923083
CIFSMaxBufSize -
30933084
MAX_SMB2_CREATE_RESPONSE_SIZE -
30943085
MAX_SMB2_CLOSE_RESPONSE_SIZE);
@@ -3358,7 +3349,7 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
33583349
fsctl_buf.BeyondFinalZero = cpu_to_le64(offset + len);
33593350

33603351
rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
3361-
cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA, true,
3352+
cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA,
33623353
(char *)&fsctl_buf,
33633354
sizeof(struct file_zero_data_information),
33643355
0, NULL, NULL);
@@ -3421,7 +3412,7 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon,
34213412

34223413
rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
34233414
cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA,
3424-
true /* is_fctl */, (char *)&fsctl_buf,
3415+
(char *)&fsctl_buf,
34253416
sizeof(struct file_zero_data_information),
34263417
CIFSMaxBufSize, NULL, NULL);
34273418
free_xid(xid);
@@ -3481,7 +3472,7 @@ static int smb3_simple_fallocate_range(unsigned int xid,
34813472
in_data.length = cpu_to_le64(len);
34823473
rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
34833474
cfile->fid.volatile_fid,
3484-
FSCTL_QUERY_ALLOCATED_RANGES, true,
3475+
FSCTL_QUERY_ALLOCATED_RANGES,
34853476
(char *)&in_data, sizeof(in_data),
34863477
1024 * sizeof(struct file_allocated_range_buffer),
34873478
(char **)&out_data, &out_data_len);
@@ -3802,7 +3793,7 @@ static loff_t smb3_llseek(struct file *file, struct cifs_tcon *tcon, loff_t offs
38023793

38033794
rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
38043795
cfile->fid.volatile_fid,
3805-
FSCTL_QUERY_ALLOCATED_RANGES, true,
3796+
FSCTL_QUERY_ALLOCATED_RANGES,
38063797
(char *)&in_data, sizeof(in_data),
38073798
sizeof(struct file_allocated_range_buffer),
38083799
(char **)&out_data, &out_data_len);
@@ -3862,7 +3853,7 @@ static int smb3_fiemap(struct cifs_tcon *tcon,
38623853

38633854
rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
38643855
cfile->fid.volatile_fid,
3865-
FSCTL_QUERY_ALLOCATED_RANGES, true,
3856+
FSCTL_QUERY_ALLOCATED_RANGES,
38663857
(char *)&in_data, sizeof(in_data),
38673858
1024 * sizeof(struct file_allocated_range_buffer),
38683859
(char **)&out_data, &out_data_len);

fs/cifs/smb2pdu.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
11731173
}
11741174

11751175
rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
1176-
FSCTL_VALIDATE_NEGOTIATE_INFO, true /* is_fsctl */,
1176+
FSCTL_VALIDATE_NEGOTIATE_INFO,
11771177
(char *)pneg_inbuf, inbuflen, CIFSMaxBufSize,
11781178
(char **)&pneg_rsp, &rsplen);
11791179
if (rc == -EOPNOTSUPP) {
@@ -3056,7 +3056,7 @@ int
30563056
SMB2_ioctl_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
30573057
struct smb_rqst *rqst,
30583058
u64 persistent_fid, u64 volatile_fid, u32 opcode,
3059-
bool is_fsctl, char *in_data, u32 indatalen,
3059+
char *in_data, u32 indatalen,
30603060
__u32 max_response_size)
30613061
{
30623062
struct smb2_ioctl_req *req;
@@ -3131,10 +3131,8 @@ SMB2_ioctl_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
31313131
req->hdr.CreditCharge =
31323132
cpu_to_le16(DIV_ROUND_UP(max(indatalen, max_response_size),
31333133
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);
31383136

31393137
/* validate negotiate request must be signed - see MS-SMB2 3.2.5.5 */
31403138
if (opcode == FSCTL_VALIDATE_NEGOTIATE_INFO)
@@ -3161,9 +3159,9 @@ SMB2_ioctl_free(struct smb_rqst *rqst)
31613159
*/
31623160
int
31633161
SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
3164-
u64 volatile_fid, u32 opcode, bool is_fsctl,
3165-
char *in_data, u32 indatalen, u32 max_out_data_len,
3166-
char **out_data, u32 *plen /* returned data len */)
3162+
u64 volatile_fid, u32 opcode, char *in_data, u32 indatalen,
3163+
u32 max_out_data_len, char **out_data,
3164+
u32 *plen /* returned data len */)
31673165
{
31683166
struct smb_rqst rqst;
31693167
struct smb2_ioctl_rsp *rsp = NULL;
@@ -3205,7 +3203,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
32053203

32063204
rc = SMB2_ioctl_init(tcon, server,
32073205
&rqst, persistent_fid, volatile_fid, opcode,
3208-
is_fsctl, in_data, indatalen, max_out_data_len);
3206+
in_data, indatalen, max_out_data_len);
32093207
if (rc)
32103208
goto ioctl_exit;
32113209

@@ -3297,7 +3295,7 @@ SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
32973295
cpu_to_le16(COMPRESSION_FORMAT_DEFAULT);
32983296

32993297
rc = SMB2_ioctl(xid, tcon, persistent_fid, volatile_fid,
3300-
FSCTL_SET_COMPRESSION, true /* is_fsctl */,
3298+
FSCTL_SET_COMPRESSION,
33013299
(char *)&fsctl_input /* data input */,
33023300
2 /* in data len */, CIFSMaxBufSize /* max out data */,
33033301
&ret_data /* out data */, NULL);

fs/cifs/smb2proto.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ extern int SMB2_open_init(struct cifs_tcon *tcon,
137137
extern void SMB2_open_free(struct smb_rqst *rqst);
138138
extern int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon,
139139
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,
141141
char **out_data, u32 *plen /* returned data len */);
142142
extern int SMB2_ioctl_init(struct cifs_tcon *tcon,
143143
struct TCP_Server_Info *server,
144144
struct smb_rqst *rqst,
145145
u64 persistent_fid, u64 volatile_fid, u32 opcode,
146-
bool is_fsctl, char *in_data, u32 indatalen,
146+
char *in_data, u32 indatalen,
147147
__u32 max_response_size);
148148
extern void SMB2_ioctl_free(struct smb_rqst *rqst);
149149
extern int SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,

0 commit comments

Comments
 (0)