[PATCH 2/3] iommu/vsi: Unlink the IOMMU from its old domain under that domain's lock
From: Arun Iyengar via B4 Relay
Date: Fri Nov 13 2026 - 19:15:35 EST
From: Arun Iyengar <aiyengar1990@xxxxxxxxx>
Attaching a paging domain moves iommu->node to the new domain's list
holding only the new domain's lock. A concurrent map or unmap on the old
domain walks the old list in vsi_iommu_flush_tlb() and can follow the
moved node into the new list.
Unlink the IOMMU under the old domain's lock first.
Fixes: 917ace84b770 ("iommu: Add verisilicon IOMMU driver")
Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Closes: https://lore.kernel.org/all/sashiko-outbox-206639@xxxxxxxxxx/
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>
---
drivers/iommu/vsi-iommu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/vsi-iommu.c b/drivers/iommu/vsi-iommu.c
index 5156e8a2e7fc..8a0f253f2017 100644
--- a/drivers/iommu/vsi-iommu.c
+++ b/drivers/iommu/vsi-iommu.c
@@ -575,12 +575,13 @@ static int vsi_iommu_attach_device(struct iommu_domain *domain,
if (ret < 0)
return ret;
+ vsi_iommu_list_del(iommu);
+
spin_lock_irqsave(&vsi_domain->lock, flags);
spin_lock(&iommu->lock);
vsi_iommu_enable(iommu, domain);
- list_del_init(&iommu->node);
list_add_tail(&iommu->node, &vsi_domain->iommus);
iommu->domain = domain;
--
2.55.0