Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796068423; b=NlvmWNLgam47m+8FxgGet5vN1BCzOLzi1vjALYWqLpZlQvf4mapuoX/8Scd+TKH005PI BAzyRJKJ3q/aAN7g6AczK46dnjw7QW+c8mt5G5dAcPxGNSBhUMWSEgK7VgT/UDeLWxZH/ ZiFgQL490YF22oUnNpojr6yzJEy+IVViy00bU8YEati4roas7b0FAG1M5+X/516dUctEK vfaD78n5XKClXsKLn0/twp8Bi3aJLlQYYk9cgYKIXGpAgsJB4gRrF/tdbFvZbxy7I1Zw5 Pdu4UgxBc69FZ0KWL6swxnUwcIcRFc7eLJXDCEUDqKlx0AJZPKJA8CtQLiswtYBUckw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796068423; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=zAUOriRx/VOxij6V2VClYgb8gtn126xs9GGyD72FpfA=; b=bkT9JhYVcgZbruZABoUCy8QR4MPOLBzIJUZ1C96NhcCEW/QqOgiB6++3tWiL+XjjivlX rl7OgBL0xcIVXTpWuTwZKZ9yvQeCwlcicuj1hEYec54gyZAtJJUe3RCAGsU0dkfN15P+5 gqdeCtIymmF7MJ6dUbH+ibUuMBugYw2u4oo+G7v6BsxGvXDM4v66hr/r7Pl3W2RVSrdyG 49MKTmWDnkdG6i4pWOQkWi9mjWSWX5cqd5IbxaZDT58mOGS19rbEeVU4GdNBc5N7YBZdF OdPpzQ4yOgKZZxtGX7eBctT1OBtSaw7w2DE7NF2Tt1WNfF5uEHC0wOOsjVAr7Vd0cTA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=GrL80pFg; arc=none smtp.remote-ip=198.175.65.11 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0698F606A33E; Mon, 30 Nov 2026 19:53:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0698F606A33E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=GrL80pFg DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796068424; x=1827604424; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=zAUOriRx/VOxij6V2VClYgb8gtn126xs9GGyD72FpfA=; b=GrL80pFgbF1FtN6st5sVi0dLoWBebSe/fSOxTBfCe1FaDrOw1e1uEVao pRVQ7D+jQHu55ZB2h0PC06sd3WhmL7lXpzuWlnljCQUJ28KBn7AWjuXip /bR+BXpVB53nwLs9pjvrLHl1etkqQwF7ina+9I10gvpEKRMAHIKoSQ0Ih Zll0r7nvd733/2x6o0VKfAVcAhwYBrBAgJB9WN05HFeU6Zo3MTljElqzs Hsd36jNlmnk+IEimxpL6fJ5Wt2Xte+rOZGrYFkw1VLuTjTutdpiDyW/IT czLmpZVhFQnmMmhKoy0sA9RvPLE7axpZCpfPnck3/ffxOFMWGfzs+Sj2w Q==; X-CSE-ConnectionGUID: OCgp5I+9TG+jTIGYMNu4zQ== X-CSE-MsgGUID: AAqFSmhCSxW2i74mtnouvQ== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4805749" X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="4805749" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 11:53:40 -0800 X-CSE-ConnectionGUID: W4qpYS+JQXSlATeTMdeUQw== X-CSE-MsgGUID: jVPSTVQwQ4KjzwmJdbgHdg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="13036608" Received: from jf5300-15a101203tc.jf.intel.com (HELO meta-crater2c.jf.intel.com) ([10.54.113.49]) by orviesa002.jf.intel.com with ESMTP; 30 Nov 2026 11:53:40 -0800 From: Daniel Byrne To: Vinod Koul , dmaengine@vger.kernel.org Cc: Vinicius Costa Gomes , Dave Jiang , Frank Li , Fenghua Yu , Dan Williams , linux-kernel@vger.kernel.org, Daniel Byrne Subject: [PATCH v2 00/10] dmaengine: idxd: event log, cdev and prep fixes Date: Mon, 30 Nov 2026 11:47:11 -0800 Message-ID: <20261130194721.1900266-1-daniel1.byrne@intel.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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