drm/vgem: off by one in vgem_gem_fault()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 3 Jul 2018 12:29:21 +0000 (15:29 +0300)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 3 Jul 2018 13:06:15 +0000 (15:06 +0200)
If page_offset is == num_pages then we end up reading beyond the end of
obj->pages[].

Fixes: af33a9190d02 ("drm/vgem: Enable dmabuf import interfaces")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20180703122921.brlfxl4vx2ybvrd2@kili.mountain
drivers/gpu/drm/vgem/vgem_drv.c

index c64a85950c8293fc39e7a42863460d12cb769253..0e5620f76ee09b43d3fbc2b03ad20e3797bd1d2a 100644 (file)
@@ -74,7 +74,7 @@ static vm_fault_t vgem_gem_fault(struct vm_fault *vmf)
 
        num_pages = DIV_ROUND_UP(obj->base.size, PAGE_SIZE);
 
-       if (page_offset > num_pages)
+       if (page_offset >= num_pages)
                return VM_FAULT_SIGBUS;
 
        mutex_lock(&obj->pages_lock);