vserver 1.9.3
[linux-2.6.git] / mm / mprotect.c
index 5b438e1..67d02dc 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>
@@ -175,9 +175,11 @@ success:
         * vm_flags and vm_page_prot are protected by the mmap_sem
         * held in write mode.
         */
+       vm_stat_unaccount(vma);
        vma->vm_flags = newflags;
        vma->vm_page_prot = newprot;
        change_protection(vma, start, end, newprot);
+       vm_stat_account(vma);
        return 0;
 
 fail:
@@ -206,6 +208,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);