smb: client: free partially allocated transform folio queue
Subsystems (2)
PATCH 1/1 smb: client: free partially allocated transform folio queue
netfs_alloc_folioq_buffer() may leave a partially allocated folio queue attached to the caller's buffer pointer when it returns an error.
smb3_init_transform_rq() stores the buffer in the request only after allocation succeeds, so the common error path cannot free a partial allocation. Store the buffer pointer before checking the return value so err_free releases it.
--- fs/smb/client/smb2ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/smb2ops.c +1 -1
@@ -4882,10 +4882,10 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst,size_t cur_size =0 ; rc =netfs_alloc_folioq_buffer (NULL , &buffer, &cur_size, size,GFP_NOFS ); + new->rq_buffer = buffer;if (rc <0 ) goto err_free; - new->rq_buffer = buffer;iov_iter_folio_queue (&new->rq_iter,ITER_SOURCE , buffer,0 ,0 , size);
Signature · 1 line
2.51.0
Hi,
Ping. Could someone please take a look at this patch?
Thanks,
Yichong
Quoted 29 lines · Yichong Chen
netfs_alloc_folioq_buffer()may leave a partially allocated folio queue attached to the caller's buffer pointer when it returns an error.
smb3_init_transform_rq()stores the buffer in the request only after allocation succeeds, so the common error path cannot free a partial allocation. Store the buffer pointer before checking the return value soerr_freereleases it.Signed-off-by Yichong Chen <[email protected]>--- fs/smb/client/smb2ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/smb/client/smb2ops.c +1
-1@@ -4882,10 +4882,10 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst,size_t cur_size =0 ; rc =netfs_alloc_folioq_buffer (NULL , &buffer, &cur_size, size,GFP_NOFS ); + new->rq_buffer = buffer;if (rc <0 ) goto err_free; - new->rq_buffer = buffer;iov_iter_folio_queue (&new->rq_iter,ITER_SOURCE , buffer,0 ,0 , size);
Signature · 3 lines
ChenXiaoSong <[email protected]> Chinese Homepage: https://chenxiaosong.com English Homepage: https://chenxiaosong.com/en
Steve French
AppliedMerged into cifs-2.6.git for-next
Quoted 40 lines · ChenXiaoSong
Reviewed-by ChenXiaoSong <[email protected]>Quoted 19 lines · Yichong Chen
netfs_alloc_folioq_buffer()may leave a partially allocated folio queue attached to the caller's buffer pointer when it returns an error.
smb3_init_transform_rq()stores the buffer in the request only after allocation succeeds, so the common error path cannot free a partial allocation. Store the buffer pointer before checking the return value soerr_freereleases it.Signed-off-by Yichong Chen <[email protected]>--- fs/smb/client/smb2ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/smb/client/smb2ops.c +0
-0@@ -4882,10 +4882,10 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst,size_t cur_size =0 ;fs/smb/client/smb2ops.c smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst, · line 4891
Quoted 10 lines
fs/smb/client/smb2ops.c +1
-1rc =netfs_alloc_folioq_buffer (NULL , &buffer, &cur_size, size,GFP_NOFS ); + new->rq_buffer = buffer;if (rc <0 ) goto err_free; - new->rq_buffer = buffer;iov_iter_folio_queue (&new->rq_iter,ITER_SOURCE , buffer,0 ,0 , size);--
ChenXiaoSong <[email protected]>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en
Signature · 3 lines
Thanks, Steve