X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=mm%2Fnommu.c;h=6a2a8aada40163c1653e8612ab29a4602e41d79c;hb=f2a2a7108aa0039ba7a5fe7a0d2ecef2219a7584;hp=365019599df8556c23d493f007a07dbf201add00;hpb=5a3e3b2230980cf2ce6e5e56b816dde19b993939;p=linux-2.6 diff --git a/mm/nommu.c b/mm/nommu.c index 365019599d..6a2a8aada4 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -221,7 +221,7 @@ long vwrite(char *buf, char *addr, unsigned long count) * Allocate enough pages to cover @size from the page level * allocator and map them into continguos kernel virtual space. * - * For tight cotrol over page level allocator and protection flags + * For tight control over page level allocator and protection flags * use __vmalloc() instead. */ void *vmalloc(unsigned long size) @@ -497,15 +497,17 @@ static int validate_mmap_request(struct file *file, (flags & MAP_TYPE) != MAP_SHARED) return -EINVAL; - if (PAGE_ALIGN(len) == 0) - return addr; - - if (len > TASK_SIZE) + if (!len) return -EINVAL; + /* Careful about overflows.. */ + len = PAGE_ALIGN(len); + if (!len || len > TASK_SIZE) + return -ENOMEM; + /* offset overflow? */ if ((pgoff + (len >> PAGE_SHIFT)) < pgoff) - return -EINVAL; + return -EOVERFLOW; if (file) { /* validate file mapping requests */