[PATCH v3 2/2] aarch64: Add memory tagging support for setjmp/longjmp routines

Yury Khrustalev yury.khrustalev@arm.com
Wed Mar 11 11:22:34 GMT 2026


On Tue, Mar 10, 2026 at 04:11:07PM +0200, claudiu.zissulescu-ianculescu@oracle.com wrote:
> From: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
> 
> When we perform stack sanitization using AArch64 memory tagging
> instructions, there may be instances where the tagged memory stack is
> not properly cleaned. Consequently, any further use of this memory
> could lead to false tag mismatch exceptions.
> 
> ...
>
> diff --git a/sysdeps/aarch64/tst-mte-jmp.c b/sysdeps/aarch64/tst-mte-jmp.c
> new file mode 100644
> index 0000000000..664d872d0d
> --- /dev/null
> +++ b/sysdeps/aarch64/tst-mte-jmp.c
>
> ...
>
> +static int
> +do_test (void)
> +{
> +  unsigned long hwcap2;
> +
> +  hwcap2 = getauxval (AT_HWCAP2);
> +  if ((hwcap2 & HWCAP2_MTE) == 0)
> +    return EXIT_UNSUPPORTED;

This check is too late because by the time main() is called, we already
have

  tst-mte-stack: error while loading shared libraries:
    MTE Stack: cannot set stack with PROT_MTE: Invalid argument

on a system without MTE support. Same for another test.

Thanks,
Yury


More information about the Libc-alpha mailing list