[PATCH] 2.4.24-pre1 fix 'noexec' behaviour
From: Nuno Monteiro
Date: Sat Dec 13 2003 - 13:50:27 EST
Hi Marcelo.
This patch submitted by Ullrich Drepper to 2.6 last week fixes the
behaviour of 'noexec' mounted partitions. Up until now it was possible to
circumvent the 'noexec' flag and run binaries off a 'noexec' partition by
using ld-linux.so.2 or any other executable loader. This patch allows to
properly honour the 'noexec' behaviour.
Please review and apply.
Regards,
Nuno
--- linux-2.4.24-pre1/mm/mmap.c.orig 2003-12-13 11:52:56.943963096 +0000
+++ linux-2.4.24-pre1/mm/mmap.c 2003-12-13 11:55:37.674528336 +0000
@@ -14,6 +14,7 @@
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/personality.h>
+#include <linux/mount.h>
#include <asm/uaccess.h>
#include <asm/pgalloc.h>
@@ -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;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/