x86_64/cet: fix tst-shstk-legacy-1{f,g} tests [BZ #31877]
Checks
| Context |
Check |
Description |
| redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
| redhat-pt-bot/TryBot-32bit |
success
|
Build for i686
|
| linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
fail
|
Test failed
|
| linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Test passed
|
Commit Message
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(-)
Comments
On Sat, Sep 12, 2026 at 7:34 PM Aurelien Jarno <aurelien@aurel32.net> wrote:
>
> 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.
With the current glibc, I got
[hjl@gnu-zen4-1 build-x86_64-linux]$
GLIBC_TUNABLES=glibc.cpu.hwcaps=SHSTK elf/tst-shstk-legacy-1g ; echo
$?
Segmentation fault (core dumped)
GLIBC_TUNABLES=glibc.cpu.hwcaps=SHSTK elf/tst-shstk-legacy-1g
139
[hjl@gnu-zen4-1 build-x86_64-linux]$
on AMD Ryzen 7 8845HS under kernel 7.2.5. Please show the output of
$ ldd elf/tst-shstk-legacy-1g. I got
[hjl@gnu-zen4-1 build-x86_64-linux]$ ldd elf/tst-shstk-legacy-1g
linux-vdso.so.1 (0x00007f6e2cd84000)
/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/elf/tst-shstk-legacy-mod-1.so
(0x00007f6e2cd71000)
libc.so.6 => /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/libc.so.6
(0x00007f6e2ca00000)
/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/elf/ld.so
=> /lib64/ld-linux-x86-64.so.2 (0x00007f6e2cd86000)
[hjl@gnu-zen4-1 build-x86_64-linux]$
On Sat, Sep 12, 2026 at 01:34:20PM +0200, Aurelien Jarno wrote:
> 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.
Same is with the adjacent patch, there is a failure report in Patchwork
for aarch64 but I cannot reproduce it, must be false positive.
Thanks,
Yury
On 2026-09-16 16:30, Yury Khrustalev wrote:
> On Sat, Sep 12, 2026 at 01:34:20PM +0200, Aurelien Jarno wrote:
> > 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.
>
> Same is with the adjacent patch, there is a failure report in Patchwork
> for aarch64 but I cannot reproduce it, must be false positive.
Yes, I already mentioned that to linaro-toolchain@lists.linaro.org. This
patch only changes sysdeps/x86_64, so I really think it is a fault
positive.
Anyway it is superseded by:
https://inbox.sourceware.org/libc-alpha/CAMe9rOqpDK6S+73_rUSa3NoT=eqrXBckpHfn-GQ4RG0DJSMb9Q@mail.gmail.com
Regards
Aurelien
@@ -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 \
@@ -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).