]> 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 17:24:35 +0000 (09:24 -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 58e7079f894a31c84807e0b2bad6c7c46cb4fae9..6b3c7dbb67fd95bba4ab2bf93b73e1d933a97f27 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -42,6 +42,7 @@ The following bugs are resolved with this release:
   [25933] Off by one error in __strncmp_avx2
   [25976] nss_compat: internal_end*ent may clobber errno, hiding ERANGE
   [27130] "rep movsb" performance issue
+  [27177] GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on doesn't work
 
 Security related changes:
 
index 95182a508c785d83b93853eca458fb940cbbfc58..a5112ef367c9ba2d6830cdb1172d673ec387091e 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 ($(enable-cet),yes)
index 4f70497aa7f53e90b2394a8ad00d51749b96903d..2160263d4a5e119379480d2229bdf794bab35dc8 100644 (file)
@@ -105,7 +105,11 @@ 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)[0]);
+      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>