@@ -372,10 +372,15 @@ static int __smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
372372 void * * request_buf , unsigned int * total_len )
373373{
374374 /* BB eventually switch this to SMB2 specific small buf size */
375- if (smb2_command == SMB2_SET_INFO )
375+ switch (smb2_command ) {
376+ case SMB2_SET_INFO :
377+ case SMB2_QUERY_INFO :
376378 * request_buf = cifs_buf_get ();
377- else
379+ break ;
380+ default :
378381 * request_buf = cifs_small_buf_get ();
382+ break ;
383+ }
379384 if (* request_buf == NULL ) {
380385 /* BB should we add a retry in here if not a writepage? */
381386 return - ENOMEM ;
@@ -3523,8 +3528,13 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
35233528 struct smb2_query_info_req * req ;
35243529 struct kvec * iov = rqst -> rq_iov ;
35253530 unsigned int total_len ;
3531+ size_t len ;
35263532 int rc ;
35273533
3534+ if (unlikely (check_add_overflow (input_len , sizeof (* req ), & len ) ||
3535+ len > CIFSMaxBufSize ))
3536+ return - EINVAL ;
3537+
35283538 rc = smb2_plain_req_init (SMB2_QUERY_INFO , tcon , server ,
35293539 (void * * ) & req , & total_len );
35303540 if (rc )
@@ -3546,15 +3556,15 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
35463556
35473557 iov [0 ].iov_base = (char * )req ;
35483558 /* 1 for Buffer */
3549- iov [0 ].iov_len = total_len - 1 + input_len ;
3559+ iov [0 ].iov_len = len ;
35503560 return 0 ;
35513561}
35523562
35533563void
35543564SMB2_query_info_free (struct smb_rqst * rqst )
35553565{
35563566 if (rqst && rqst -> rq_iov )
3557- cifs_small_buf_release (rqst -> rq_iov [0 ].iov_base ); /* request */
3567+ cifs_buf_release (rqst -> rq_iov [0 ].iov_base ); /* request */
35583568}
35593569
35603570static int
@@ -5439,6 +5449,11 @@ build_qfs_info_req(struct kvec *iov, struct cifs_tcon *tcon,
54395449 return 0 ;
54405450}
54415451
5452+ static inline void free_qfs_info_req (struct kvec * iov )
5453+ {
5454+ cifs_buf_release (iov -> iov_base );
5455+ }
5456+
54425457int
54435458SMB311_posix_qfs_info (const unsigned int xid , struct cifs_tcon * tcon ,
54445459 u64 persistent_fid , u64 volatile_fid , struct kstatfs * fsdata )
@@ -5470,7 +5485,7 @@ SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon,
54705485
54715486 rc = cifs_send_recv (xid , ses , server ,
54725487 & rqst , & resp_buftype , flags , & rsp_iov );
5473- cifs_small_buf_release ( iov . iov_base );
5488+ free_qfs_info_req ( & iov );
54745489 if (rc ) {
54755490 cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
54765491 goto posix_qfsinf_exit ;
@@ -5521,7 +5536,7 @@ SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon,
55215536
55225537 rc = cifs_send_recv (xid , ses , server ,
55235538 & rqst , & resp_buftype , flags , & rsp_iov );
5524- cifs_small_buf_release ( iov . iov_base );
5539+ free_qfs_info_req ( & iov );
55255540 if (rc ) {
55265541 cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
55275542 goto qfsinf_exit ;
@@ -5588,7 +5603,7 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
55885603
55895604 rc = cifs_send_recv (xid , ses , server ,
55905605 & rqst , & resp_buftype , flags , & rsp_iov );
5591- cifs_small_buf_release ( iov . iov_base );
5606+ free_qfs_info_req ( & iov );
55925607 if (rc ) {
55935608 cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
55945609 goto qfsattr_exit ;
0 commit comments