about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2021-01-12 19:00:13 -0800
committerH.J. Lu <hjl.tools@gmail.com>2021-01-13 08:36:36 -0800
commit8113182a97182a691594c7db7dc04410081d5ae0 (patch)
tree04478ef927e14ca5078f59af97d6b4a87a7f293c /sysdeps
parent369b47aaf7464d2007448a389647bbb2e255e98b (diff)
downloadglibc-8113182a97182a691594c7db7dc04410081d5ae0.tar.gz
glibc-8113182a97182a691594c7db7dc04410081d5ae0.tar.xz
glibc-8113182a97182a691594c7db7dc04410081d5ae0.zip
x86: Set header.feature_1 in TCB for always-on CET [BZ #27177]
Update dl_cet_check() to set header.feature_1 in TCB when both IBT and
SHSTK are always on.

(cherry picked from commit 2ef23b520597f4ea1790a669b83e608f24f4cf12)
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/x86/Makefile6
-rw-r--r--sysdeps/x86/dl-cet.c6
-rw-r--r--sysdeps/x86/tst-setjmp-cet.c1
3 files changed, 12 insertions, 1 deletions
diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile
index 95182a508c..a5112ef367 100644
--- a/sysdeps/x86/Makefile
+++ b/sysdeps/x86/Makefile
@@ -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)
diff --git a/sysdeps/x86/dl-cet.c b/sysdeps/x86/dl-cet.c
index 4f70497aa7..2160263d4a 100644
--- a/sysdeps/x86/dl-cet.c
+++ b/sysdeps/x86/dl-cet.c
@@ -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
index 0000000000..42c795d2a8
--- /dev/null
+++ b/sysdeps/x86/tst-setjmp-cet.c
@@ -0,0 +1 @@
+#include <setjmp/tst-setjmp.c>