[PATCH v1 1/2] arm64: set POR_EL0 for kernel threads

Kevin Brodsky kevin.brodsky at arm.com
Wed Oct 2 02:45:16 PDT 2024


On 01/10/2024 15:36, Joey Gouly wrote:
> Restrict kernel threads to only have RWX overlays for pkey 0.  This matches
> what arch/x86 does, by defaulting to a restrictive PKRU.
>
> Signed-off-by: Joey Gouly <joey.gouly at arm.com>
> Cc: Will Deacon <will at kernel.org>
> Cc: Catalin Marinas <catalin.marinas at arm.com>
> ---
>  arch/arm64/kernel/process.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
> index 0540653fbf38..94f42df249e3 100644
> --- a/arch/arm64/kernel/process.c
> +++ b/arch/arm64/kernel/process.c
> @@ -410,6 +410,9 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
>  		memset(childregs, 0, sizeof(struct pt_regs));
>  		childregs->pstate = PSR_MODE_EL1h | PSR_IL_BIT;
>  
> +		if (system_supports_poe())
> +			p->thread.por_el0 = POR_EL0_INIT;

Nit: I'd expect this to be done after all the unconditional assignments,
i.e. after setting x19/x20.

Otherwise:

Reviewed-by: Kevin Brodsky <Kevin.Brodsky at arm.com>

Kevin

> +
>  		p->thread.cpu_context.x19 = (unsigned long)args->fn;
>  		p->thread.cpu_context.x20 = (unsigned long)args->fn_arg;
>  	}




More information about the linux-arm-kernel mailing list