]> Git Repo - linux.git/commitdiff
dmaengine: idxd: Fix possible Use-After-Free in irq_process_work_list
authorLi RongQing <[email protected]>
Mon, 3 Jun 2024 01:24:44 +0000 (09:24 +0800)
committerVinod Koul <[email protected]>
Tue, 11 Jun 2024 16:07:25 +0000 (21:37 +0530)
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: 16e19e11228b ("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]>
drivers/dma/idxd/irq.c

index 8dc029c8655151a1a47d7849e6fae313c4130add..fc049c9c9892e66302929afd9b0f99b881feca92 100644 (file)
@@ -611,11 +611,13 @@ static void irq_process_work_list(struct idxd_irq_entry *irq_entry)
 
        spin_unlock(&irq_entry->list_lock);
 
-       list_for_each_entry(desc, &flist, list) {
+       list_for_each_entry_safe(desc, n, &flist, list) {
                /*
                 * Check against the original status as ABORT is software defined
                 * and 0xff, which DSA_COMP_STATUS_MASK can mask out.
                 */
+               list_del(&desc->list);
+
                if (unlikely(desc->completion->status == IDXD_COMP_DESC_ABORT)) {
                        idxd_desc_complete(desc, IDXD_COMPLETE_ABORT, true);
                        continue;
This page took 0.057682 seconds and 4 git commands to generate.