Re: [PATCH v2 09/21] arm64: stackprotector: Re-enable per-task stackprotector

From: Jinjie Ruan

Date: Thu Oct 08 2026 - 03:58:18 EST




在 2026/9/19 0:13, Will Deacon 写道:
> Now that 'current' resides in TPIDRRO_EL0, update the per-task
> stackprotector compiler invocation to use the new register.
>
> Note that this requires a very recent build of clang [1], as (unlike
> GCC), it historically rejected all registers other than SP_EL0.
>
> Cc: Mark Rutland <mark.rutland@xxxxxxx>
> Link: https://github.com/llvm/llvm-project/pull/188054 [1]
> Signed-off-by: Will Deacon <will@xxxxxxxxxx>
> ---
> arch/arm64/Kconfig | 3 +--
> arch/arm64/Makefile | 2 +-
> 2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index b8270b301809..020fcaf36b1b 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -2450,12 +2450,11 @@ config RANDOMIZE_MODULE_REGION_FULL
> exhaustion, modules might be able to fall back to a larger 2GB area.
>
> config CC_HAVE_STACKPROTECTOR_SYSREG
> - def_bool $(cc-option,-mstack-protector-guard=sysreg -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=0)
> + def_bool $(cc-option,-mstack-protector-guard=sysreg -mstack-protector-guard-reg=tpidrro_el0 -mstack-protector-guard-offset=0)
>
> config STACKPROTECTOR_PER_TASK
> def_bool y
> depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_SYSREG
> - depends on BROKEN
>
> config UNWIND_PATCH_PAC_INTO_SCS
> bool "Enable shadow call stack dynamically using code patching"
> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> index 6b005c8fef70..a293ab67818f 100644
> --- a/arch/arm64/Makefile
> +++ b/arch/arm64/Makefile
> @@ -72,7 +72,7 @@ ifeq ($(CONFIG_STACKPROTECTOR_PER_TASK),y)
> prepare: stack_protector_prepare
> stack_protector_prepare: prepare0
> $(eval KBUILD_CFLAGS += -mstack-protector-guard=sysreg \
> - -mstack-protector-guard-reg=sp_el0 \
> + -mstack-protector-guard-reg=tpidrro_el0 \

Reviewed-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>

> -mstack-protector-guard-offset=$(shell \
> awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}' \
> $(objtree)/include/generated/asm-offsets.h))

--
Best regards,
Jinjie