Skip to content

Commit

Permalink
drm: udl: Properly check framebuffer mmap offsets
Browse files Browse the repository at this point in the history
The memmap options sent to the udl framebuffer driver were not being
checked for all sets of possible crazy values.  Fix this up by properly
bounding the allowed values.

Reported-by: Eyal Itkin <eyalit@checkpoint.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20180321154553.GA18454@kroah.com
  • Loading branch information
Greg Kroah-Hartman authored and Daniel Vetter committed Mar 22, 2018
1 parent b24791f commit 3b82a4d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/gpu/drm/udl/udl_fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,15 @@ static int udl_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
{
unsigned long start = vma->vm_start;
unsigned long size = vma->vm_end - vma->vm_start;
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
unsigned long offset;
unsigned long page, pos;

if (offset + size > info->fix.smem_len)
if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
return -EINVAL;

offset = vma->vm_pgoff << PAGE_SHIFT;

if (offset > info->fix.smem_len || size > info->fix.smem_len - offset)
return -EINVAL;

pos = (unsigned long)info->fix.smem_start + offset;
Expand Down

0 comments on commit 3b82a4d

Please sign in to comment.