[PATCH v2 01/10] dmaengine: idxd: don't queue EVL fault work for kernel WQs
From: Daniel Byrne
Date: Mon Nov 30 2026 - 14:54:18 EST
The event log fault path queues work on wq->wq, the workqueue that only
the user (cdev) driver creates for its work queues. A completion record
fault logged for a kernel work queue, a dmaengine or iaa_crypto queue,
finds that pointer NULL and queue_work() dereferences it.
The fault worker only serves user contexts. It copies the completion
record through the PASID xarray that cdev opens populate. On a kernel
work queue there is nothing to do, so log the entry rate-limited and
drop it. Test the queue's type and not the pointer alone, since a user
probe that failed leaves the pointer dangling. The warning names the
queue's type, because the same test drops an entry for a queue whose
user driver was unbound after the entry was logged, and for a queue
retyped to user while disabled.
Fixes: c40bd7d9737b ("dmaengine: idxd: process user page faults for completion record")
Cc: stable@xxxxxxxxxxxxxxx # 6.4+
Signed-off-by: Daniel Byrne <daniel1.byrne@xxxxxxxxx>
---
v2: the test is unchanged. The warning no longer says "kernel wq" and
prints the queue's type, since the same test also drops the record of a
user queue whose cdev driver is not bound; the comment says so, and the
message adds a queue retyped to user while disabled. The wq declaration
moves to the top of the block.
drivers/dma/idxd/irq.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/idxd/irq.c b/drivers/dma/idxd/irq.c
index 6a25e1fd0e62..7ae73bb39548 100644
--- a/drivers/dma/idxd/irq.c
+++ b/drivers/dma/idxd/irq.c
@@ -322,6 +322,7 @@ static void process_evl_entry(struct idxd_device *idxd,
if (status == DSA_COMP_CRA_XLAT || status == DSA_COMP_DRAIN_EVL ||
status == DSA_COMP_BATCH_EVL_ERR) {
+ struct idxd_wq *wq = idxd->wqs[entry_head->wq_idx];
struct idxd_evl_fault *fault;
int ent_size = evl_ent_size(idxd);
@@ -331,10 +332,24 @@ static void process_evl_entry(struct idxd_device *idxd,
if (!entry_head->rcr && status == DSA_COMP_DRAIN_EVL)
return;
+ /*
+ * The fault worker only does user-context work,
+ * copying the completion record through the wq's
+ * PASID xarray, which is populated by cdev opens
+ * alone. A kernel WQ, or a user WQ whose cdev driver
+ * is not bound, has no cdev workqueue and no user
+ * contexts, so queueing could only warn and drop the
+ * record. Note it and move on.
+ */
+ if (!is_idxd_wq_user(wq) || !wq->wq) {
+ dev_warn_ratelimited(dev,
+ "EVL fault on wq %d with no user fault workqueue (type %u), status %#x\n",
+ wq->id, wq->type, status);
+ return;
+ }
+
fault = kmem_cache_alloc(idxd->evl_cache, GFP_ATOMIC);
if (fault) {
- struct idxd_wq *wq = idxd->wqs[entry_head->wq_idx];
-
fault->wq = wq;
fault->status = status;
memcpy(&fault->entry, entry_head, ent_size);
--
2.43.0