Skip to contentSkip to conversation

uio: fix vma io range check in mmap

PATCH New Bin Wang 1 participant 1 message Mar 25, 2014 Userspace I/O (UIO)

lore
Share & tools
lore

Bin Wang

author
#0 lore raw

PATCH 1/1 uio: fix vma io range check in mmap

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.

---
 drivers/uio/uio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/uio/uio.c +1 -1
index a673e5b..e371f5a 100644
@@ -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;
Signature · 1 line
1.7.0.4