From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Sasha Levin <sashal@kernel.org>,
iommu@lists.linux-foundation.org, Joerg Roedel <jroedel@suse.de>
Subject: [PATCH AUTOSEL 5.6 07/73] iommu/vt-d: Fix mm reference leak
Date: Sat, 18 Apr 2020 09:47:09 -0400 [thread overview]
Message-ID: <20200418134815.6519-7-sashal@kernel.org> (raw)
In-Reply-To: <20200418134815.6519-1-sashal@kernel.org>
From: Jacob Pan <jacob.jun.pan@linux.intel.com>
[ Upstream commit 902baf61adf6b187f0a6b789e70d788ea71ff5bc ]
Move canonical address check before mmget_not_zero() to avoid mm
reference leak.
Fixes: 9d8c3af31607 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/iommu/intel-svm.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
index edac769fc03d8..2998418f0a383 100644
--- a/drivers/iommu/intel-svm.c
+++ b/drivers/iommu/intel-svm.c
@@ -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)
--
2.20.1
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2020-04-18 13:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-18 13:47 [PATCH AUTOSEL 5.6 01/73] iommu/amd: Fix the configuration of GCR3 table root pointer Sasha Levin
2020-04-18 13:47 ` [PATCH AUTOSEL 5.6 05/73] iommu/vt-d: Fix page request descriptor size Sasha Levin
2020-04-18 13:47 ` Sasha Levin [this message]
2020-04-18 13:47 ` [PATCH AUTOSEL 5.6 25/73] dma-direct: fix data truncation in dma_direct_get_required_mask() Sasha Levin
2020-04-18 13:47 ` [PATCH AUTOSEL 5.6 26/73] dma-debug: fix displaying of dma allocation type Sasha Levin
2020-04-18 13:47 ` [PATCH AUTOSEL 5.6 48/73] iommu/virtio: Fix freeing of incomplete domains Sasha Levin
2020-04-18 13:47 ` [PATCH AUTOSEL 5.6 49/73] iommu/vt-d: Add build dependency on IOASID Sasha Levin
2020-04-18 13:47 ` [PATCH AUTOSEL 5.6 51/73] iommu/vt-d: Silence RCU-list debugging warning in dmar_find_atsr() Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200418134815.6519-7-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jroedel@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).