Message ID | 20221013071035.2890124-3-yebin10@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | fix potential wild-ptr-deref in 'smb3_free_compound_rqst' | expand |
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 180f0260cbc4..a1b47ce4ea15 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -4467,7 +4467,6 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst, goto err_free; nrq->rq_pages = pages; - nrq->rq_npages = npages; nrq->rq_offset = orq->rq_offset; nrq->rq_pagesz = orq->rq_pagesz; nrq->rq_tailsz = orq->rq_tailsz; @@ -4480,6 +4479,7 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst, pages[j] = alloc_page(GFP_KERNEL|__GFP_HIGHMEM); if (!pages[j]) goto err_free; + nrq->rq_npages++; } /* copy pages form the old */
As 'smb3_init_transform_rq' first set 'new_rq[i].rq_npages', then allocate page, if allocate page failed will call 'smb3_free_compound_rqst' to free page. However, there may only allocate part of 'rq_npages' pages which will lead to wild-ptr-deref when free pages. To solve above issue just increase 'new_rq[i].rq_npages' after allocate page success. Signed-off-by: Ye Bin <yebin10@huawei.com> --- fs/cifs/smb2ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)