Skip to content

Commit e3215de

Browse files
lrq-maxvinodkoul
authored andcommitted
dmaengine: idxd: Fix possible Use-After-Free in irq_process_work_list
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 <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Reviewed-by: Fenghua Yu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 462237d commit e3215de

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
@@ -611,11 +611,13 @@ static void irq_process_work_list(struct idxd_irq_entry *irq_entry)
611611

612612
spin_unlock(&irq_entry->list_lock);
613613

614-
list_for_each_entry(desc, &flist, list) {
614+
list_for_each_entry_safe(desc, n, &flist, list) {
615615
/*
616616
* Check against the original status as ABORT is software defined
617617
* and 0xff, which DSA_COMP_STATUS_MASK can mask out.
618618
*/
619+
list_del(&desc->list);
620+
619621
if (unlikely(desc->completion->status == IDXD_COMP_DESC_ABORT)) {
620622
idxd_desc_complete(desc, IDXD_COMPLETE_ABORT, true);
621623
continue;

0 commit comments

Comments
 (0)