Skip to content

Instantly share code, notes, and snippets.

@gengor
Created November 17, 2010 14:51
Show Gist options
  • Save gengor/a3f6d7aa9f6aec15e8ea to your computer and use it in GitHub Desktop.
Save gengor/a3f6d7aa9f6aec15e8ea to your computer and use it in GitHub Desktop.
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1048,19 +1048,8 @@ unsigned long do_mmap_pgoff(struct file
#ifdef CONFIG_PAX_MPROTECT
if (mm->pax_flags & MF_PAX_MPROTECT) {
- if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
- gr_log_rwxmmap(file);
-
-#ifdef CONFIG_PAX_EMUPLT
- vm_flags &= ~VM_EXEC;
-#else
- return -EPERM;
-#endif
-
- }
-
- if (!(vm_flags & VM_EXEC))
- vm_flags &= ~VM_MAYEXEC;
+ if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
+ vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
else
vm_flags &= ~VM_MAYWRITE;
}
@@ -2748,10 +2737,8 @@ int install_special_mapping(struct mm_st
#ifdef CONFIG_PAX_MPROTECT
if (mm->pax_flags & MF_PAX_MPROTECT) {
- if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
- return -EPERM;
- if (!(vm_flags & VM_EXEC))
- vm_flags &= ~VM_MAYEXEC;
+ if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
+ vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
else
vm_flags &= ~VM_MAYWRITE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment