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 <redacted>
Reported-by: Shakeel Butt <redacted>
Fixes 5586cf6 ("powerpc: introduce execute-only pkey")
Signed-off-by: Ram Pai <redacted>
---
arch/powerpc/mm/pkeys.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
@@ -425,9 +425,9 @@ int __arch_override_mprotect_pkey(struct vm_area_struct *vma, int prot,{/**Ifthecurrentlyassociatedpkeyisexecute-only,buttherequested-*protectionrequiresreadorwrite,moveitbacktothedefaultpkey.+*protectionisnotexecute-only,moveitbacktothedefaultpkey.*/-if(vma_is_pkey_exec_only(vma)&&(prot&(PROT_READ|PROT_WRITE)))+if(vma_is_pkey_exec_only(vma)&&(prot!=PROT_EXEC))return0;/*
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 <redacted>
Reported-by: Shakeel Butt <redacted>
Fixes 5586cf6 ("powerpc: introduce execute-only pkey")
@@ -425,9 +425,9 @@ int __arch_override_mprotect_pkey(struct vm_area_struct *vma, int prot,{/**Ifthecurrentlyassociatedpkeyisexecute-only,buttherequested-*protectionrequiresreadorwrite,moveitbacktothedefaultpkey.+*protectionisnotexecute-only,moveitbacktothedefaultpkey.*/-if(vma_is_pkey_exec_only(vma)&&(prot&(PROT_READ|PROT_WRITE)))+if(vma_is_pkey_exec_only(vma)&&(prot!=PROT_EXEC))return0;/*
I think I'm slow today. It took me a while to figure out why this is
buggy. It will leave the VMA with the execute-only pkey if prot = 0.
Other bit combinations work fine IIUC.
Reviewed-by: Thiago Jung Bauermann <redacted>
--
Thiago Jung Bauermann
IBM Linux Technology Center
From: Michael Ellerman <hidden> Date: 2018-06-05 15:19:31
On Fri, 2018-05-04 at 20:01:51 UTC, Ram Pai wrote:
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 <redacted>
Reported-by: Shakeel Butt <redacted>
Fixes 5586cf6 ("powerpc: introduce execute-only pkey")
Signed-off-by: Ram Pai <redacted>
Reviewed-by: Thiago Jung Bauermann <redacted>