Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1271307
| From | Joerg Roedel <joro@8bytes.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 4/4] iommu/vt-d: Do access checks before calling handle_mm_fault() |
| Date | 2015-11-17 16:20 +0100 |
| Message-ID | <qvQd3-6JK-15@gated-at.bofh.it> (permalink) |
| References | <qvQd3-6JK-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Joerg Roedel <jroedel@suse.de>
Not doing so is a bug and might trigger a BUG_ON in
handle_mm_fault(). So add the proper permission checks
before calling into mm code.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
drivers/iommu/intel-svm.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
index c69e3f9..5046483 100644
--- a/drivers/iommu/intel-svm.c
+++ b/drivers/iommu/intel-svm.c
@@ -484,6 +484,23 @@ struct page_req_dsc {
};
#define PRQ_RING_MASK ((0x1000 << PRQ_ORDER) - 0x10)
+
+static bool access_error(struct vm_area_struct *vma, struct page_req_dsc *req)
+{
+ unsigned long requested = 0;
+
+ if (req->exe_req)
+ requested |= VM_EXEC;
+
+ if (req->rd_req)
+ requested |= VM_READ;
+
+ if (req->wr_req)
+ requested |= VM_WRITE;
+
+ return (requested & ~vma->vm_flags) != 0;
+}
+
static irqreturn_t prq_event_thread(int irq, void *d)
{
struct intel_iommu *iommu = d;
@@ -539,6 +556,9 @@ static irqreturn_t prq_event_thread(int irq, void *d)
if (!vma || address < vma->vm_start)
goto invalid;
+ if (access_error(vma, req))
+ goto invalid;
+
ret = handle_mm_fault(svm->mm, vma, address,
req->wr_req ? FAULT_FLAG_WRITE : 0);
if (ret & VM_FAULT_ERROR)
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/4 v2] Implement access checks in iommu page fault paths Joerg Roedel <joro@8bytes.org> - 2015-11-17 16:20 +0100
[PATCH 1/4] iommu/amd: Do proper access checking before calling handle_mm_fault() Joerg Roedel <joro@8bytes.org> - 2015-11-17 16:20 +0100
[PATCH 2/4] iommu/amd: Correctly set flags for handle_mm_fault call Joerg Roedel <joro@8bytes.org> - 2015-11-17 16:20 +0100
[PATCH 3/4] iommu/amd: Cleanup error handling in do_fault() Joerg Roedel <joro@8bytes.org> - 2015-11-17 16:20 +0100
[PATCH 4/4] iommu/vt-d: Do access checks before calling handle_mm_fault() Joerg Roedel <joro@8bytes.org> - 2015-11-17 16:20 +0100
Re: [PATCH 4/4] iommu/vt-d: Do access checks before calling handle_mm_fault() David Woodhouse <dwmw2@infradead.org> - 2015-11-20 16:40 +0100
Re: [PATCH 0/4 v2] Implement access checks in iommu page fault paths Oded Gabbay <oded.gabbay@gmail.com> - 2015-11-18 15:10 +0100
Re: [PATCH 0/4 v2] Implement access checks in iommu page fault paths Jesse Barnes <jbarnes@virtuousgeek.org> - 2015-11-18 17:20 +0100
Re: [PATCH 0/4 v2] Implement access checks in iommu page fault paths Joerg Roedel <joro@8bytes.org> - 2015-11-27 13:10 +0100
csiph-web