Skip to contentSkip to conversation

dmaengine: idxd: fix possible wrong descriptor completion in llist_abort_desc()

PATCH Applied Tuo Li 3 participants 3 messages Jan 6 – Mar 9

Subsystems (2)
lore
Share & tools
lore

Tuo Li

author
#0 lore raw

PATCH 1/1 dmaengine: idxd: fix possible wrong descriptor completion in llist_abort_desc()

At the end of this function, d is the traversal cursor of flist, but the code completes found instead. This can lead to issues such as NULL pointer dereferences, double completion, or descriptor leaks.

Fix this by completing d instead of found in the final list_for_each_entry_safe() loop.

Fixes aa8d18becc0c ("dmaengine: idxd: add callback support for iaa crypto")
---
 drivers/dma/idxd/submit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/idxd/submit.c +1 -1
index 6db1c5fcedc5..03217041b8b3 100644
@@ -138,7 +138,7 @@ static void llist_abort_desc(struct idxd_wq *wq, struct idxd_irq_entry *ie,
 	 */
 	list_for_each_entry_safe(d, t, &flist, list) {
 		list_del_init(&d->list);
-		idxd_dma_complete_txd(found, IDXD_COMPLETE_ABORT, true,
+		idxd_dma_complete_txd(d, IDXD_COMPLETE_ABORT, true,
 				      NULL, NULL);
 	}
 }
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Tuo Li

At the end of this function, d is the traversal cursor of flist, but the code completes found instead. This can lead to issues such as NULL pointer dereferences, double completion, or descriptor leaks.

Fix this by completing d instead of found in the final list_for_each_entry_safe() loop.

Fixes aa8d18becc0c ("dmaengine: idxd: add callback support for iaa crypto")

Good catch! Thanks.

Quoted 17 lines
---
 drivers/dma/idxd/submit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/idxd/submit.c +1 -1
index 6db1c5fcedc5..03217041b8b3 100644
@@ -138,7 +138,7 @@ static void llist_abort_desc(struct idxd_wq *wq, struct idxd_irq_entry *ie,
 	 */
 	list_for_each_entry_safe(d, t, &flist, list) {
 		list_del_init(&d->list);
-		idxd_dma_complete_txd(found, IDXD_COMPLETE_ABORT, true,
+		idxd_dma_complete_txd(d, IDXD_COMPLETE_ABORT, true,
 				      NULL, NULL);
 	}
 }
maintainer Applied
#2 lore raw
In reply to Tuo Li
Quoted 8 lines · Tuo Li

At the end of this function, d is the traversal cursor of flist, but the code completes found instead. This can lead to issues such as NULL pointer dereferences, double completion, or descriptor leaks.

Fix this by completing d instead of found in the final list_for_each_entry_safe() loop.

[...]

Applied, thanks!

[1/1] dmaengine: idxd: fix possible wrong descriptor completion in llist_abort_desc()

      commit: e1c9866173c5f8521f2d0768547a01508cb9ff27

Best regards,

Signature · 1 line
~Vinod