[PATCH 2/2] nptl: Enable MTE for stacks created for threads.

Yury Khrustalev yury.khrustalev@arm.com
Thu Feb 26 09:55:47 GMT 2026


On Fri, Mar 14, 2025 at 01:21:42PM +0000, Cupertino Miranda wrote:
> This patch adds MPROT_MTE flag to newly mapped stacks for threads, if
> DT_AARCH64_MEMTAG_STACK is present in the array of dynamic tags in the
> executable.
> 
> ...
>
> diff --git a/sysdeps/unix/sysv/linux/aarch64/dl-mte-stack.c b/sysdeps/unix/sysv/linux/aarch64/dl-mte-stack.c
> index a4bc82c99b..7ed92855ae 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/dl-mte-stack.c
> +++ b/sysdeps/unix/sysv/linux/aarch64/dl-mte-stack.c
>
> ...
>
> +int
> +stack_mem_tagging_prot (void)
> +{
> +  if ((GLRO(dl_aarch64_cpu_features).mte_state & AARCH64_CPU_FEATURE_MTE_STATE_STACK) == 8
> +      && _dl_mte_mode ())
> +    return PROT_MTE;

Because we don't check the return value of prctl(PR_SET_TAGGED_ADDR_CTRL, ...), we don't
actually know if memory tagging was enabled for the process. If it wasn't, there is probably
no need to add extra mprotect flag for the threads.

Thanks,
Yury



More information about the Libc-alpha mailing list