Skip to content

Commit

Permalink
uio: fix vma io range check in mmap
Browse files Browse the repository at this point in the history
the vma range size is always page size aligned in mmap, while the
real io space range may not be page aligned, thus leading to range
check failure in the uio_mmap_physical().

for example, in a case of io range size "mem->size == 1KB", and we
have (vma->vm_end - vma->vm_start) == 4KB, due to "len" is aligned
to page size in do_mmap_pgoff().

now fix this issue by align mem->size to page size in the check.

Signed-off-by: Bin Wang <binw@marvell.com>
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Bin Wang authored and Greg Kroah-Hartman committed May 27, 2014
1 parent ca3c61f commit ddb0975
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/uio/uio.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ static int uio_mmap_physical(struct vm_area_struct *vma)

if (mem->addr & ~PAGE_MASK)
return -ENODEV;
if (vma->vm_end - vma->vm_start > mem->size)
if (vma->vm_end - vma->vm_start > PAGE_ALIGN(mem->size))
return -EINVAL;

vma->vm_ops = &uio_physical_vm_ops;
Expand Down

0 comments on commit ddb0975

Please sign in to comment.