@@ -376,10 +376,15 @@ static int __smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
376
376
void * * request_buf , unsigned int * total_len )
377
377
{
378
378
/* BB eventually switch this to SMB2 specific small buf size */
379
- if (smb2_command == SMB2_SET_INFO )
379
+ switch (smb2_command ) {
380
+ case SMB2_SET_INFO :
381
+ case SMB2_QUERY_INFO :
380
382
* request_buf = cifs_buf_get ();
381
- else
383
+ break ;
384
+ default :
382
385
* request_buf = cifs_small_buf_get ();
386
+ break ;
387
+ }
383
388
if (* request_buf == NULL ) {
384
389
/* BB should we add a retry in here if not a writepage? */
385
390
return - ENOMEM ;
@@ -3494,8 +3499,13 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
3494
3499
struct smb2_query_info_req * req ;
3495
3500
struct kvec * iov = rqst -> rq_iov ;
3496
3501
unsigned int total_len ;
3502
+ size_t len ;
3497
3503
int rc ;
3498
3504
3505
+ if (unlikely (check_add_overflow (input_len , sizeof (* req ), & len ) ||
3506
+ len > CIFSMaxBufSize ))
3507
+ return - EINVAL ;
3508
+
3499
3509
rc = smb2_plain_req_init (SMB2_QUERY_INFO , tcon , server ,
3500
3510
(void * * ) & req , & total_len );
3501
3511
if (rc )
@@ -3517,15 +3527,15 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
3517
3527
3518
3528
iov [0 ].iov_base = (char * )req ;
3519
3529
/* 1 for Buffer */
3520
- iov [0 ].iov_len = total_len - 1 + input_len ;
3530
+ iov [0 ].iov_len = len ;
3521
3531
return 0 ;
3522
3532
}
3523
3533
3524
3534
void
3525
3535
SMB2_query_info_free (struct smb_rqst * rqst )
3526
3536
{
3527
3537
if (rqst && rqst -> rq_iov )
3528
- cifs_small_buf_release (rqst -> rq_iov [0 ].iov_base ); /* request */
3538
+ cifs_buf_release (rqst -> rq_iov [0 ].iov_base ); /* request */
3529
3539
}
3530
3540
3531
3541
static int
@@ -5392,6 +5402,11 @@ build_qfs_info_req(struct kvec *iov, struct cifs_tcon *tcon,
5392
5402
return 0 ;
5393
5403
}
5394
5404
5405
+ static inline void free_qfs_info_req (struct kvec * iov )
5406
+ {
5407
+ cifs_buf_release (iov -> iov_base );
5408
+ }
5409
+
5395
5410
int
5396
5411
SMB311_posix_qfs_info (const unsigned int xid , struct cifs_tcon * tcon ,
5397
5412
u64 persistent_fid , u64 volatile_fid , struct kstatfs * fsdata )
@@ -5423,7 +5438,7 @@ SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon,
5423
5438
5424
5439
rc = cifs_send_recv (xid , ses , server ,
5425
5440
& rqst , & resp_buftype , flags , & rsp_iov );
5426
- cifs_small_buf_release ( iov . iov_base );
5441
+ free_qfs_info_req ( & iov );
5427
5442
if (rc ) {
5428
5443
cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
5429
5444
goto posix_qfsinf_exit ;
@@ -5474,7 +5489,7 @@ SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon,
5474
5489
5475
5490
rc = cifs_send_recv (xid , ses , server ,
5476
5491
& rqst , & resp_buftype , flags , & rsp_iov );
5477
- cifs_small_buf_release ( iov . iov_base );
5492
+ free_qfs_info_req ( & iov );
5478
5493
if (rc ) {
5479
5494
cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
5480
5495
goto qfsinf_exit ;
@@ -5541,7 +5556,7 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
5541
5556
5542
5557
rc = cifs_send_recv (xid , ses , server ,
5543
5558
& rqst , & resp_buftype , flags , & rsp_iov );
5544
- cifs_small_buf_release ( iov . iov_base );
5559
+ free_qfs_info_req ( & iov );
5545
5560
if (rc ) {
5546
5561
cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
5547
5562
goto qfsattr_exit ;
0 commit comments