Skip to content

dmaengine: idxd: fix crashes in the probe error path

Jingyi Li dmaengine lkml stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2dmaengine: idxd: fix double free in idxd_free()drivers/dma/idxd/init.c+0 -31 reply
2/2dmaengine: idxd: fix destroy of NULL or already destroyed workqueuedrivers/dma/idxd/init.c drivers/dma/idxd/sysfs.c+4 -11 reply

Reviews trailers per patch

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

PatchFrank Li
1/2
2/2R-b

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

Read the v1 thread

Cover letter [PATCH 0/2] dmaengine: idxd: fix crashes in the probe error path

When idxd_probe() fails, the cleanup in idxd_pci_probe_alloc() runs into two bugs:

1. idxd_free() frees opcap_bmap, the IDA id and idxd after put_device() has already freed them via idxd_conf_device_release() (double free).

2. idxd_conf_device_release() calls destroy_workqueue() on a NULL workqueue when probe fails before idxd_setup_internals(), and on an already destroyed one after idxd_cleanup_internals() or the err_evl path of idxd_setup_internals().

We hit both in a kdump crash kernel, where the DSA device fails to reset and reports HALTED. Depending on the kernel version, the crash kernel either oopses in destroy_workqueue() (2) or corrupts the slab (1), and no dump is saved.

Testing: the equivalent change was tested on 6.18.57 on 10 systems with DSA, triggering kdump with idxd loaded in the crash kernel:

- unpatched: 10/10 NULL pointer dereference in destroy_workqueue(), 0/10 dumps saved
- patch 1 only: no change, the oops in (2) happens first
- both patches: 10/10 dumps saved; with slub_debug=FZPU, no slub reports and no oopses

On 6.18.18, which predates commit 3d33de353b1f, patch 1 alone fixed the slab corruption (10/10 dumps, previously 0x6b poison faults with slub_debug).

This series is build-tested with W=1 on top of 7.3-rc4.

Jingyi Li (2):
dmaengine: idxd: fix double free in idxd_free()
dmaengine: idxd: fix destroy of NULL or already destroyed workqueue

 drivers/dma/idxd/init.c  | 5 ++---
 drivers/dma/idxd/sysfs.c | 3 ++-
 2 files changed, 4 insertions(+), 4 deletions(-)

base-commit: 93f51579e7df248780214094418f205253383cc5

Signature · 1 line
2.43.0