@@ -364,10 +364,15 @@ static int __smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
364
364
void * * request_buf , unsigned int * total_len )
365
365
{
366
366
/* BB eventually switch this to SMB2 specific small buf size */
367
- if (smb2_command == SMB2_SET_INFO )
367
+ switch (smb2_command ) {
368
+ case SMB2_SET_INFO :
369
+ case SMB2_QUERY_INFO :
368
370
* request_buf = cifs_buf_get ();
369
- else
371
+ break ;
372
+ default :
370
373
* request_buf = cifs_small_buf_get ();
374
+ break ;
375
+ }
371
376
if (* request_buf == NULL ) {
372
377
/* BB should we add a retry in here if not a writepage? */
373
378
return - ENOMEM ;
@@ -3415,8 +3420,13 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
3415
3420
struct smb2_query_info_req * req ;
3416
3421
struct kvec * iov = rqst -> rq_iov ;
3417
3422
unsigned int total_len ;
3423
+ size_t len ;
3418
3424
int rc ;
3419
3425
3426
+ if (unlikely (check_add_overflow (input_len , sizeof (* req ), & len ) ||
3427
+ len > CIFSMaxBufSize ))
3428
+ return - EINVAL ;
3429
+
3420
3430
rc = smb2_plain_req_init (SMB2_QUERY_INFO , tcon , server ,
3421
3431
(void * * ) & req , & total_len );
3422
3432
if (rc )
@@ -3438,15 +3448,15 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
3438
3448
3439
3449
iov [0 ].iov_base = (char * )req ;
3440
3450
/* 1 for Buffer */
3441
- iov [0 ].iov_len = total_len - 1 + input_len ;
3451
+ iov [0 ].iov_len = len ;
3442
3452
return 0 ;
3443
3453
}
3444
3454
3445
3455
void
3446
3456
SMB2_query_info_free (struct smb_rqst * rqst )
3447
3457
{
3448
3458
if (rqst && rqst -> rq_iov )
3449
- cifs_small_buf_release (rqst -> rq_iov [0 ].iov_base ); /* request */
3459
+ cifs_buf_release (rqst -> rq_iov [0 ].iov_base ); /* request */
3450
3460
}
3451
3461
3452
3462
static int
@@ -5176,6 +5186,11 @@ build_qfs_info_req(struct kvec *iov, struct cifs_tcon *tcon,
5176
5186
return 0 ;
5177
5187
}
5178
5188
5189
+ static inline void free_qfs_info_req (struct kvec * iov )
5190
+ {
5191
+ cifs_buf_release (iov -> iov_base );
5192
+ }
5193
+
5179
5194
int
5180
5195
SMB311_posix_qfs_info (const unsigned int xid , struct cifs_tcon * tcon ,
5181
5196
u64 persistent_fid , u64 volatile_fid , struct kstatfs * fsdata )
@@ -5207,7 +5222,7 @@ SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon,
5207
5222
5208
5223
rc = cifs_send_recv (xid , ses , server ,
5209
5224
& rqst , & resp_buftype , flags , & rsp_iov );
5210
- cifs_small_buf_release ( iov . iov_base );
5225
+ free_qfs_info_req ( & iov );
5211
5226
if (rc ) {
5212
5227
cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
5213
5228
goto posix_qfsinf_exit ;
@@ -5258,7 +5273,7 @@ SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon,
5258
5273
5259
5274
rc = cifs_send_recv (xid , ses , server ,
5260
5275
& rqst , & resp_buftype , flags , & rsp_iov );
5261
- cifs_small_buf_release ( iov . iov_base );
5276
+ free_qfs_info_req ( & iov );
5262
5277
if (rc ) {
5263
5278
cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
5264
5279
goto qfsinf_exit ;
@@ -5325,7 +5340,7 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
5325
5340
5326
5341
rc = cifs_send_recv (xid , ses , server ,
5327
5342
& rqst , & resp_buftype , flags , & rsp_iov );
5328
- cifs_small_buf_release ( iov . iov_base );
5343
+ free_qfs_info_req ( & iov );
5329
5344
if (rc ) {
5330
5345
cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
5331
5346
goto qfsattr_exit ;
0 commit comments