diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2023-12-16 08:53:12 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2023-12-18 07:04:18 -0800 |
commit | 442983319ba70de801fc856e8dd4748fba8f7f1b (patch) | |
tree | 0150e4448669869613112e336dc9e1ab9972f452 /sysdeps/x86/tst-cet-legacy-8.c | |
parent | 12ab77e893479a1f7d4666082a48efad79777bb9 (diff) | |
download | glibc-442983319ba70de801fc856e8dd4748fba8f7f1b.tar.gz glibc-442983319ba70de801fc856e8dd4748fba8f7f1b.tar.xz glibc-442983319ba70de801fc856e8dd4748fba8f7f1b.zip |
x86/cet: Don't assume that SHSTK implies IBT
Since shadow stack (SHSTK) is enabled in the Linux kernel without enabling indirect branch tracking (IBT), don't assume that SHSTK implies IBT. Use "CPU_FEATURE_ACTIVE (IBT)" to check if IBT is active and "CPU_FEATURE_ACTIVE (SHSTK)" to check if SHSTK is active.
Diffstat (limited to 'sysdeps/x86/tst-cet-legacy-8.c')
-rw-r--r-- | sysdeps/x86/tst-cet-legacy-8.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sysdeps/x86/tst-cet-legacy-8.c b/sysdeps/x86/tst-cet-legacy-8.c index 5d8d9ba7dc..77d77a5408 100644 --- a/sysdeps/x86/tst-cet-legacy-8.c +++ b/sysdeps/x86/tst-cet-legacy-8.c @@ -18,7 +18,7 @@ #include <stdio.h> #include <stdlib.h> -#include <x86intrin.h> +#include <sys/platform/x86.h> #include <sys/mman.h> #include <support/test-driver.h> #include <support/xsignal.h> @@ -29,11 +29,6 @@ static int do_test (void) { - /* NB: This test should trigger SIGSEGV on CET platforms. If SHSTK - is disabled, assuming IBT is also disabled. */ - if (_get_ssp () == 0) - return EXIT_UNSUPPORTED; - void (*funcp) (void); funcp = xmmap (NULL, 0x1000, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1); @@ -41,8 +36,14 @@ do_test (void) /* Write RET instruction. */ *(char *) funcp = 0xc3; funcp (); + + /* NB: This test should trigger SIGSEGV when IBT is active. We should + reach here if IBT isn't active. */ + if (!CPU_FEATURE_ACTIVE (IBT)) + return EXIT_UNSUPPORTED; + return EXIT_FAILURE; } -#define EXPECTED_SIGNAL (_get_ssp () == 0 ? 0 : SIGSEGV) +#define EXPECTED_SIGNAL (CPU_FEATURE_ACTIVE (IBT) ? SIGSEGV : 0) #include <support/test-driver.c> |