[PATCH 1/6] cet: Ensure that CPU_FEATURE_ACTIVE does not cache SHSTK/IBT status
Florian Weimer
fweimer@redhat.com
Mon Nov 23 14:13:50 GMT 2026
* Arjun Shankar:
> Since a process can transition from SHSTK to non-SHSTK mode after
> dlopen, mark the feature_1 load volatile so that the compiler always
> reads the current status.
> ---
> sysdeps/unix/sysv/linux/x86/bits/platform/features.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/x86/bits/platform/features.h b/sysdeps/unix/sysv/linux/x86/bits/platform/features.h
> index 3a3b9f0416..55400f687d 100644
> --- a/sysdeps/unix/sysv/linux/x86/bits/platform/features.h
> +++ b/sysdeps/unix/sysv/linux/x86/bits/platform/features.h
> @@ -34,9 +34,9 @@ x86_cpu_cet_active (unsigned int __index)
> #ifdef __x86_64__
> unsigned int __feature_1;
> # ifdef __LP64__
> - __asm__ ("mov %%fs:72, %0" : "=r" (__feature_1));
> + __asm__ __volatile__ ("mov %%fs:72, %0" : "=r" (__feature_1));
> # else
> - __asm__ ("mov %%fs:40, %0" : "=r" (__feature_1));
> + __asm__ __volatile__ ("mov %%fs:40, %0" : "=r" (__feature_1));
> # endif
> if (__index == x86_cpu_IBT)
> return __feature_1 & x86_feature_1_ibt;
It's really unfortunate that we baked this dependency into existing
binaries. <sys/platform.h> is not designed for process attributes
that can change during the execution of the process.
Thanks,
Florian
More information about the Libc-alpha
mailing list