--- mmap.c 2003-12-05 09:39:09.000000000 +0800 +++ mmap.c.execproto 2003-12-31 11:25:12.000000000 +0800 @@ -17,6 +17,7 @@ #include #include +#include /* * WARNING: the debugging will use recursive algorithms so never enable this @@ -400,8 +401,13 @@ unsigned long do_mmap_pgoff(struct file 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;