One should not be able to use ARCH_SHSTK_UNLOCK via arch_prctl to twiddle feature bits, test that this is the case.
Signed-off-by: Bill Roberts <[email protected]> --- 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 21af54d5f4ea..82a5fefa9df5 100644 --- a/tools/testing/selftests/x86/test_shadow_stack.c +++ b/tools/testing/selftests/x86/test_shadow_stack.c @@ -979,6 +979,14 @@ int main(int argc, char *argv[]) { int ret = 0; + /* test that we can't use unlock to set shadow stack */ + if (!ARCH_PRCTL(ARCH_SHSTK_UNLOCK, ARCH_SHSTK_SHSTK)) { + printf("[SKIP]\tCould enable Shadow stack via UNLOCK\n"); + return 1; + } + + 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

