mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/5] iommu: Fix attach handle publication ordering
@ 2026-11-02  7:04 Nicolin Chen
  2026-11-02  7:04 ` [PATCH v2 1/5] iommu: Unpublish the attach handle before the group detach callback Nicolin Chen
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Nicolin Chen @ 2026-11-02  7:04 UTC (permalink / raw)
  To: joro, Lu Baolu, Kevin Tian, Yi Liu
  Cc: Will Deacon, Robin Murphy, Jean-Philippe Brucker,
	Jason Gunthorpe, iommu, linux-kernel

Jason pointed out an issue in the attach handle replacing path:
https://lore.kernel.org/linux-iommu/20260923233920.GJ2545495@nvidia.com/

When an attachment is detached or replaced, the IOMMU core can still leave
the outgoing attach handle published while calling into the driver. A fault
report looks up the handle without the group mutex, so it can find the old
handle after the driver's fault flush and just before the caller frees it.

Patches 1-4 unpublish the outgoing handle before calling into the driver,
for both group and PASID detach and replace operations. Both replace paths
store XA_ZERO_ENTRY to reserve the slot and restore the old entry on error.

This blocks new lookups, but does not retire a fault that already obtained
the old handle. The driver must still synchronize those readers before the
handle is freed.

Patch 5 rejects a same-domain replace in both of the replace APIs. Such a
replace skips the driver callback. So, nothing would ever flush the pending
faults before the caller frees the old handle.

This is on GitHub:
https://github.com/nicolinc/iommufd/commits/fix_iommu_attach_handle-v2

Changelog
v2
 * Rebase on v7.4-rc1
 * Drop "Assisted-by: LLM" tags
 * Add Reviewed-by from Kevin, Yi and Baolu
 * New patch: reject a same-domain replace in the attach handle APIs
v1
 https://lore.kernel.org/linux-iommu/cover.1790718296.git.nicolinc@nvidia.com/

Nicolin Chen (5):
  iommu: Unpublish the attach handle before the group detach callback
  iommu: Unpublish the attach handle before the PASID detach callback
  iommu: Unpublish the old attach handle before the group replace
    callback
  iommu: Unpublish the old attach handle before the PASID replace
    callback
  iommu: Reject a same-domain replace in the attach handle APIs

 drivers/iommu/iommu.c | 86 ++++++++++++++++++++++++++++++-------------
 1 file changed, 61 insertions(+), 25 deletions(-)


base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-02  7:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-02  7:04 [PATCH v2 0/5] iommu: Fix attach handle publication ordering Nicolin Chen
2026-11-02  7:04 ` [PATCH v2 1/5] iommu: Unpublish the attach handle before the group detach callback Nicolin Chen
2026-11-02  7:04 ` [PATCH v2 2/5] iommu: Unpublish the attach handle before the PASID " Nicolin Chen
2026-11-02  7:04 ` [PATCH v2 3/5] iommu: Unpublish the old attach handle before the group replace callback Nicolin Chen
2026-11-02  7:04 ` [PATCH v2 4/5] iommu: Unpublish the old attach handle before the PASID " Nicolin Chen
2026-11-02  7:04 ` [PATCH v2 5/5] iommu: Reject a same-domain replace in the attach handle APIs Nicolin Chen

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®