Skip to content

Commit 0fcfced

Browse files
committed
dmaengine: idxd: Fix possible Use-After-Free in irq_process_work_list
jira VULN-8254 cve CVE-2024-40956 commit-author Li RongQing <lirongqing@baidu.com> commit e3215de Use list_for_each_entry_safe() to allow iterating through the list and deleting the entry in the iteration process. The descriptor is freed via idxd_desc_complete() and there's a slight chance may cause issue for the list iterator when the descriptor is reused by another thread without it being deleted from the list. Fixes: 16e19e1 ("dmaengine: idxd: Fix list corruption in description completion") Signed-off-by: Li RongQing <lirongqing@baidu.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Fenghua Yu <fenghua.yu@intel.com> Link: https://lore.kernel.org/r/20240603012444.11902-1-lirongqing@baidu.com Signed-off-by: Vinod Koul <vkoul@kernel.org> (cherry picked from commit e3215de) Signed-off-by: David Gomez <dgomez@ciq.com>
1 parent 053dedd commit 0fcfced

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/dma/idxd/irq.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,13 @@ static void irq_process_work_list(struct idxd_irq_entry *irq_entry)
460460

461461
spin_unlock(&irq_entry->list_lock);
462462

463-
list_for_each_entry(desc, &flist, list) {
463+
list_for_each_entry_safe(desc, n, &flist, list) {
464464
/*
465465
* Check against the original status as ABORT is software defined
466466
* and 0xff, which DSA_COMP_STATUS_MASK can mask out.
467467
*/
468+
list_del(&desc->list);
469+
468470
if (unlikely(desc->completion->status == IDXD_COMP_DESC_ABORT)) {
469471
idxd_dma_complete_txd(desc, IDXD_COMPLETE_ABORT, true);
470472
continue;

0 commit comments

Comments
 (0)