]> git.itanic.dy.fi Git - linux-stable/commitdiff
drm/ttm: Fix accesses through vmas with only partial coverage
authorThomas Hellstrom <thellstrom@vmware.com>
Mon, 9 Dec 2013 07:23:57 +0000 (23:23 -0800)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 15 Feb 2014 19:20:13 +0000 (19:20 +0000)
commit d386735588c3e22129c2bc6eb64fc1d37a8f805c upstream.

VMAs covering a bo but that didn't start at the same address space offset as
the bo they were mapping were incorrectly generating SEGFAULT errors in
the fault handler.

Reported-by: Joseph Dolinak <kanilo2@yahoo.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
[bwh: Backported to 3.2: drm_vma_node_start() is open-coded;
 vma_pages() was open-coded]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/gpu/drm/ttm/ttm_bo_vm.c

index 221b924acebe273fb8b19080cd5a90b026256e73..e223175a188d3be2bc89e00b73301b384f16721c 100644 (file)
@@ -144,9 +144,9 @@ static int ttm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
        }
 
        page_offset = ((address - vma->vm_start) >> PAGE_SHIFT) +
-           bo->vm_node->start - vma->vm_pgoff;
-       page_last = ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) +
-           bo->vm_node->start - vma->vm_pgoff;
+               vma->vm_pgoff - bo->vm_node->start;
+       page_last = vma_pages(vma) + vma->vm_pgoff -
+               bo->vm_node->start;
 
        if (unlikely(page_offset >= bo->num_pages)) {
                retval = VM_FAULT_SIGBUS;