Skip to content

iommu: Fix pci_dev_reset_iommu_prepare/done()

Nicolin Chen linux-iommu lkml 8 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v8 Latest8 patches 5 repliesIn review
  2. v76 patches 14 repliesSuperseded
  3. v61 patch 9 repliesSuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v51 patch3 repliesSuperseded
v41 patch2 repliesSuperseded
v31 patch1 replySuperseded
v21 patch7 repliesSuperseded
v11 patch6 repliesSuperseded

Changes in v8 from the cover letter

* Add Reviewed-by tags
* Fix NULL group->domain in done()
* Tidy goto cleanup when using guard()
* Update patch subject and commit message
* Add warning on premature unblocking in DMA alias cases
* Drop unreachable skip in __iommu_group_set_domain_internal() error path

Patches in v8 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8iommu: Fix NULL group->domain dereference in pci_dev_reset_iommu_done()drivers/iommu/iommu.c+7 -21 reply
2/8iommu: Fix kdocs of pci_dev_reset_iommu_done()drivers/iommu/iommu.c+3 -30 replies
3/8iommu: Replace per-group resetting_domain with per-gdev blocked flagdrivers/iommu/iommu.c+78 -240 replies
4/8iommu: Fix pasid attach in pci_dev_reset_iommu_prepare/done()drivers/iommu/iommu.c+18 -71 reply
5/8iommu: Fix nested pci_dev_reset_iommu_prepare/done()drivers/iommu/iommu.c+13 -60 replies
6/8iommu: Fix ATS invalidation timeouts during __iommu_remove_group_pasid()drivers/iommu/iommu.c+6 -11 reply
7/8iommu: Fix WARN_ON in __iommu_group_set_domain_nofail() due to resetdrivers/iommu/iommu.c+10 -20 replies
8/8iommu: Warn on premature unblock during DMA aliased sibling resetdrivers/iommu/iommu.c+49 -01 reply

Reviews trailers per patch

All 8 patches have a Reviewed-by or Acked-by.

PatchShuai XueJason GunthorpeKevin TianLu Baolu
1/8R-b
2/8R-b R-b R-b R-b
3/8R-b R-b R-b R-b
4/8R-b R-b R-b R-b
5/8R-b R-b R-b R-b
6/8R-b R-b
7/8R-b R-b
8/8R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v8 thread

Cover letter [PATCH rc v8 0/8] iommu: Fix pci_dev_reset_iommu_prepare/done()

Shuai and Kevin found a few bugs in the pci_dev_reset_iommu_prepare/done() helpers when used to handle some corner cases:
- Nested callbacks
- Multi-device groups
- WARN_ON/UAF due to concurrent detach

This needs some substantial rework by tracking device reset states on a per gdev basis. This series includes a few patches addressing them. Most of the patches are reviewed previously in a single patch v6. As we found more bugs during the reviews, I split that v6 to smaller patches so each of them will be cleaner.

This is on Github:
https://github.com/nicolinc/iommufd/commits/fix_iommu_reset-v8

Note that concurrent reset of two DMA alias siblings (sharing the same RID) might prematurely unblock when one device is done while the other is still resetting. And it's a bit convoluted to support this case. Given that it's unclear whether real ATS devices might share RID, for now, add a warning in the done(). A future work can fix it properly if someone hits it.

Changelog
v8:
* Add Reviewed-by tags
* Fix NULL group->domain in done()
* Tidy goto cleanup when using guard()
* Update patch subject and commit message
* Add warning on premature unblocking in DMA alias cases
* Drop unreachable skip in __iommu_group_set_domain_internal() error path
v7:
https://lore.kernel.org/all/[email protected]/
* Add Reviewed-by tags
* Split v6 into smaller patches
* Add one patch to fix UAF during detach()
* Add one patch to fix unnecessary ATS invalidation
v6:
https://lore.kernel.org/all/[email protected]/
* Update inline comments and commit message
* Add "max_pasids > 0" condition in both helpers
v5:
https://lore.kernel.org/all/[email protected]/
* Add 'blocked' to fix iommu_driver_get_domain_for_dev() return.
v4:
https://lore.kernel.org/all/[email protected]/
* Rename 'reset_cnt' to 'recovery_cnt'
v3:
https://lore.kernel.org/all/[email protected]/
* Turn prepare()/done() to be per-gdev
* Use reset_depth to track nested re-entries
* Replace group->resetting_domain with a reset_cnt
v2:
https://lore.kernel.org/all/[email protected]/
* Fix in the helpers by allowing re-entry
v1:
https://lore.kernel.org/all/[email protected]/

Nicolin Chen (8):
iommu: Fix NULL group->domain dereference in
pci_dev_reset_iommu_done()
iommu: Fix kdocs of pci_dev_reset_iommu_done()
iommu: Replace per-group resetting_domain with per-gdev blocked flag
iommu: Fix pasid attach in pci_dev_reset_iommu_prepare/done()
iommu: Fix nested pci_dev_reset_iommu_prepare/done()
iommu: Fix ATS invalidation timeouts during
__iommu_remove_group_pasid()
iommu: Fix WARN_ON in __iommu_group_set_domain_nofail() due to reset
iommu: Warn on premature unblock during DMA aliased sibling reset

 drivers/iommu/iommu.c | 223 ++++++++++++++++++++++++++++++++++--------
 1 file changed, 181 insertions(+), 42 deletions(-)
Signature · 1 line
2.43.0