[PATCH v3 2/2] arm64: Conditionally configure PTR_AUTH key of the kernel.

Will Deacon will at kernel.org
Mon Mar 29 15:51:38 BST 2021


On Mon, Feb 08, 2021 at 03:55:54PM +0100, Daniel Kiss wrote:
> If the kernel is not compiled with CONFIG_ARM64_PTR_AUTH_KERNEL=y,
> then no PACI/AUTI instructions are expected while the kernel is running
> so the kernel's key will not be used. Write of a system regiters
> is expensive therefore avoid it not required.

What happens if somebody tries to load a module built with PAC into a kernel
where CONFIG_ARM64_PTR_AUTH_KERNEL=n? Do we reject the module?

I'm not sure how much we care, but I'm a bit worried that it might not go
"obviously" wrong.

> Signed-off-by: Daniel Kiss <daniel.kiss at arm.com>
> ---
>  arch/arm64/include/asm/asm_pointer_auth.h | 63 +++++++++++++----------
>  arch/arm64/include/asm/pointer_auth.h     | 20 +++++--
>  arch/arm64/include/asm/processor.h        |  2 +
>  arch/arm64/kernel/asm-offsets.c           |  2 +
>  4 files changed, 54 insertions(+), 33 deletions(-)

[...]

> diff --git a/arch/arm64/include/asm/pointer_auth.h b/arch/arm64/include/asm/pointer_auth.h
> index c6b4f0603024..b34aebb95757 100644
> --- a/arch/arm64/include/asm/pointer_auth.h
> +++ b/arch/arm64/include/asm/pointer_auth.h
> @@ -30,9 +30,11 @@ struct ptrauth_keys_user {
>  	struct ptrauth_key apga;
>  };
>  
> +#ifdef CONFIG_ARM64_PTR_AUTH_KERNEL
>  struct ptrauth_keys_kernel {
>  	struct ptrauth_key apia;
>  };
> +#endif
>  
>  static inline void ptrauth_keys_init_user(struct ptrauth_keys_user *keys)
>  {
> @@ -54,6 +56,8 @@ do {								\
>  	write_sysreg_s(__pki_v.hi, SYS_ ## k ## KEYHI_EL1);	\
>  } while (0)
>  
> +#ifdef CONFIG_ARM64_PTR_AUTH_KERNEL
> +
>  static __always_inline void ptrauth_keys_init_kernel(struct ptrauth_keys_kernel *keys)
>  {
>  	if (system_supports_address_auth())
> @@ -69,6 +73,8 @@ static __always_inline void ptrauth_keys_switch_kernel(struct ptrauth_keys_kerne
>  	isb();
>  }
>  
> +#endif /* CONFIG_ARM64_PTR_AUTH_KERNEL */

Can you group this with the struct and avoid having two #ifdef blocks?

Will



More information about the linux-arm-kernel mailing list