]> 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:08:27 +0000 (05:08 -0800)
Update dl_cet_check() to set header.feature_1 in TCB when both IBT and
SHSTK are always on.

(cherry picked from commit 2ef23b520597f4ea1790a669b83e608f24f4cf12)

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

diff --git a/NEWS b/NEWS
index 5c32a966b74e13832cb459345dd99c1affaba85f..8b589b175b0a59d638de06128ebdf780cb385503 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ The following bugs are resolved with this release:
   [26853] aarch64: Missing unwind information in statically linked startup code
   [26932] libc: sh: Multiple floating point functions defined as stubs only
   [27130] "rep movsb" performance issue
+  [27177] GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on doesn't work
 
 Version 2.32
 
index a6736aef2554737fa56b1c5d898ee7075e9b87c8..9736a13e7be0f15c9b43e1ccc4bc8fe685e1c1f4 100644 (file)
@@ -12,6 +12,12 @@ endif
 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 03572f7af6ff18d12ef48b263e7f4fb28d0e1cbd..3cc54a8d534cf0036d18846e186ea841c8327a32 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>