From 4a68828e3781cd6f61f792daa1dd5904a8f45288 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 12 Jan 2021 19:00:13 -0800 Subject: [PATCH] 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) --- NEWS | 1 + sysdeps/x86/Makefile | 6 ++++++ sysdeps/x86/dl-cet.c | 6 +++++- sysdeps/x86/tst-setjmp-cet.c | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 sysdeps/x86/tst-setjmp-cet.c diff --git a/NEWS b/NEWS index 271f0333147..4f9e4138b8a 100644 --- a/NEWS +++ b/NEWS @@ -77,6 +77,7 @@ The following bugs are resolved with this release: [25423] Array overflow in backtrace on powerpc [25933] Off by one error in __strncmp_avx2 [27130] "rep movsb" performance issue + [27177] GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on doesn't work Security related changes: diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile index 43ad4a79ff6..891a4fdbb04 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 b82ba14e75b..56c37bcd4f4 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 00000000000..42c795d2a86 --- /dev/null +++ b/sysdeps/x86/tst-setjmp-cet.c @@ -0,0 +1 @@ +#include -- 2.47.2