On Mon, 2026-06-15 at 14:51 -0500, Bill Roberts wrote:
> 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;
> +     }

More generally, we should not be able to use ARCH_SHSTK_UNLOCK here. Can we make
the comment generic and not checking for a specific bug? Because it does more
than that.

> +
> +     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;

Reply via email to