[PATCH 1/1] iommu/vt-d: Avoid relying on pci_ats_supported() for rbtree removal
From: Lu Baolu
Date: Sun Nov 22 2026 - 19:50:58 EST
Commit 89436f4f5412 ("iommu/vt-d: Fix WARN_ON in iommu probe path") made
the device rbtree insertion in intel_iommu_probe_device() conditional on
pci_ats_supported(). To match, intel_iommu_release_device() only removes
the device from the rbtree if pci_ats_supported() is still true.
That relies on pci_ats_supported() returning the same result at release
as it did at probe. If it changes in between, the rbtree can retain an
entry after its device_domain_info has been freed, resulting in a
use-after-free during a later lookup.
Checking RB_EMPTY_NODE() to track rbtree membership is common in the
iommu subsystem. Since device_rbtree_remove() safely handles an empty
node, call it unconditionally in the release path. This makes removal
depend on the device's actual rbtree membership.
Fixes: 89436f4f5412 ("iommu/vt-d: Fix WARN_ON in iommu probe path")
Signed-off-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
---
drivers/iommu/intel/iommu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 5a2e705a2f2e..82f7bd8ecadf 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -3393,6 +3393,7 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev)
info->dev = dev;
info->iommu = iommu;
+ /* An empty node marks the device as not in the rbtree. */
RB_CLEAR_NODE(&info->node);
if (dev_is_pci(dev)) {
if (ecap_dev_iotlb_support(iommu->ecap) &&
@@ -3508,8 +3509,7 @@ static void intel_iommu_release_device(struct device *dev)
}
mutex_lock(&iommu->iopf_lock);
- if (dev_is_pci(dev) && pci_ats_supported(to_pci_dev(dev)))
- device_rbtree_remove(info);
+ device_rbtree_remove(info);
mutex_unlock(&iommu->iopf_lock);
if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev) &&
--
2.43.0