--- linux/mm/mmap.c.orig 2002-12-11 14:08:39.000000000 +0100 +++ linux/mm/mmap.c 2002-12-11 14:09:54.000000000 +0100 @@ -473,10 +473,6 @@ } -/* - * NOTE: in this function we rely on TASK_SIZE being lower than - * SIZE_MAX-PAGE_SIZE at least. I'm pretty sure that it is. - */ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long pgoff) @@ -493,14 +489,14 @@ if (file && (!file->f_op || !file->f_op->mmap)) return -ENODEV; - if (!len) + if (len == 0) return addr; + + len = PAGE_ALIGN(len); - if (len > TASK_SIZE) + if (len > TASK_SIZE || len == 0) return -EINVAL; - len = PAGE_ALIGN(len); /* This cannot be zero now */ - /* offset overflow? */ if ((pgoff + (len >> PAGE_SHIFT)) < pgoff) return -EINVAL;