Commit ecceb7dba63c for kernel
commit ecceb7dba63cb63ca920f87bb43afaaf3a56c618
Author: Arun Iyengar <aiyengar1990@gmail.com>
Date: Sat Nov 14 00:14:26 2026 +0000
iommu/vsi: Unlink the IOMMU from its old domain under that domain's lock
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@kernel.org>
Closes: https://lore.kernel.org/all/sashiko-outbox-206639@kernel.org/
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
diff --git a/drivers/iommu/vsi-iommu.c b/drivers/iommu/vsi-iommu.c
index 2e1413b8f3b7..734b867e192c 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;