net/mlx5e: Implement a mlx5e workqueue
[deliverable/linux.git] / mm / mprotect.c
index fa37c4cd973aa49b4deb227646fcdb2779f7cb24..b650c5412f5884b4b05da98ab8d9995695fc7baf 100644 (file)
@@ -359,6 +359,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
        struct vm_area_struct *vma, *prev;
        int error = -EINVAL;
        const int grows = prot & (PROT_GROWSDOWN|PROT_GROWSUP);
+       const bool rier = (current->personality & READ_IMPLIES_EXEC) &&
+                               (prot & PROT_READ);
+
        prot &= ~(PROT_GROWSDOWN|PROT_GROWSUP);
        if (grows == (PROT_GROWSDOWN|PROT_GROWSUP)) /* can't be both */
                return -EINVAL;
@@ -375,11 +378,6 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
                return -EINVAL;
 
        reqprot = prot;
-       /*
-        * Does the application expect PROT_READ to imply PROT_EXEC:
-        */
-       if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
-               prot |= PROT_EXEC;
 
        down_write(&current->mm->mmap_sem);
 
@@ -414,6 +412,10 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
 
                /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
 
+               /* Does the application expect PROT_READ to imply PROT_EXEC */
+               if (rier && (vma->vm_flags & VM_MAYEXEC))
+                       prot |= PROT_EXEC;
+
                newflags = calc_vm_prot_bits(prot, pkey);
                newflags |= (vma->vm_flags & ~(VM_READ | VM_WRITE | VM_EXEC));
 
@@ -445,6 +447,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
                        error = -ENOMEM;
                        goto out;
                }
+               prot = reqprot;
        }
 out:
        up_write(&current->mm->mmap_sem);
This page took 0.024369 seconds and 5 git commands to generate.