@@ -471,10 +471,15 @@ static int __smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
471471 void * * request_buf , unsigned int * total_len )
472472{
473473 /* 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 :
475477 * request_buf = cifs_buf_get ();
476- else
478+ break ;
479+ default :
477480 * request_buf = cifs_small_buf_get ();
481+ break ;
482+ }
478483 if (* request_buf == NULL ) {
479484 /* BB should we add a retry in here if not a writepage? */
480485 return - ENOMEM ;
@@ -3596,8 +3601,13 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
35963601 struct smb2_query_info_req * req ;
35973602 struct kvec * iov = rqst -> rq_iov ;
35983603 unsigned int total_len ;
3604+ size_t len ;
35993605 int rc ;
36003606
3607+ if (unlikely (check_add_overflow (input_len , sizeof (* req ), & len ) ||
3608+ len > CIFSMaxBufSize ))
3609+ return - EINVAL ;
3610+
36013611 rc = smb2_plain_req_init (SMB2_QUERY_INFO , tcon , server ,
36023612 (void * * ) & req , & total_len );
36033613 if (rc )
@@ -3619,15 +3629,15 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
36193629
36203630 iov [0 ].iov_base = (char * )req ;
36213631 /* 1 for Buffer */
3622- iov [0 ].iov_len = total_len - 1 + input_len ;
3632+ iov [0 ].iov_len = len ;
36233633 return 0 ;
36243634}
36253635
36263636void
36273637SMB2_query_info_free (struct smb_rqst * rqst )
36283638{
36293639 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 */
36313641}
36323642
36333643static int
@@ -5519,6 +5529,11 @@ build_qfs_info_req(struct kvec *iov, struct cifs_tcon *tcon,
55195529 return 0 ;
55205530}
55215531
5532+ static inline void free_qfs_info_req (struct kvec * iov )
5533+ {
5534+ cifs_buf_release (iov -> iov_base );
5535+ }
5536+
55225537int
55235538SMB311_posix_qfs_info (const unsigned int xid , struct cifs_tcon * tcon ,
55245539 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,
55505565
55515566 rc = cifs_send_recv (xid , ses , server ,
55525567 & rqst , & resp_buftype , flags , & rsp_iov );
5553- cifs_small_buf_release ( iov . iov_base );
5568+ free_qfs_info_req ( & iov );
55545569 if (rc ) {
55555570 cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
55565571 goto posix_qfsinf_exit ;
@@ -5601,7 +5616,7 @@ SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon,
56015616
56025617 rc = cifs_send_recv (xid , ses , server ,
56035618 & rqst , & resp_buftype , flags , & rsp_iov );
5604- cifs_small_buf_release ( iov . iov_base );
5619+ free_qfs_info_req ( & iov );
56055620 if (rc ) {
56065621 cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
56075622 goto qfsinf_exit ;
@@ -5668,7 +5683,7 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
56685683
56695684 rc = cifs_send_recv (xid , ses , server ,
56705685 & rqst , & resp_buftype , flags , & rsp_iov );
5671- cifs_small_buf_release ( iov . iov_base );
5686+ free_qfs_info_req ( & iov );
56725687 if (rc ) {
56735688 cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
56745689 goto qfsattr_exit ;
0 commit comments