[PATCH 01/10] x86/pkeys: Add fault handling for PF_PK page fault bit

Tim Gardner tim.gardner at canonical.com
Wed Oct 19 15:09:01 UTC 2016


From: Dave Hansen <dave.hansen at linux.intel.com>

BugLink: http://bugs.launchpad.net/bugs/1591804

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.hansen at linux.intel.com>
Acked-by: Mel Gorman <mgorman at techsingularity.net>
Cc: linux-arch at vger.kernel.org
Cc: Dave Hansen <dave at sr71.net>
Cc: arnd at arndb.de
Cc: linux-api at vger.kernel.org
Cc: linux-mm at kvack.org
Cc: luto at kernel.org
Cc: akpm at linux-foundation.org
Cc: torvalds at linux-foundation.org
Link: http://lkml.kernel.org/r/20160729163010.DD1FE1ED@viggo.jf.intel.com
Signed-off-by: Thomas Gleixner <tglx at linutronix.de>

(cherry picked from commit e8c6226d483cb28f55cab718065ea1b7226d40e8)
Signed-off-by: Tim Gardner <tim.gardner at canonical.com>
---
 arch/x86/mm/fault.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index dc80230..b88d8ac 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1112,6 +1112,15 @@ access_error(unsigned long error_code, struct vm_area_struct *vma)
 {
 	/* 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
-- 
2.7.4





More information about the kernel-team mailing list