[PATCH] x86_64/cet: fix tst-shstk-legacy-1{f,g} tests [BZ #31877]
Aurelien Jarno
aurelien@aurel32.net
Sat Sep 12 11:34:20 GMT 2026
The tst-shstk-legacy-1f and tst-shstk-legacy-1g tests depend on the
tst-shstk-legacy-mod-1.so module to test that legacy shadow stack code
in init_array does not trigger a segfault in tst-shstk-legacy-1f, while
it does trigger a segfault in tst-shstk-legacy-1g. However, the module
is built but never loaded by the tests.
Load it using LD_PRELOAD. When glibc is configured with --enable-cet,
this allows tst-shstk-legacy-1g to pass on systems with kernel and
hardware support for shadow stacks.
---
sysdeps/x86_64/Makefile | 2 +-
sysdeps/x86_64/tst-shstk-legacy-1g.sh | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile
index ff0463d7ca..688b537a48 100644
--- a/sysdeps/x86_64/Makefile
+++ b/sysdeps/x86_64/Makefile
@@ -466,7 +466,7 @@ $(objpfx)tst-shstk-legacy-1e-static.out: \
$(objpfx)tst-shstk-legacy-1e-static
$(SHELL) $< $(common-objpfx) 2> $@; \
$(evaluate-test)
-tst-shstk-legacy-1f-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=SHSTK
+tst-shstk-legacy-1f-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=SHSTK LD_PRELOAD=$(objpfx)tst-shstk-legacy-mod-1.so
$(objpfx)tst-shstk-legacy-1f: $(objpfx)tst-shstk-legacy-mod-1.so
$(objpfx)tst-shstk-legacy-mod-1.so: \
$(objpfx)tst-shstk-legacy-mod-1.os \
diff --git a/sysdeps/x86_64/tst-shstk-legacy-1g.sh b/sysdeps/x86_64/tst-shstk-legacy-1g.sh
index 449bf7493b..0453e3d3af 100755
--- a/sysdeps/x86_64/tst-shstk-legacy-1g.sh
+++ b/sysdeps/x86_64/tst-shstk-legacy-1g.sh
@@ -22,6 +22,7 @@ common_objpfx=$1; shift
test_program_prefix=$1; shift
GLIBC_TUNABLES=glibc.cpu.hwcaps=SHSTK \
+LD_PRELOAD=${common_objpfx}elf/tst-shstk-legacy-mod-1.so \
${test_program_prefix} \
${common_objpfx}elf/tst-shstk-legacy-1g
# The exit status should only be unsupported (77) or segfault (139).
--
2.53.0
More information about the Libc-alpha
mailing list