Skip to content

Commit

Permalink
iommu/vt-d: Fix mm reference leak
Browse files Browse the repository at this point in the history
Move canonical address check before mmget_not_zero() to avoid mm
reference leak.

Fixes: 9d8c3af ("iommu/vt-d: IOMMU Page Request needs to check if address is canonical.")
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
  • Loading branch information
Jacob Pan authored and Joerg Roedel committed Mar 27, 2020
1 parent f8788d8 commit 902baf6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/iommu/intel-svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,14 +611,15 @@ static irqreturn_t prq_event_thread(int irq, void *d)
* any faults on kernel addresses. */
if (!svm->mm)
goto bad_req;
/* If the mm is already defunct, don't handle faults. */
if (!mmget_not_zero(svm->mm))
goto bad_req;

/* If address is not canonical, return invalid response */
if (!is_canonical_address(address))
goto bad_req;

/* If the mm is already defunct, don't handle faults. */
if (!mmget_not_zero(svm->mm))
goto bad_req;

down_read(&svm->mm->mmap_sem);
vma = find_extend_vma(svm->mm, address);
if (!vma || address < vma->vm_start)
Expand Down

0 comments on commit 902baf6

Please sign in to comment.