Skip to content

dmaengine: fix kref underflow and UAF in dma_chan_put()

Shivank Garg dmaengine lkml stable 5 versions – Applied

Status from this message: Applied, thanks!

Get series with b4
b4 am [email protected] change-id 20260518-dmaengine-kref-fix-7b21acb09455

Versions newest first

  1. v5 Latest4 patches 2 repliesApplied
  2. v44 patches 8 repliesSuperseded
  3. v33 patches 9 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v22 patches0 repliesSuperseded
v11 patch2 repliesSuperseded

Changes in v5 from the cover letter

- Use int return type and add __must_check for dma_device_get() (Frank)
- Drop the comment above synchronize_rcu() and note in the commit message
that this will delay for grace period dma_list_mutex held (Logan)
- Link to v4: https://lore.kernel.org/r/[email protected]

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/4dmaengine: add dma_device_get() helperdrivers/dma/dmaengine.c+7 -20 replies
2/4dmaengine: Fix device kref underflow in dma_chan_put()drivers/dma/dmaengine.c+3 -10 replies
3/4dmaengine: fix use-after-free in dma_chan_put() and dma_release_channel()drivers/dma/dmaengine.c+4 -10 replies
4/4dmaengine: wait for RCU readers before releasing dma_devicedrivers/dma/dmaengine.c+1 -00 replies

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchLogan GunthorpeFrank Li
1/4R-b
2/4R-b R-b
3/4R-b R-b
4/4R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/4] dmaengine: fix kref underflow and UAF in dma_chan_put()

Fix bugs related to dma_chan_put(), found while testing with SDXI[1].

[1]: https://lore.kernel.org/dmaengine/[email protected]

---
Changes in v5:
- Use int return type and add __must_check for dma_device_get() (Frank)
- Drop the comment above synchronize_rcu() and note in the commit message
that this will delay for grace period dma_list_mutex held (Logan)
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Add dma_device_get() helper (Frank)
- Drop dma_chan_put() move change (Frank)
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Add patch 3: add synchronize_rcu() to wait for RCU readers to prevent use-after-free. (Sashiko)
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Add patch 2 fixing the dma_chan_put()/dma_release_channel() use-after-free (sashiko)
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Shivank Garg (4):
dmaengine: add dma_device_get() helper
dmaengine: Fix device kref underflow in dma_chan_put()
dmaengine: fix use-after-free in dma_chan_put() and dma_release_channel()
dmaengine: wait for RCU readers before releasing dma_device

 drivers/dma/dmaengine.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

---
base-commit: a4ff2be345d0abc943da8dd8da98151843b750dc
change-id: 20260518-dmaengine-kref-fix-7b21acb09455

Best regards,

Signature · 1 line
Shivank Garg <[email protected]>