]> git.baikalelectronics.ru Git - kernel.git/commitdiff
iommu/vt-d: Fix PASID leak in intel_svm_unbind_mm()
authorFenghua Yu <fenghua.yu@intel.com>
Sat, 28 Aug 2021 07:06:21 +0000 (15:06 +0800)
committerJoerg Roedel <jroedel@suse.de>
Thu, 9 Sep 2021 11:18:06 +0000 (13:18 +0200)
The mm->pasid will be used in intel_svm_free_pasid() after load_pasid()
during unbinding mm. Clearing it in load_pasid() will cause PASID cannot
be freed in intel_svm_free_pasid().

Additionally mm->pasid was updated already before load_pasid() during pasid
allocation. No need to update it again in load_pasid() during binding mm.
Don't update mm->pasid to avoid the issues in both binding mm and unbinding
mm.

Fixes: 4048377414162 ("iommu/vt-d: Use iommu_sva_alloc(free)_pasid() helpers")
Reported-and-tested-by: Dave Jiang <dave.jiang@intel.com>
Co-developed-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Link: https://lore.kernel.org/r/20210826215918.4073446-1-fenghua.yu@intel.com
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/20210828070622.2437559-2-baolu.lu@linux.intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/intel/svm.c

index 2014fe8695ace20b560f5902f49a11f926c13e43..a3f84f2ff1ba882b2b52313b420e2996c44d482e 100644 (file)
@@ -514,9 +514,6 @@ static void load_pasid(struct mm_struct *mm, u32 pasid)
 {
        mutex_lock(&mm->context.lock);
 
-       /* Synchronize with READ_ONCE in update_pasid(). */
-       smp_store_release(&mm->pasid, pasid);
-
        /* Update PASID MSR on all CPUs running the mm's tasks. */
        on_each_cpu_mask(mm_cpumask(mm), _load_pasid, NULL, true);