@@ -373,10 +373,15 @@ static int __smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
373373 void * * request_buf , unsigned int * total_len )
374374{
375375 /* BB eventually switch this to SMB2 specific small buf size */
376- if (smb2_command == SMB2_SET_INFO )
376+ switch (smb2_command ) {
377+ case SMB2_SET_INFO :
378+ case SMB2_QUERY_INFO :
377379 * request_buf = cifs_buf_get ();
378- else
380+ break ;
381+ default :
379382 * request_buf = cifs_small_buf_get ();
383+ break ;
384+ }
380385 if (* request_buf == NULL ) {
381386 /* BB should we add a retry in here if not a writepage? */
382387 return - ENOMEM ;
@@ -3346,8 +3351,13 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
33463351 struct smb2_query_info_req * req ;
33473352 struct kvec * iov = rqst -> rq_iov ;
33483353 unsigned int total_len ;
3354+ size_t len ;
33493355 int rc ;
33503356
3357+ if (unlikely (check_add_overflow (input_len , sizeof (* req ), & len ) ||
3358+ len > CIFSMaxBufSize ))
3359+ return - EINVAL ;
3360+
33513361 rc = smb2_plain_req_init (SMB2_QUERY_INFO , tcon , server ,
33523362 (void * * ) & req , & total_len );
33533363 if (rc )
@@ -3369,15 +3379,15 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
33693379
33703380 iov [0 ].iov_base = (char * )req ;
33713381 /* 1 for Buffer */
3372- iov [0 ].iov_len = total_len - 1 + input_len ;
3382+ iov [0 ].iov_len = len ;
33733383 return 0 ;
33743384}
33753385
33763386void
33773387SMB2_query_info_free (struct smb_rqst * rqst )
33783388{
33793389 if (rqst && rqst -> rq_iov )
3380- cifs_small_buf_release (rqst -> rq_iov [0 ].iov_base ); /* request */
3390+ cifs_buf_release (rqst -> rq_iov [0 ].iov_base ); /* request */
33813391}
33823392
33833393static int
@@ -5104,6 +5114,11 @@ build_qfs_info_req(struct kvec *iov, struct cifs_tcon *tcon,
51045114 return 0 ;
51055115}
51065116
5117+ static inline void free_qfs_info_req (struct kvec * iov )
5118+ {
5119+ cifs_buf_release (iov -> iov_base );
5120+ }
5121+
51075122int
51085123SMB311_posix_qfs_info (const unsigned int xid , struct cifs_tcon * tcon ,
51095124 u64 persistent_fid , u64 volatile_fid , struct kstatfs * fsdata )
@@ -5135,7 +5150,7 @@ SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon,
51355150
51365151 rc = cifs_send_recv (xid , ses , server ,
51375152 & rqst , & resp_buftype , flags , & rsp_iov );
5138- cifs_small_buf_release ( iov . iov_base );
5153+ free_qfs_info_req ( & iov );
51395154 if (rc ) {
51405155 cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
51415156 goto posix_qfsinf_exit ;
@@ -5186,7 +5201,7 @@ SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon,
51865201
51875202 rc = cifs_send_recv (xid , ses , server ,
51885203 & rqst , & resp_buftype , flags , & rsp_iov );
5189- cifs_small_buf_release ( iov . iov_base );
5204+ free_qfs_info_req ( & iov );
51905205 if (rc ) {
51915206 cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
51925207 goto qfsinf_exit ;
@@ -5253,7 +5268,7 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
52535268
52545269 rc = cifs_send_recv (xid , ses , server ,
52555270 & rqst , & resp_buftype , flags , & rsp_iov );
5256- cifs_small_buf_release ( iov . iov_base );
5271+ free_qfs_info_req ( & iov );
52575272 if (rc ) {
52585273 cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
52595274 goto qfsattr_exit ;
0 commit comments