--- armlinux/mm/mmap.c 2002/10/09 01:13:02 1.33.2.4 +++ armlinux/mm/mmap.c 2003/12/02 22:25:25 1.33.2.6 @@ -406,10 +406,12 @@ if (file && (!file->f_op || !file->f_op->mmap)) return -ENODEV; - if ((len = PAGE_ALIGN(len)) == 0) + if (!len) return addr; - if (len > TASK_SIZE) + len = PAGE_ALIGN(len); + + if (len > TASK_SIZE || len == 0) return -EINVAL; /* offset overflow? */ @@ -903,6 +905,8 @@ break; } no_mmaps: + if (last < first) + return; /* * If the PGD bits are not consecutive in the virtual address, the * old method of shifting the VA >> by PGDIR_SHIFT doesn't work. @@ -913,6 +917,7 @@ end_index = pgd_index(last); if (end_index > start_index) { clear_page_tables(mm, start_index, end_index - start_index); + flush_tlb_pgtables(mm, first & PGDIR_MASK, last & PGDIR_MASK); } } @@ -1041,6 +1046,9 @@ if (!len) return addr; + if ((addr + len) > TASK_SIZE || (addr + len) < addr) + return -EINVAL; + /* * mlock MCL_FUTURE? */