Merge to Fedora Core 2 kernel-2.6.8-1.521
[linux-2.6.git] / mm / mprotect.c
index 4122bdd..e978ff3 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/highmem.h>
 #include <linux/security.h>
 #include <linux/mempolicy.h>
+#include <linux/personality.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -211,6 +212,12 @@ do_mprotect(struct mm_struct *mm, unsigned long start, size_t len,
                return -EINVAL;
        if (end == start)
                return 0;
+       /*
+        * Does the application expect PROT_READ to imply PROT_EXEC:
+        */
+       if (unlikely((prot & PROT_READ) &&
+                       (current->personality & READ_IMPLIES_EXEC)))
+               prot |= PROT_EXEC;
 
        vm_flags = calc_vm_prot_bits(prot);