iommu/vt-d: drop mm use count if address is not canonical
The use count of svm->mm is incremented by mmget_not_zero. However, it is not dropped when the address is not canonical. This patch fixes the bug.
address is canonical.")
--- drivers/iommu/intel-svm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iommu/intel-svm.c +3 -1
@@ -574,8 +574,10 @@ static irqreturn_t prq_event_thread(int irq, void *d) goto bad_req;/* If address is not canonical, return invalid response */ -if (!is_canonical_address (address)) +if (!is_canonical_address (address)) { +mmput (svm->mm); goto bad_req; + }down_read (&svm->mm->mmap_sem); vma =find_extend_vma (svm->mm, address);
Signature · 1 line
2.7.4
Joerg Roedel
maintainer[ Adding more people. ]
Quoted 18 lines · Pan Bian
The use count of
svm->mmis incremented bymmget_not_zero. However, it is not dropped when the address is not canonical. This patch fixes the bug.Fixes 9d8c3af31607("iommu/vt-d: IOMMU Page Request needs to check ifaddress is canonical.")
Signed-off-by Pan Bian <[email protected]>--- drivers/iommu/intel-svm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/iommu/intel-svm.c +0
-0@@ -574,8 +574,10 @@ static irqreturn_t prq_event_thread(int irq, void *d) goto bad_req;
drivers/iommu/intel-svm.c static irqreturn_t prq_event_thread(int irq, void *d) · line 583
Quoted 10 lines
drivers/iommu/intel-svm.c +3
-1/* If address is not canonical, return invalid response */ -if (!is_canonical_address (address)) +if (!is_canonical_address (address)) { +mmput (svm->mm); goto bad_req; + }down_read (&svm->mm->mmap_sem); vma =find_extend_vma (svm->mm, address);
I think it is better to move the canonical address check before mmget_not_zero() like in the diff below. But I let David and Jacob comment on this.
Regards,
Joerg
drivers/iommu/intel-svm.c +4 -3
@@ -586,14 +586,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)
Jacob Pan
Tested-byQuoted 30 lines · On Fri, 26 Apr 2019 15:38:46 +0200 Joerg Roedel <[email protected]> wrote:
[ Adding more people. ]
Quoted 27 lines · Pan Bian
The use count of
svm->mmis incremented bymmget_not_zero. However, it is not dropped when the address is not canonical. This patch fixes the bug.Fixes 9d8c3af31607("iommu/vt-d: IOMMU Page Request needs to checkif address is canonical.")
Signed-off-by Pan Bian <[email protected]>--- drivers/iommu/intel-svm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/iommu/intel-svm.c +0
-0@@ -574,8 +574,10 @@ static irqreturn_t prq_event_thread(int irq, void *d) goto bad_req;/* If address is not canonical, return invalid response */
drivers/iommu/intel-svm.c +3
-1-if (!is_canonical_address (address)) +if (!is_canonical_address (address)) { +mmput (svm->mm); goto bad_req; + }
Quoted 7 lines
drivers/iommu/intel-svm.c static irqreturn_t prq_event_thread(int irq, void *d) · line 599
Quoted 2 lines
drivers/iommu/intel-svm.c +0
-0down_read (&svm->mm->mmap_sem); vma =find_extend_vma (svm->mm, address);I think it is better to move the canonical address check before
mmget_not_zero()like in the diff below. But I let David and Jacob comment on this.
Looks good to me. Tested with PRQ and fake non canonical address then send an invalid page response.
Quoted 24 lines
Regards,
Joerg
drivers/iommu/intel-svm.c +0
-1@@ -586,14 +586,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. */
drivers/iommu/intel-svm.c +0
-2-if (!mmget_not_zero (svm->mm)) - goto bad_req;/* If address is not canonical, return invalid response */ if (!is_canonical_address(address))
drivers/iommu/intel-svm.c +1
-0goto bad_req; +/* If the mm is already defunct, don't handle faults. */
drivers/iommu/intel-svm.c static irqreturn_t prq_event_thread(int irq, void *d) · line 600
Quoted 6 lines
drivers/iommu/intel-svm.c +3
-0+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)
[Jacob Pan]