]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
x86: Set header.feature_1 in TCB for always-on CET [BZ #27177]
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 13 Jan 2021 03:00:13 +0000 (19:00 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 13 Jan 2021 13:03:34 +0000 (05:03 -0800)
Update dl_cet_check() to set header.feature_1 in TCB when both IBT and
SHSTK are always on.

sysdeps/x86/Makefile
sysdeps/x86/dl-cet.c
sysdeps/x86/tst-setjmp-cet.c [new file with mode: 0644]

index c814d5a1958c086cfd9a70947452d224b994b9c1..adaa2a92cd136271099aeaa41770bdcd521259d1 100644 (file)
@@ -48,6 +48,12 @@ endif # $(subdir) == math
 ifeq ($(subdir),setjmp)
 gen-as-const-headers += jmp_buf-ssp.sym
 sysdep_routines += __longjmp_cancel
+ifneq ($(enable-cet),no)
+ifneq ($(have-tunables),no)
+tests += tst-setjmp-cet
+tst-setjmp-cet-ENV = GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on
+endif
+endif
 endif
 
 ifeq ($(subdir),string)
index ed7fd6d10d2a923c2e3bce5de230c65a411c7c60..a63b9c7164e73c2b76a883343eb073c22349c95d 100644 (file)
@@ -47,7 +47,10 @@ dl_cet_check (struct link_map *m, const char *program)
   /* No legacy object check if both IBT and SHSTK are always on.  */
   if (enable_ibt_type == cet_always_on
       && enable_shstk_type == cet_always_on)
-    return;
+    {
+      THREAD_SETMEM (THREAD_SELF, header.feature_1, GL(dl_x86_feature_1));
+      return;
+    }
 
   /* Check if IBT is enabled by kernel.  */
   bool ibt_enabled
diff --git a/sysdeps/x86/tst-setjmp-cet.c b/sysdeps/x86/tst-setjmp-cet.c
new file mode 100644 (file)
index 0000000..42c795d
--- /dev/null
@@ -0,0 +1 @@
+#include <setjmp/tst-setjmp.c>