summaryrefslogtreecommitdiffstats
path: root/drivers/iommu/intel-iommu.c
diff options
context:
space:
mode:
authorLu Baolu <baolu.lu@linux.intel.com>2019-08-05 20:14:09 -0400
committerJoerg Roedel <jroedel@suse.de>2019-08-09 11:35:25 -0400
commit3a18844dcf89e636b2d0cbf577e3963b0bcb6d23 (patch)
treed2e1a012c4e47e8a5d1740ae19f12d366ebac4b4 /drivers/iommu/intel-iommu.c
parentae23bfb68f2896835e54a137688906713cb607e7 (diff)
iommu/vt-d: Fix possible use-after-free of private domain
Multiple devices might share a private domain. One real example is a pci bridge and all devices behind it. When remove a private domain, make sure that it has been detached from all devices to avoid use-after-free case. Cc: Ashok Raj <ashok.raj@intel.com> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> Cc: Kevin Tian <kevin.tian@intel.com> Cc: Alex Williamson <alex.williamson@redhat.com> Fixes: 942067f1b6b97 ("iommu/vt-d: Identify default domains replaced with private") Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Tested-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu/intel-iommu.c')
-rw-r--r--drivers/iommu/intel-iommu.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 37259b7f95a7..12d094d08c0a 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -4791,7 +4791,8 @@ static void __dmar_remove_one_dev_info(struct device_domain_info *info)
4791 4791
4792 /* free the private domain */ 4792 /* free the private domain */
4793 if (domain->flags & DOMAIN_FLAG_LOSE_CHILDREN && 4793 if (domain->flags & DOMAIN_FLAG_LOSE_CHILDREN &&
4794 !(domain->flags & DOMAIN_FLAG_STATIC_IDENTITY)) 4794 !(domain->flags & DOMAIN_FLAG_STATIC_IDENTITY) &&
4795 list_empty(&domain->devices))
4795 domain_exit(info->domain); 4796 domain_exit(info->domain);
4796 4797
4797 free_devinfo_mem(info); 4798 free_devinfo_mem(info);