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.
Fixes: 81f30337ef4f ("selftests/x86: Add shadow stack test")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
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(-)
diff --git a/tools/testing/selftests/x86/test_shadow_stack.c b/tools/testing/selftests/x86/test_shadow_stack.c
index 3d6ca33edba42..f7051ea525d4e 100644
--- a/tools/testing/selftests/x86/test_shadow_stack.c
+++ b/tools/testing/selftests/x86/test_shadow_stack.c
@@ -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)) {
--
2.53.0