[PATCH] CET: Correctly run dlopen tests with SHSTK enabled in hwcaps
Arjun Shankar
arjun@redhat.com
Sat Nov 14 14:16:38 GMT 2026
> I am seeing these failures on a VM with CTE disabled, and I think it would
> trigger on CPUs without CET, kernels without CONFIG_X86_USER_SHADOW_STACK:
>
> FAIL: elf/tst-cet-legacy-4a
> FAIL: elf/tst-cet-legacy-4b
>
> Both passed before the patch. The sibling tests (tst-shstk-legacy-1b/1e/1g)
> return EXIT_UNSUPPORTED when !CPU_FEATURE_ACTIVE (SHSTK); this patch should
> do the same.
>
> But I think there is a catch with the obvious fix:
>
> if (!CPU_FEATURE_ACTIVE (SHSTK))
> FAIL_UNSUPPORTED (...);
>
> Where x86_cpu_cet_active reads %fs:72 with a non-volatile asm, so the
> compiler may reuse the value across the dlopen call.
>
> Making the asm in bits/platform/features.h volatile is probably worth a
> separate fix, since CPU_FEATURE_ACTIVE (SHSTK) can change at run time.
Thanks! When I post a v2, I'll take care of this in a separate patch.
> Two more checks would make 4b and 4c test their policies:
>
> - in 4b, SHSTK should still be enabled after the legacy object is
> loaded;
> - in 4c, glibc.cpu.x86_shstk=off should win over
> glibc.cpu.hwcaps=SHSTK.
>
> Without them, 4b only checks that dlopen does not fail, and the new
> hwcaps setting has no visible effect in 4c.
I believe I ran into an issue with how this is handled during dlopen
and my guess is that the policy check will fail in at least one case.
I'm still looking at it and once I've understood what's going on, I'll
post here.
More information about the Libc-alpha
mailing list