[PATCH ] powerpc/pkeys: Detach execute_only key on !PROT_EXEC

Ram Pai linuxram at us.ibm.com
Sat May 5 06:01:51 AEST 2018


Disassociate the exec_key from a VMA if the VMA permission is not
PROT_EXEC anymore.  Otherwise the exec_only key continues to be
associated with the vma, causing unexpected behavior.

The problem was reported on x86 by Shakeel Butt,
which is also applicable on powerpc.

cc: Shakeel Butt <shakeelb at google.com>
Reported-by: Shakeel Butt <shakeelb at google.com>
Fixes 5586cf6 ("powerpc: introduce execute-only pkey")
Signed-off-by: Ram Pai <linuxram at us.ibm.com>
---
 arch/powerpc/mm/pkeys.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c
index e81d59e..fdeb9f5 100644
--- a/arch/powerpc/mm/pkeys.c
+++ b/arch/powerpc/mm/pkeys.c
@@ -425,9 +425,9 @@ int __arch_override_mprotect_pkey(struct vm_area_struct *vma, int prot,
 {
 	/*
 	 * If the currently associated pkey is execute-only, but the requested
-	 * protection requires read or write, move it back to the default pkey.
+	 * protection is not execute-only, move it back to the default pkey.
 	 */
-	if (vma_is_pkey_exec_only(vma) && (prot & (PROT_READ | PROT_WRITE)))
+	if (vma_is_pkey_exec_only(vma) && (prot != PROT_EXEC))
 		return 0;
 
 	/*
-- 
1.7.1



More information about the Linuxppc-dev mailing list