--- linux-2.4.22/mm/mmap.c Fri Jun 13 16:51:39 2003 +++ linux-2.4.26/mm/mmap.c Wed Feb 18 14:36:32 2004 @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -69,7 +70,7 @@ return 1; /* The page cache contains buffer pages these days.. */ - free = atomic_read(&page_cache_size); + free = page_cache_size; free += nr_free_pages(); free += nr_swap_pages; @@ -400,8 +401,13 @@ int error; rb_node_t ** rb_link, * rb_parent; - if (file && (!file->f_op || !file->f_op->mmap)) - return -ENODEV; + if (file) { + if (!file->f_op || !file->f_op->mmap) + return -ENODEV; + + if ((prot & PROT_EXEC) && (file->f_vfsmnt->mnt_flags & MNT_NOEXEC)) + return -EPERM; + } if (!len) return addr; @@ -1041,6 +1047,9 @@ if (!len) return addr; + if ((addr + len) > TASK_SIZE || (addr + len) < addr) + return -EINVAL; + /* * mlock MCL_FUTURE? */