Skip to content

pds_core: fix use-after-free on workqueue during remove

Nikhil P. Rao netdev 3 versions – Applied

Status from this message: This series was applied to netdev/net.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 2 repliesApplied 2/2
  2. v22 patches 6 repliesSuperseded
  3. v11 patch 1 replySuperseded

Changes in v3 from the cover letter

- Drop READ_ONCE(qcq->intx) in pdsc_process_adminq(); clear qcq->intx after cancel_work_sync() in pdsc_qcq_free() so the work path observes a stable value without the barrier (addresses Paolo's v2 comment). This removes the adminq.c change entirely.

Patches in v3 All 2 applied

#Subject and filesSizeRepliesApplied
1/2pds_core: fix deadlock between reset thread and removedrivers/net/ethernet/amd/pds_core/core.c+4 -32 repliesApplied
2/2pds_core: fix use-after-free on workqueue during removedrivers/net/ethernet/amd/pds_core/core.c drivers/net/ethernet/amd/pds_core/main.c+13 -60 repliesApplied

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchHarshitha Ramamurthy
1/2R-b
2/2

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

Read the v3 thread

Cover letter [PATCH net v3 0/2] pds_core: fix use-after-free on workqueue during remove

This series fixes a use-after-free on the workqueue during driver remove.

Patch 1 fixes a pre-existing deadlock between the PCI reset worker and pdsc_remove() that was identified during review of v1.

Patch 2 is the reworked UAF fix that moves destroy_workqueue() after pdsc_teardown() and adds proper work synchronization.

v3:
- Drop READ_ONCE(qcq->intx) in pdsc_process_adminq(); clear qcq->intx after cancel_work_sync() in pdsc_qcq_free() so the work path observes a stable value without the barrier (addresses Paolo's v2 comment). This removes the adminq.c change entirely.

v2:
- Fix deadlock between pci_reset_thread and remove (new patch 1/2) found by sashiko AI review of v1
- Rework UAF fix: move destroy_workqueue() after pdsc_teardown() instead of setting wq to NULL (addresses NULL deref found by sashiko)
- Add cancel_work_sync() after free_irq() to drain ISR-queued work
- Reorder adminqcq/notifyqcq freeing to avoid accessing freed notifyqcq

v2: https://lore.kernel.org/netdev/[email protected]/
v1: https://lore.kernel.org/netdev/[email protected]/

Nikhil P. Rao (2):
pds_core: fix deadlock between reset thread and remove
pds_core: fix use-after-free on workqueue during remove

 drivers/net/ethernet/amd/pds_core/core.c | 21 ++++++++++++++-------
 drivers/net/ethernet/amd/pds_core/main.c |  5 +++--
 2 files changed, 17 insertions(+), 9 deletions(-)

--
2.43.0