]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
i386: Use __seg_gs qualifiers in {STACK, POINTER}_CHK_GUARD macros
authorUros Bizjak <ubizjak@gmail.com>
Tue, 9 Sep 2025 16:41:54 +0000 (18:41 +0200)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 10 Sep 2025 12:32:40 +0000 (05:32 -0700)
Use the __seg_gs named address space qualifiers to cast reads of
the guard values in the TCB as %gs: prefixed addresses.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
sysdeps/i386/stackguard-macros.h

index 039762927c7595ed968e339c33154a4a19f504f1..574a4095842c28dfa7bf64092dae2c8085f54dc1 100644 (file)
@@ -1,12 +1,7 @@
 #include <stdint.h>
 
 #define STACK_CHK_GUARD \
-  ({ uintptr_t x; asm ("movl %%gs:0x14, %0" : "=r" (x)); x; })
+  (*(uintptr_t __seg_gs *) offsetof (tcbhead_t, stack_guard))
 
 #define POINTER_CHK_GUARD \
-  ({                                                   \
-     uintptr_t x;                                      \
-     asm ("movl %%gs:%c1, %0" : "=r" (x)               \
-         : "i" (offsetof (tcbhead_t, pointer_guard))); \
-     x;                                                        \
-   })
+  (*(uintptr_t __seg_gs *) offsetof (tcbhead_t, pointer_guard))