[PATCH v2 2/2] selftest/x86: test ARCH_SHSTK_UNLOCK

From: Bill Roberts

Date: Tue Jul 07 2026 - 15:17:40 EST


Test that ARCH_SHSTK_UNLOCK can't be called from normal (non-ptrace)
context.

Signed-off-by: Bill Roberts <bill.roberts@xxxxxxx>
---
tools/testing/selftests/x86/test_shadow_stack.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/tools/testing/selftests/x86/test_shadow_stack.c b/tools/testing/selftests/x86/test_shadow_stack.c
index 3d6ca33edba4..cbe7ca4ebd90 100644
--- a/tools/testing/selftests/x86/test_shadow_stack.c
+++ b/tools/testing/selftests/x86/test_shadow_stack.c
@@ -1059,6 +1059,14 @@ int main(int argc, char *argv[])
{
int ret = 0;

+ /* Test that ARCH_SHSTK_UNLOCK can't be called from normal (non-ptrace) context. */
+ if (!ARCH_PRCTL(ARCH_SHSTK_UNLOCK, ARCH_SHSTK_SHSTK)) {
+ printf("[FAIL]\tARCH_SHSTK_UNLOCK should fail in a non-ptrace context\n");
+ goto out;
+ }
+
+ printf("[OK]\tCouldn't enable Shadow stack via UNLOCK\n");
+
if (ARCH_PRCTL(ARCH_SHSTK_ENABLE, ARCH_SHSTK_SHSTK)) {
printf("[SKIP]\tCould not enable Shadow stack\n");
return 1;
--
2.54.0