mm/core, x86/mm/pkeys: Add execute-only protection keys support
[cascardo/linux.git] / arch / x86 / mm / fault.c
index d81744e..5877b92 100644 (file)
@@ -1108,6 +1108,16 @@ access_error(unsigned long error_code, struct vm_area_struct *vma)
         */
        if (error_code & PF_PK)
                return 1;
+
+       if (!(error_code & PF_INSTR)) {
+               /*
+                * Assume all accesses require either read or execute
+                * permissions.  This is not an instruction access, so
+                * it requires read permissions.
+                */
+               if (!(vma->vm_flags & VM_READ))
+                       return 1;
+       }
        /*
         * Make sure to check the VMA so that we do not perform
         * faults just to hit a PF_PK as soon as we fill in a