Message ID | 20250110061639.1280907-4-chenridong@huaweicloud.com |
---|---|
State | New |
Headers | show |
Series | padata: fix UAF issues | expand |
On Fri, Jan 10, 2025 at 06:16:39AM +0000, Chen Ridong wrote: ... > Fixes: bbefa1dd6a6d ("crypto: pcrypt - Avoid deadlock by using per-instance padata queues") > Signed-off-by: Chen Ridong <chenridong@huawei.com> Series looks good, thanks for the persistence. Acked-by: Daniel Jordan <daniel.m.jordan@oracle.com> > diff --git a/kernel/padata.c b/kernel/padata.c ... > static void invoke_padata_reorder(struct work_struct *work) > @@ -364,6 +370,8 @@ static void invoke_padata_reorder(struct work_struct *work) > pd = container_of(work, struct parallel_data, reorder_work); > padata_reorder(pd); > local_bh_enable(); > + /* Pairs with putting the reorder_work in the serial_wq */ s/putting/getting/
On 2025/1/14 1:00, Daniel Jordan wrote: > On Fri, Jan 10, 2025 at 06:16:39AM +0000, Chen Ridong wrote: > ... >> Fixes: bbefa1dd6a6d ("crypto: pcrypt - Avoid deadlock by using per-instance padata queues") >> Signed-off-by: Chen Ridong <chenridong@huawei.com> > > Series looks good, thanks for the persistence. > Thank you for your patience. Best regards, Ridong > Acked-by: Daniel Jordan <daniel.m.jordan@oracle.com> > >> diff --git a/kernel/padata.c b/kernel/padata.c > ... >> static void invoke_padata_reorder(struct work_struct *work) >> @@ -364,6 +370,8 @@ static void invoke_padata_reorder(struct work_struct *work) >> pd = container_of(work, struct parallel_data, reorder_work); >> padata_reorder(pd); >> local_bh_enable(); >> + /* Pairs with putting the reorder_work in the serial_wq */ > > s/putting/getting/ >
diff --git a/kernel/padata.c b/kernel/padata.c index de2c02a81469..418987056340 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -352,8 +352,14 @@ static void padata_reorder(struct parallel_data *pd) smp_mb(); reorder = per_cpu_ptr(pd->reorder_list, pd->cpu); - if (!list_empty(&reorder->list) && padata_find_next(pd, false)) + if (!list_empty(&reorder->list) && padata_find_next(pd, false)) { + /* + * Other context(eg. the padata_serial_worker) can finish the request. + * To avoid UAF issue, add pd ref here, and put pd ref after reorder_work finish. + */ + padata_get_pd(pd); queue_work(pinst->serial_wq, &pd->reorder_work); + } } static void invoke_padata_reorder(struct work_struct *work) @@ -364,6 +370,8 @@ static void invoke_padata_reorder(struct work_struct *work) pd = container_of(work, struct parallel_data, reorder_work); padata_reorder(pd); local_bh_enable(); + /* Pairs with putting the reorder_work in the serial_wq */ + padata_put_pd(pd); } static void padata_serial_worker(struct work_struct *serial_work)