VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / mm / mprotect.c
index 5b438e1..88041d4 100644 (file)
@@ -17,9 +17,9 @@
 #include <linux/highmem.h>
 #include <linux/security.h>
 #include <linux/mempolicy.h>
+#include <linux/personality.h>
 
 #include <asm/uaccess.h>
-#include <asm/pgalloc.h>
 #include <asm/pgtable.h>
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
@@ -206,6 +206,12 @@ sys_mprotect(unsigned long start, size_t len, unsigned long prot)
                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);