selftests/x86: report a skip when shadow stack cannot be enabled
PATCH 1/1 selftests/x86: report a skip when shadow stack cannot be enabled
test_shadow_stack prints "[SKIP] Could not enable Shadow stack" when ARCH_SHSTK_ENABLE fails, as it does on CPUs without shadow stack support and on kernels built without CONFIG_X86_USER_SHADOW_STACK, but then exits with 1, so the kselftest runner reports a failure.
Exit with KSFT_SKIP instead.
---
Found with KernelCI's x86 builds, which leave CONFIG_X86_USER_SHADOW_STACK unset. Tested on an AMD EPYC 9655P with KernelCI's x86_64 build of next-20261104: the test now exits with 4 instead of 1.
tools/testing/selftests/x86/test_shadow_stack.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/selftests/x86/test_shadow_stack.c +3 -1
@@ -36,6 +36,8 @@#include <linux/elf.h> #include <linux/perf_event.h> +#include "kselftest.h" +/* * Define the ABI defines if needed, so people can run the tests * without building the headers.
@@ -1061,7 +1063,7 @@ int main(int argc, char *argv[])if (ARCH_PRCTL (ARCH_SHSTK_ENABLE ,ARCH_SHSTK_SHSTK )) {printf ("[SKIP]\tCould not enable Shadow stack\n" ); -return 1 ; +return KSFT_SKIP ; }if (ARCH_PRCTL (ARCH_SHSTK_DISABLE ,ARCH_SHSTK_SHSTK )) {
Signature · 1 line
2.53.0
Quoted 7 lines · Sasha Levin
test_shadow_stackprints "[SKIP] Could not enable Shadow stack" whenARCH_SHSTK_ENABLEfails, as it does on CPUs without shadow stack support and on kernels built withoutCONFIG_X86_USER_SHADOW_STACK, but then exits with 1, so the kselftest runner reports a failure.Exit with
KSFT_SKIPinstead.
Quoted 7 lines
Fixes 81f30337ef4f ("selftests/x86: Add shadow stack test")Signed-off-by Sasha Levin <[email protected]>---
Found with KernelCI's x86 builds, which leaveCONFIG_X86_USER_SHADOW_STACKunset. Tested on an AMD EPYC 9655P with KernelCI'sx86_64build of next-20261104: the test now exits with 4 instead of 1.
There are some other things labeled SKIP in the same function. But they should probably actually be FAIL, so the one update done in this patch seems appropriate.