On memory tagging status in Glibc
Sunil Pandey
skpgkp2@gmail.com
Thu Mar 19 02:00:07 GMT 2026
On Wed, Mar 18, 2026 at 2:43 AM Yury Khrustalev <yury.khrustalev@arm.com>
wrote:
> 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.
>
Can it be more generic, something like
--enable-memory-tagging=feature1,feature2..
Where featureN is architecture specific. In case of ARM
feature1=stack
feature2=heap
and so on.
For other arch, feature1 and feature2 can be defined as architecture
specific memory tagging
features.
>
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20260318/34ead5b2/attachment.htm>
More information about the Libc-alpha
mailing list