Re: [PATCH RESEND v2 1/2] arch/x86: handle ARCH_SHSTK_ENABLE explicitly

From: Bill Roberts

Date: Tue Dec 01 2026 - 09:50:07 EST



On 11/30/26 5:09 PM, Dave Hansen wrote:
While I applaud the restraint in just having an LLM write the changelog,
I had a really hard time reading this. How does this (LLM-assisted)
version look? It feels more readable to me.

--

x86/shstk: Don't treat ARCH_SHSTK_UNLOCK as ARCH_SHSTK_ENABLE

On x86, normal arch_prctl() syscalls and ptrace() callers share
shstk_prctl() to control user shadow stack. It identifies ptrace()
callers by 'task != current'.

ARCH_SHSTK_UNLOCK is only meant for ptrace() callers. Normal syscall
callers should never use it. If they do, they accidentally get
ARCH_SHSTK_ENABLE behavior.

This happens because ARCH_SHSTK_UNLOCK is handled only in the ptrace
case. In the 'task == current' case, shstk_prctl() handles the other
options and assumes that any remaining one is ARCH_SHSTK_ENABLE, so
ARCH_SHSTK_UNLOCK falls through to the enable path.

This is surprising behavior, but does not give userspace any control
that it doesn't already have.

Check for ARCH_SHSTK_ENABLE explicitly and return -EINVAL for any
unhandled option.
LGTM. Is there any other feedback to address and do we want to handle this as a new patch or just amend the commit log when it's applied?

I am good with either.