Re: [PATCH RESEND v2 1/2] arch/x86: handle ARCH_SHSTK_ENABLE explicitly
From: Dave Hansen
Date: Mon Nov 30 2026 - 18:10:05 EST
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.