diff options
author | Joerg Roedel <jroedel@suse.de> | 2015-11-17 16:11:39 +0100 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2015-12-14 15:37:55 +0100 |
commit | 7f8312a3b31de5676144d9e75f2f2647c8b4b769 (patch) | |
tree | aea5b2b647c49e6b6fc1a215856bb174945861b4 /drivers/iommu | |
parent | 7b5cc1a9c9f4096555345c365508d727149553fe (diff) | |
download | talos-obmc-linux-7f8312a3b31de5676144d9e75f2f2647c8b4b769.tar.gz talos-obmc-linux-7f8312a3b31de5676144d9e75f2f2647c8b4b769.zip |
iommu/vt-d: Do access checks before calling handle_mm_fault()
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.
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Acked-By: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/intel-svm.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c index c69e3f9ec958..50464833d0b8 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) |