Re: [PATCH v2] x86/shstk: shadow stack enabling write return code change
From: Dave Hansen
Date: Wed Jul 08 2026 - 12:54:12 EST
On 7/7/26 11:45, Bill Roberts wrote:
> The WRSS instruction (the special instruction that writes to shadow stacks)
> cannot be used in userspace unless IA32_U_CET.SH_STK_EN=1 (user shadow
> stack is enabled). So the kernel *should* return -EINVAL to userspace if
> it tries to enable it when shadow stack is disabled. However, currently,
> it will return -EPERM. But, that error code doesn't fit the condition as
> the failure is due to an invalid state change request not a permission
> issue.
>
> Investigating userspace call sites, like glibc and criu (checkpoint code),
> they do not rely on this specific error message, nor could a userspace
> effectively utilize this specific return error code to indicate a
> difference in "I cannot enable write because of invalid permissions"
> versus "I cannot enable write because the shadow stack is disabled".
Hi Bill,
Thanks for the patch. One bit of context I'd appreciate: why do you
care? Were you just auditing the code and something seemed wrong? Were
you doing some ARM code and noticed a mismatch?
What motivated the change?