[PATCH 1/6] cet: Ensure that CPU_FEATURE_ACTIVE does not cache SHSTK/IBT status

Arjun Shankar arjun@redhat.com
Mon Nov 23 12:46:55 GMT 2026


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;
-- 
2.56.0



More information about the Libc-alpha mailing list