Skip to content

iommufd: Fix vDEVICE allocation lifecycle bugs

Nicolin Chen linux-arm-kernel linux-iommu lkml 2 versions – Applied

Status from this message: Applied to for-rc

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 6 repliesApplied
  2. v13 patches 4 repliesSuperseded

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/3iommufd/viommu: Release the igroup lock on the vdevice_size error pathdrivers/iommu/iommufd/viommu.c+1 -10 replies
2/3iommufd/viommu: Publish a vDEVICE only after vdevice_init() succeedsdrivers/iommu/iommufd/viommu.c+15 -53 replies
3/3iommu/arm-smmu-v3-iommufd: Require exactly one Stream ID for a vDEVICEdrivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c+15 -00 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchKevin TianPranjal Shrivastava
SeriesR-b
1/3R-b
2/3R-b
3/3R-b

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

Read the v2 thread

Cover letter [PATCH v2 0/3] iommufd: Fix vDEVICE allocation lifecycle bugs

Sashiko flagged a few bugs in how IOMMU_VDEVICE_ALLOC creates and validates a vDEVICE on a vIOMMU:

- the core publishes a vDEVICE into the vIOMMU xarray before the driver's vdevice_init() runs, so a concurrent invalidation can reach one it has not yet accepted;
- the undersized-vdevice_size guard returns holding the igroup mutex, deadlocking later vDEVICE operations on that group;
- the Arm SMMUv3 vIOMMU accepts a device without exactly one Stream ID:
an out-of-bounds streams[] read for none, stale ATC/IOTLB for several.

Fix each of them properly.

This is on Github:
https://github.com/nicolinc/iommufd/commits/fix_vdevice_sashiko-v2

Changelog
v2
* Add "Reviewed-by" from Kevin
* Patch-2: Add "Cc stable"; drop the out_release label by inlining the xa_release() call
* Patch-2: Note that the reserved slot is hidden only via xa_* helpers
* Patch-3: Return -EOPNOTSUPP instead of -EINVAL
v1
https://lore.kernel.org/all/[email protected]/

Nicolin Chen (3):
iommufd/viommu: Release the igroup lock on the vdevice_size error path iommufd/viommu: Publish a vDEVICE only after vdevice_init() succeeds iommu/arm-smmu-v3-iommufd: Require exactly one Stream ID for a vDEVICE

 .../arm/arm-smmu-v3/arm-smmu-v3-iommufd.c     | 15 +++++++++++++
 drivers/iommu/iommufd/viommu.c                | 22 ++++++++++++++-----
 2 files changed, 31 insertions(+), 6 deletions(-)
Signature · 1 line
2.43.0