From: Dave Hansen <dave.han...@linux.intel.com>

PF_PK means that a memory access violated the protection key
access restrictions.  It is unconditionally an access_error()
because the permissions set on the VMA don't matter (the PKRU
value overrides it), and we never "resolve" PK faults (like
how a COW can "resolve write fault).

Signed-off-by: Dave Hansen <dave.han...@linux.intel.com>
Cc: linux-...@vger.kernel.org
Cc: linux-a...@vger.kernel.org
Cc: linux...@kvack.org
Cc: x...@kernel.org
Cc: torva...@linux-foundation.org
Cc: a...@linux-foundation.org
Cc: Arnd Bergmann <a...@arndb.de>
Cc: mgor...@techsingularity.net
Cc: hu...@google.com
Cc: v...@zeniv.linux.org.uk
---

 b/arch/x86/mm/fault.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff -puN arch/x86/mm/fault.c~pkeys-105-add-pk-to-fault arch/x86/mm/fault.c
--- a/arch/x86/mm/fault.c~pkeys-105-add-pk-to-fault     2016-07-07 
05:46:59.554745699 -0700
+++ b/arch/x86/mm/fault.c       2016-07-07 05:46:59.558745881 -0700
@@ -1112,6 +1112,15 @@ access_error(unsigned long error_code, s
 {
        /* This is only called for the current mm, so: */
        bool foreign = false;
+
+       /*
+        * Read or write was blocked by protection keys.  This is
+        * always an unconditional error and can never result in
+        * a follow-up action to resolve the fault, like a COW.
+        */
+       if (error_code & PF_PK)
+               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
_

Reply via email to