* [PATCH 2/2] selftest/x86: test ARCH_SHSTK_UNLOCK
[not found] <20260615195156.257950-1-bill.roberts@arm.com>
@ 2026-06-15 19:51 ` Bill Roberts
2026-06-29 21:46 ` Edgecombe, Rick P
2026-06-29 21:57 ` Edgecombe, Rick P
0 siblings, 2 replies; 6+ messages in thread
From: Bill Roberts @ 2026-06-15 19:51 UTC (permalink / raw)
To: rick.p.edgecombe, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, H. Peter Anvin, Shuah Khan
Cc: Bill Roberts, linux-kernel, linux-kselftest
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 <bill.roberts@arm.com>
---
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] selftest/x86: test ARCH_SHSTK_UNLOCK
2026-06-29 21:46 ` Edgecombe, Rick P
@ 2026-06-29 17:09 ` Bill Roberts
2026-06-30 17:02 ` Edgecombe, Rick P
0 siblings, 1 reply; 6+ messages in thread
From: Bill Roberts @ 2026-06-29 17:09 UTC (permalink / raw)
To: Edgecombe, Rick P, x86@kernel.org, dave.hansen@linux.intel.com,
shuah@kernel.org, mingo@redhat.com, bp@alien8.de, tglx@kernel.org,
hpa@zytor.com
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
On 6/29/26 4:46 PM, Edgecombe, Rick P wrote:
> 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 <bill.roberts@arm.com>
>> ---
>> 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.
Hey Rick, not really sure how I could make the git commit message and
the comment
more generic, as they seem really generic, can you please be more
specific or give me
a blurb you're looking for here?
>
>> +
>> + 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;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] selftest/x86: test ARCH_SHSTK_UNLOCK
2026-06-29 21:57 ` Edgecombe, Rick P
@ 2026-06-29 17:13 ` Bill Roberts
0 siblings, 0 replies; 6+ messages in thread
From: Bill Roberts @ 2026-06-29 17:13 UTC (permalink / raw)
To: Edgecombe, Rick P, x86@kernel.org, dave.hansen@linux.intel.com,
shuah@kernel.org, mingo@redhat.com, bp@alien8.de, tglx@kernel.org,
hpa@zytor.com
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
On 6/29/26 4:57 PM, Edgecombe, Rick P wrote:
> On Mon, 2026-06-15 at 14:51 -0500, Bill Roberts wrote:
>> + /* 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");
> Should it be a FAIL? And if this path is taken the test will crash because
> shadow stack got accidentally enabled and we can't return from this function. It
> can "goto out" and disable shadow stack before returning.
Yeah Rick, we can do that, not sure why I didn't do that in V1 :-p
>> + return 1;
>> + }
>> +
>> + printf("[OK]\tCouldn't enable Shadow stack via UNLOCK\n");
>> +
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] selftest/x86: test ARCH_SHSTK_UNLOCK
2026-06-15 19:51 ` [PATCH 2/2] selftest/x86: test ARCH_SHSTK_UNLOCK Bill Roberts
@ 2026-06-29 21:46 ` Edgecombe, Rick P
2026-06-29 17:09 ` Bill Roberts
2026-06-29 21:57 ` Edgecombe, Rick P
1 sibling, 1 reply; 6+ messages in thread
From: Edgecombe, Rick P @ 2026-06-29 21:46 UTC (permalink / raw)
To: x86@kernel.org, dave.hansen@linux.intel.com, shuah@kernel.org,
mingo@redhat.com, bp@alien8.de, tglx@kernel.org,
bill.roberts@arm.com, hpa@zytor.com
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
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 <bill.roberts@arm.com>
> ---
> 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;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] selftest/x86: test ARCH_SHSTK_UNLOCK
2026-06-15 19:51 ` [PATCH 2/2] selftest/x86: test ARCH_SHSTK_UNLOCK Bill Roberts
2026-06-29 21:46 ` Edgecombe, Rick P
@ 2026-06-29 21:57 ` Edgecombe, Rick P
2026-06-29 17:13 ` Bill Roberts
1 sibling, 1 reply; 6+ messages in thread
From: Edgecombe, Rick P @ 2026-06-29 21:57 UTC (permalink / raw)
To: x86@kernel.org, dave.hansen@linux.intel.com, shuah@kernel.org,
mingo@redhat.com, bp@alien8.de, tglx@kernel.org,
bill.roberts@arm.com, hpa@zytor.com
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
On Mon, 2026-06-15 at 14:51 -0500, Bill Roberts wrote:
> + /* 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");
Should it be a FAIL? And if this path is taken the test will crash because
shadow stack got accidentally enabled and we can't return from this function. It
can "goto out" and disable shadow stack before returning.
> + return 1;
> + }
> +
> + printf("[OK]\tCouldn't enable Shadow stack via UNLOCK\n");
> +
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] selftest/x86: test ARCH_SHSTK_UNLOCK
2026-06-29 17:09 ` Bill Roberts
@ 2026-06-30 17:02 ` Edgecombe, Rick P
0 siblings, 0 replies; 6+ messages in thread
From: Edgecombe, Rick P @ 2026-06-30 17:02 UTC (permalink / raw)
To: bill.roberts@foss.arm.com, x86@kernel.org, hpa@zytor.com,
mingo@redhat.com, bp@alien8.de, tglx@kernel.org, shuah@kernel.org,
dave.hansen@linux.intel.com
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
On Mon, 2026-06-29 at 12:09 -0500, Bill Roberts wrote:
> > > + /* 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.
>
> Hey Rick, not really sure how I could make the git commit message and
> the comment
> more generic, as they seem really generic, can you please be more
> specific or give me
> a blurb you're looking for here?
I was thinking that the comment was specifically about ARCH_SHSTK_UNLOCK being
able to set shadow stack. But it is really testing whether ARCH_SHSTK_UNLOCK can
be called at all. So maybe:
/*
* Test that ARCH_SHSTK_UNLOCK can't be called
* from normal (non-ptrace) context.
*/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-06-30 17:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260615195156.257950-1-bill.roberts@arm.com>
2026-06-15 19:51 ` [PATCH 2/2] selftest/x86: test ARCH_SHSTK_UNLOCK Bill Roberts
2026-06-29 21:46 ` Edgecombe, Rick P
2026-06-29 17:09 ` Bill Roberts
2026-06-30 17:02 ` Edgecombe, Rick P
2026-06-29 21:57 ` Edgecombe, Rick P
2026-06-29 17:13 ` Bill Roberts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox