Re: [PATCH 31/31] x86, pkeys: execute-only support

From: Thomas Gleixner
Date: Fri Jan 08 2016 - 14:52:20 EST


On Wed, 6 Jan 2016, Dave Hansen wrote:
>
> Signed-off-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>

> diff -puN arch/x86/mm/fault.c~pkeys-79-xonly arch/x86/mm/fault.c
> --- a/arch/x86/mm/fault.c~pkeys-79-xonly 2016-01-06 15:50:16.799660453 -0800
> +++ b/arch/x86/mm/fault.c 2016-01-06 15:50:16.810660949 -0800
> @@ -14,6 +14,8 @@
> #include <linux/prefetch.h> /* prefetchw */
> #include <linux/context_tracking.h> /* exception_enter(), ... */
> #include <linux/uaccess.h> /* faulthandler_disabled() */
> +#include <linux/pkeys.h> /* PKEY_* */
> +#include <uapi/asm-generic/mman-common.h>
>
> #include <asm/cpufeature.h> /* boot_cpu_has, ... */
> #include <asm/traps.h> /* dotraplinkage, ... */
> @@ -23,6 +25,7 @@
> #include <asm/vsyscall.h> /* emulate_vsyscall */
> #include <asm/vm86.h> /* struct vm86 */
> #include <asm/mmu_context.h> /* vma_pkey() */
> +#include <asm/fpu/internal.h> /* fpregs_active() */

These include changes are presumably leftovers from an earlier version. At
least I can't see a reason why we would need them for the change below.

> #define CREATE_TRACE_POINTS
> #include <asm/trace/exceptions.h>
> @@ -1108,6 +1111,16 @@ access_error(unsigned long error_code, s
> */
> 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;
> + }

Except for the above nit: Reviewed-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>