On memory tagging status in Glibc
Yury Khrustalev
yury.khrustalev@arm.com
Wed Mar 18 09:43:03 GMT 2026
Hi,
Just to summarise status of the "Enable MTE support for stack" patch [1].
There have been a number of points raised in the comments in that thread,
however, the overall picture is that some preparation needs to be done before
this patch can move forward.
[1]: https://inbox.sourceware.org/libc-alpha/20260310141107.43347-1-claudiu.zissulescu-ianculescu@oracle.com/
I am working on a separate patch for this preparation right now.
In a nutshell, we need to change configure flag --enable-memory-tagging to
allow for two independent macros for heap and stack tagging activated based
on the value of this flag. Furthermore, we need to change how prctl syscall
is made to enable PR_SET_TAGGED_ADDR_CTRL. There has to be only one place
where this happens that should work for both stack and heap tagging.
Before we make the prctl syscall we need to do 2 things:
1) Check HWCAP2_MTE: this happens in init_cpu_features.
Note that the glibc.mem.tagging tunable will need to be processed here
too. This tunable will change as well, and later we will need to figure
out how to merge value of this tunable with whatever ELF marking we will
also use.
2) Scan binaries for dynamic array tags or program properties (or whatever)
and determine flags for the prctl syscall: this happens in _rtld_main_check.
Note that the check function should also be called for dlopen, however it's
up for a discussion what to do at that point.
There will be two macros USE_MTAG_HEAP and USE_MTAG_STACK that should be used
to guard code that only needs to be compiled when corresponding configure option
is selected.
The --enable-memory-tagging flag will take a comma-delimited list of types of
memory tagging, e.g. --enable-memory-tagging=stack,heap. By default, the value
is none.
My plan is to eventually change the default value for aarch64 to heap when the
implementation of tagging in malloc is ready.
The glibc.mem.tagging tunable will be changed to be an enum and it will be used
to select the mode of tagging: none, auto, sync, async. If tunable is provided,
we do prctl syscall PR_SET_TAGGED_ADDR_CTRL with the selected mode (unless it is
overridden based on ELF marking, subject to discussion).
Hope this helps,
Yury
More information about the Libc-alpha
mailing list