@@ -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 ;
@@ -3596,8 +3601,13 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
3596
3601
struct smb2_query_info_req * req ;
3597
3602
struct kvec * iov = rqst -> rq_iov ;
3598
3603
unsigned int total_len ;
3604
+ size_t len ;
3599
3605
int rc ;
3600
3606
3607
+ if (unlikely (check_add_overflow (input_len , sizeof (* req ), & len ) ||
3608
+ len > CIFSMaxBufSize ))
3609
+ return - EINVAL ;
3610
+
3601
3611
rc = smb2_plain_req_init (SMB2_QUERY_INFO , tcon , server ,
3602
3612
(void * * ) & req , & total_len );
3603
3613
if (rc )
@@ -3619,15 +3629,15 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
3619
3629
3620
3630
iov [0 ].iov_base = (char * )req ;
3621
3631
/* 1 for Buffer */
3622
- iov [0 ].iov_len = total_len - 1 + input_len ;
3632
+ iov [0 ].iov_len = len ;
3623
3633
return 0 ;
3624
3634
}
3625
3635
3626
3636
void
3627
3637
SMB2_query_info_free (struct smb_rqst * rqst )
3628
3638
{
3629
3639
if (rqst && rqst -> rq_iov )
3630
- cifs_small_buf_release (rqst -> rq_iov [0 ].iov_base ); /* request */
3640
+ cifs_buf_release (rqst -> rq_iov [0 ].iov_base ); /* request */
3631
3641
}
3632
3642
3633
3643
static int
@@ -5519,6 +5529,11 @@ build_qfs_info_req(struct kvec *iov, struct cifs_tcon *tcon,
5519
5529
return 0 ;
5520
5530
}
5521
5531
5532
+ static inline void free_qfs_info_req (struct kvec * iov )
5533
+ {
5534
+ cifs_buf_release (iov -> iov_base );
5535
+ }
5536
+
5522
5537
int
5523
5538
SMB311_posix_qfs_info (const unsigned int xid , struct cifs_tcon * tcon ,
5524
5539
u64 persistent_fid , u64 volatile_fid , struct kstatfs * fsdata )
@@ -5550,7 +5565,7 @@ SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon,
5550
5565
5551
5566
rc = cifs_send_recv (xid , ses , server ,
5552
5567
& rqst , & resp_buftype , flags , & rsp_iov );
5553
- cifs_small_buf_release ( iov . iov_base );
5568
+ free_qfs_info_req ( & iov );
5554
5569
if (rc ) {
5555
5570
cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
5556
5571
goto posix_qfsinf_exit ;
@@ -5601,7 +5616,7 @@ SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon,
5601
5616
5602
5617
rc = cifs_send_recv (xid , ses , server ,
5603
5618
& rqst , & resp_buftype , flags , & rsp_iov );
5604
- cifs_small_buf_release ( iov . iov_base );
5619
+ free_qfs_info_req ( & iov );
5605
5620
if (rc ) {
5606
5621
cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
5607
5622
goto qfsinf_exit ;
@@ -5668,7 +5683,7 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
5668
5683
5669
5684
rc = cifs_send_recv (xid , ses , server ,
5670
5685
& rqst , & resp_buftype , flags , & rsp_iov );
5671
- cifs_small_buf_release ( iov . iov_base );
5686
+ free_qfs_info_req ( & iov );
5672
5687
if (rc ) {
5673
5688
cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
5674
5689
goto qfsattr_exit ;
0 commit comments