@@ -373,10 +373,15 @@ static int __smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
373
373
void * * request_buf , unsigned int * total_len )
374
374
{
375
375
/* 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 :
377
379
* request_buf = cifs_buf_get ();
378
- else
380
+ break ;
381
+ default :
379
382
* request_buf = cifs_small_buf_get ();
383
+ break ;
384
+ }
380
385
if (* request_buf == NULL ) {
381
386
/* BB should we add a retry in here if not a writepage? */
382
387
return - ENOMEM ;
@@ -3346,8 +3351,13 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
3346
3351
struct smb2_query_info_req * req ;
3347
3352
struct kvec * iov = rqst -> rq_iov ;
3348
3353
unsigned int total_len ;
3354
+ size_t len ;
3349
3355
int rc ;
3350
3356
3357
+ if (unlikely (check_add_overflow (input_len , sizeof (* req ), & len ) ||
3358
+ len > CIFSMaxBufSize ))
3359
+ return - EINVAL ;
3360
+
3351
3361
rc = smb2_plain_req_init (SMB2_QUERY_INFO , tcon , server ,
3352
3362
(void * * ) & req , & total_len );
3353
3363
if (rc )
@@ -3369,15 +3379,15 @@ SMB2_query_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
3369
3379
3370
3380
iov [0 ].iov_base = (char * )req ;
3371
3381
/* 1 for Buffer */
3372
- iov [0 ].iov_len = total_len - 1 + input_len ;
3382
+ iov [0 ].iov_len = len ;
3373
3383
return 0 ;
3374
3384
}
3375
3385
3376
3386
void
3377
3387
SMB2_query_info_free (struct smb_rqst * rqst )
3378
3388
{
3379
3389
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 */
3381
3391
}
3382
3392
3383
3393
static int
@@ -5104,6 +5114,11 @@ build_qfs_info_req(struct kvec *iov, struct cifs_tcon *tcon,
5104
5114
return 0 ;
5105
5115
}
5106
5116
5117
+ static inline void free_qfs_info_req (struct kvec * iov )
5118
+ {
5119
+ cifs_buf_release (iov -> iov_base );
5120
+ }
5121
+
5107
5122
int
5108
5123
SMB311_posix_qfs_info (const unsigned int xid , struct cifs_tcon * tcon ,
5109
5124
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,
5135
5150
5136
5151
rc = cifs_send_recv (xid , ses , server ,
5137
5152
& rqst , & resp_buftype , flags , & rsp_iov );
5138
- cifs_small_buf_release ( iov . iov_base );
5153
+ free_qfs_info_req ( & iov );
5139
5154
if (rc ) {
5140
5155
cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
5141
5156
goto posix_qfsinf_exit ;
@@ -5186,7 +5201,7 @@ SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon,
5186
5201
5187
5202
rc = cifs_send_recv (xid , ses , server ,
5188
5203
& rqst , & resp_buftype , flags , & rsp_iov );
5189
- cifs_small_buf_release ( iov . iov_base );
5204
+ free_qfs_info_req ( & iov );
5190
5205
if (rc ) {
5191
5206
cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
5192
5207
goto qfsinf_exit ;
@@ -5253,7 +5268,7 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
5253
5268
5254
5269
rc = cifs_send_recv (xid , ses , server ,
5255
5270
& rqst , & resp_buftype , flags , & rsp_iov );
5256
- cifs_small_buf_release ( iov . iov_base );
5271
+ free_qfs_info_req ( & iov );
5257
5272
if (rc ) {
5258
5273
cifs_stats_fail_inc (tcon , SMB2_QUERY_INFO_HE );
5259
5274
goto qfsattr_exit ;
0 commit comments