Skip to contentSkip to conversation

selftests/x86: report a skip when shadow stack cannot be enabled

PATCH In review Sasha Levin 2 participants 2 messages Nov 5

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

Fixes 81f30337ef4f ("selftests/x86: Add shadow stack test")

---
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
index 3d6ca33edba42..f7051ea525d4e 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Sasha Levin

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.

Quoted 7 lines
Fixes 81f30337ef4f ("selftests/x86: Add shadow stack test")

---
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.

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.