mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Byrne <daniel1.byrne@intel.com>
To: Vinod Koul <vkoul@kernel.org>, dmaengine@vger.kernel.org
Cc: Vinicius Costa Gomes <vinicius.gomes@intel.com>,
	Dave Jiang <dave.jiang@intel.com>, Frank Li <Frank.Li@kernel.org>,
	Fenghua Yu <fenghuay@nvidia.com>, Dan Williams <djbw@kernel.org>,
	linux-kernel@vger.kernel.org,
	Daniel Byrne <daniel1.byrne@intel.com>
Subject: [PATCH v2 00/10] dmaengine: idxd: event log, cdev and prep fixes
Date: Mon, 30 Nov 2026 11:47:11 -0800	[thread overview]
Message-ID: <20261130194721.1900266-1-daniel1.byrne@intel.com> (raw)

These are fixes for bugs in the idxd driver that an in-kernel polling
client exposed while sharing DSA work queues between many users. That
client, a DMA copy offload engine, is not posted yet, and these fixes
do not depend on it. They apply to v7.4-rc2. Every patch has a Fixes
tag and a Cc: stable line with the first affected release.

v1 was one series of 17 patches. v2 is posted as three series:
 - "dmaengine: idxd: event log, cdev and prep fixes", this series:
   ten fixes that stand alone. They apply in order, since some of
   them touch the same lines, but none needs another to work, nor
   either of the other two series;
 - "dmaengine: fixes for channels registered and removed at run time",
   4 patches to the dmaengine core and to idxd's use of it, posted
   with this one;
 - "dmaengine: idxd: fixes found by an in-kernel polling client", on
   the device commands, terminate_all, the teardown, halts and
   resets. It applies on top of this series and is not posted yet,
   see "Patches on the list" below.

In short:
 - the event-log fault path dereferences a NULL workqueue on a kernel
   WQ (1), and the user WQ's workqueue is detached under the event log
   lock (2);
 - a memcpy longer than the work queue's transfer limit is accepted at
   prep and fails silently in hardware (4);
 - event log: the fault work item leaked when there is no record to
   copy (3), a reference on the mm around the completion-record copy
   (5), GENCFG read before the event log enable is cleared (6);
 - the prep callbacks no longer sleep for a descriptor (7); it was
   carried by v1 of the polled-status series and belongs here;
 - three bugs in the code next to these, new in this posting: the
   event log is allocated by a size that is read before its lock is
   taken (8), the queue enable leaves the interrupt requested when
   its last step fails (9), and the quiesce of all kernel queues
   tests a queue without its lock and can kill a reference that is
   not there (10).

Link to v1: https://lore.kernel.org/dmaengine/20261019150630.4026341-1-daniel1.byrne@intel.com/

Changes since v1:

v1's 17 patches were reviewed by Frank Li, by sashiko.dev and by a local
run of the same reviewer. Frank's Reviewed-by is on patch 4. v1's
patches 1, 2 and 3 are patches 1, 2 and 4 here, and the other seven
are new. The per-patch changes are under the --- line of each patch.

What the reviews found, as far as it concerns this series:
 - sashiko.dev had no finding on v1's patches 1, 2 and 3. One of its
   findings on v1's patch 10 was a bug that v7.3 has already, the
   completion record copied into an mm without a users reference.
   Patch 5 fixes it.
 - The local run found the leak that patch 3 fixes in its review of
   v1's patches 1 and 2, and with it the warning of patch 1, which
   called every queue it dropped an entry for a kernel queue. It found
   the GENCFG write that patch 6 fixes in its review of v1's patch 8.
 - The v2 patches were reviewed by a local run of the same reviewer as
   well. In its reviews of the third series it reported bugs that
   those patches did not introduce and that v7.4-rc2 has. Patches 8, 9
   and 10 fix three of them. Two more are in the error path of
   idxd_cdev_open(), and a patch from the list fixes those, see
   "Patches on the list" below. Its last complete run reports no
   issue on patches 1 to 9. On patch 10 it reports no bug that the
   patch introduces. It reports two in the code around it that
   v7.4-rc2 has, the second kill of a queue's reference and the
   handle revoke's test of a queue without its lock. The third series
   fixes both.

Patches on the list:

Vinicius Costa Gomes' "dmaengine: idxd: More error handling fixes" v2
is on the list and not applied yet. This series applies with it or
without it.
 - Its patch 5, "dmaengine: idxd: Fix error handling in
   idxd_cdev_open()", fixes the open that returns success with its
   context freed and the PASID that stays on a dedicated queue. The
   local reviews of this series found both, and they are left to that
   patch.
 - Its patches 7 and 8 fix terminate_all. Two patches of the third
   series, which were patches 6 and 9 of v1, fix the same two
   problems. The third series follows when that overlap is resolved.
https://lore.kernel.org/r/20261125-wt-idxd-fixes-v2-0-25a4691dfb9e@intel.com

Ziyu Zhang's "dmaengine: idxd: Fix deadlock on interrupt handle
revocation" v2 removes the call of idxd_wqs_quiesce() from the handle
revoke path. Patch 10 fixes that function for its other caller, the
halt handler, and applies with that patch or without it.
https://lore.kernel.org/r/20261125133123.98687-1-ziyuzhang201@gmail.com

Testing:

The three series were tested as one stack, and were one series for most
of the rounds. The cover letter of the third, "dmaengine: idxd: fixes
found by an in-kernel polling client", will describe them: a test
module's scenarios on a dmaengine channel, dmatest, iaa_crypto with
zswap, user queues, resets and halts, under KASAN with lockdep and
DMA-API debugging and under KCSAN, on v7.3 and on v7.4-rc2. Every
scenario passes.

Of this series those rounds run the prep callbacks on an exhausted
pool (7), which the scenarios that fill the queue reach, and the setup
and the free of the event log on every enable and disable of a device
(6, 8). They do not reach the event log fault paths (1, 2, 3, 5), which
need a user process whose completion record faults, the refusal in
patch 4, the write of the event log size that patch 8 refuses, the
error path of patch 9, or the quiesce of patch 10, which needs a
system-reset halt or a revoked interrupt handle. Those paths did not
run in these rounds.

Tools:

I used Claude Opus/Fable model to review (sashiko and local reviews)
the code, suggest fixes, and edit the changelogs. I also used it to
run the builds and the test rounds described above. I reviewed the
results and fixes it suggested and I am responsible for them.

Daniel Byrne (10):
  dmaengine: idxd: don't queue EVL fault work for kernel WQs
  dmaengine: idxd: detach the user fault workqueue under the event log
    lock
  dmaengine: idxd: free the event log fault item when no record is
    copied
  dmaengine: idxd: refuse a memcpy longer than the WQ max transfer size
  dmaengine: idxd: take an mm_users reference for the completion record
    copy
  dmaengine: idxd: read GENCFG before clearing the event log enable
  dmaengine: idxd: don't sleep for a descriptor in the prep callbacks
  dmaengine: idxd: read the event log size under its lock in the setup
  dmaengine: idxd: free the queue interrupt when the percpu_ref setup
    fails
  dmaengine: idxd: test a queue under its lock before quiescing it

 drivers/dma/idxd/cdev.c   | 60 +++++++++++++++++++++++++++++++++------
 drivers/dma/idxd/device.c | 15 +++++++++-
 drivers/dma/idxd/dma.c    |  9 ++++--
 drivers/dma/idxd/init.c   | 20 ++++++++++++-
 drivers/dma/idxd/irq.c    | 25 ++++++++++++++--
 drivers/dma/idxd/sysfs.c  | 10 +++++++
 6 files changed, 123 insertions(+), 16 deletions(-)


base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
-- 
2.43.0


             reply	other threads:[~2026-11-30 19:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 19:47 Daniel Byrne [this message]
2026-11-30 19:47 ` [PATCH v2 01/10] dmaengine: idxd: don't queue EVL fault work for kernel WQs Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 02/10] dmaengine: idxd: detach the user fault workqueue under the event log lock Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 03/10] dmaengine: idxd: free the event log fault item when no record is copied Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 04/10] dmaengine: idxd: refuse a memcpy longer than the WQ max transfer size Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 05/10] dmaengine: idxd: take an mm_users reference for the completion record copy Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 06/10] dmaengine: idxd: read GENCFG before clearing the event log enable Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 07/10] dmaengine: idxd: don't sleep for a descriptor in the prep callbacks Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 08/10] dmaengine: idxd: read the event log size under its lock in the setup Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 09/10] dmaengine: idxd: free the queue interrupt when the percpu_ref setup fails Daniel Byrne
2026-11-30 19:47 ` [PATCH v2 10/10] dmaengine: idxd: test a queue under its lock before quiescing it Daniel Byrne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130194721.1900266-1-daniel1.byrne@intel.com \
    --to=daniel1.byrne@intel.com \
    --cc=Frank.Li@kernel.org \
    --cc=dave.jiang@intel.com \
    --cc=djbw@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=fenghuay@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vinicius.gomes@intel.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®