@@ -471,10 +471,15 @@ static int __smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
471
471
void * * request_buf , unsigned int * total_len )
472
472
{
473
473
/* BB eventually switch this to SMB2 specific small buf size */
474
- if (smb2_command == SMB2_SET_INFO )
474
+ switch (smb2_command ) {
475
+ case SMB2_SET_INFO :
476
+ case SMB2_QUERY_INFO :
475
477
* request_buf = cifs_buf_get ();
476
- else
478
+ break ;
479
+ default :
477
480
* request_buf = cifs_small_buf_get ();
481
+ break ;
482
+ }
478
483
if (* request_buf == NULL ) {
479
484
/* BB should we add a retry in here if not a writepage? */
480
485
return - ENOMEM ;
@@ -3587,8 +3592,13 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
3587
3592
struct smb2_query_info_req * req ;
3588
3593
struct kvec * iov = rqst -> rq_iov ;
3589
3594
unsigned int total_len ;
3595
+ size_t len ;
3590
3596
int rc ;
3591
3597
3598
+ if (unlikely (check_add_overflow (input_len , sizeof (* req ), & len ) ||
3599
+ len > CIFSMaxBufSize ))
3600
+ return - EINVAL ;
3601
+
3592
3602
rc = smb2_plain_req_init (SMB2_QUERY_INFO , tcon , server ,
3593
3603
(void * * ) & req , & total_len );
3594
3604
if (rc )
@@ -3610,15 +3620,15 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
3610
3620
3611
3621
iov [0 ].iov_base = (char * )req ;
3612
3622
/* 1 for Buffer */
3613
- iov [0 ].iov_len = total_len - 1 + input_len ;
3623
+ iov [0 ].iov_len = len ;
3614
3624
return 0 ;
3615
3625
}
3616
3626
3617
3627
void
3618
3628
SMB2_query_info_free (struct smb_rqst * rqst )
3619
3629
{
3620
3630
if (rqst && rqst -> rq_iov )
3621
- cifs_small_buf_release (rqst -> rq_iov [0 ].iov_base ); /* request */
3631
+ cifs_buf_release (rqst -> rq_iov [0 ].iov_base ); /* request */
3622
3632
}
3623
3633
3624
3634
static int
@@ -5493,6 +5503,11 @@ build_qfs_info_req(struct kvec *iov, struct cifs_tcon *tcon,
5493
5503
return 0 ;
5494
5504
}
5495
5505
5506
+ static inline void free_qfs_info_req (struct kvec * iov )
5507
+ {
5508
+ cifs_buf_release (iov -> iov_base );
5509
+ }
5510
+
5496
5511
int
5497
5512
SMB311_posix_qfs_info (const unsigned int xid , struct cifs_tcon * tcon ,
5498
5513
u64 persistent_fid , u64 volatile_fid , struct kstatfs * fsdata )
@@ -5524,7 +5539,7 @@ SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon,
5524
5539
5525
5540
rc = cifs_send_recv (xid , ses , server ,
5526
5541
& rqst , & resp_buftype , flags , & rsp_iov );
5527
- cifs_small_buf_release ( iov . iov_base );
5542
+ free_qfs_info_req ( & iov );
5528
5543
if (rc ) {
5529
5544
cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
5530
5545
goto posix_qfsinf_exit ;
@@ -5575,7 +5590,7 @@ SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon,
5575
5590
5576
5591
rc = cifs_send_recv (xid , ses , server ,
5577
5592
& rqst , & resp_buftype , flags , & rsp_iov );
5578
- cifs_small_buf_release ( iov . iov_base );
5593
+ free_qfs_info_req ( & iov );
5579
5594
if (rc ) {
5580
5595
cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
5581
5596
goto qfsinf_exit ;
@@ -5642,7 +5657,7 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
5642
5657
5643
5658
rc = cifs_send_recv (xid , ses , server ,
5644
5659
& rqst , & resp_buftype , flags , & rsp_iov );
5645
- cifs_small_buf_release ( iov . iov_base );
5660
+ free_qfs_info_req ( & iov );
5646
5661
if (rc ) {
5647
5662
cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
5648
5663
goto qfsattr_exit ;
0 commit comments