From: "tip-bot2 for Bill Roberts" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Bill Roberts <bill.roberts@arm.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/mm] x86/shstk: Avoid accidentally treating ARCH_SHSTK_UNLOCK as ARCH_SHSTK_ENABLE
Date: Tue, 01 Dec 2026 23:41:02 -0000 [thread overview]
Message-ID: <179616846251.1190409.331559976257880347.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20261102181708.29178-1-bill.roberts@arm.com>
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: 4ce4f49da646a7775fc6359ce5abb396725b77ad
Gitweb: https://git.kernel.org/tip/4ce4f49da646a7775fc6359ce5abb396725b77ad
Author: Bill Roberts <bill.roberts@arm.com>
AuthorDate: Mon, 02 Nov 2026 12:17:07 -06:00
Committer: Dave Hansen <dave.hansen@linux.intel.com>
CommitterDate: Tue, 01 Dec 2026 15:32:19 -08:00
x86/shstk: Avoid accidentally treating 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.
[ dhansen+llm: rewrite changelog ]
Signed-off-by: Bill Roberts <bill.roberts@arm.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Link: https://patch.msgid.link/20261102181708.29178-1-bill.roberts@arm.com
---
arch/x86/kernel/shstk.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/shstk.c b/arch/x86/kernel/shstk.c
index df5576d..36ee353 100644
--- a/arch/x86/kernel/shstk.c
+++ b/arch/x86/kernel/shstk.c
@@ -608,11 +608,13 @@ long shstk_prctl(struct task_struct *task, int option, unsigned long arg2)
return -EINVAL;
}
- /* Handle ARCH_SHSTK_ENABLE */
- if (features & ARCH_SHSTK_SHSTK)
- return shstk_setup();
- if (features & ARCH_SHSTK_WRSS)
- return wrss_control(true);
+ if (option == ARCH_SHSTK_ENABLE) {
+ if (features & ARCH_SHSTK_SHSTK)
+ return shstk_setup();
+ if (features & ARCH_SHSTK_WRSS)
+ return wrss_control(true);
+ }
+
return -EINVAL;
}
prev parent reply other threads:[~2026-12-01 23:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 18:17 [PATCH RESEND v2 1/2] arch/x86: handle ARCH_SHSTK_ENABLE explicitly Bill Roberts
2026-11-02 18:17 ` [PATCH RESEND v2 2/2] selftest/x86: test ARCH_SHSTK_UNLOCK Bill Roberts
2026-11-09 18:34 ` Bill Roberts
2026-12-01 23:41 ` [tip: x86/mm] selftest/x86: Test ARCH_SHSTK_UNLOCK tip-bot2 for Bill Roberts
2026-11-30 23:09 ` [PATCH RESEND v2 1/2] arch/x86: handle ARCH_SHSTK_ENABLE explicitly Dave Hansen
2026-12-01 14:49 ` Bill Roberts
2026-12-01 23:41 ` tip-bot2 for Bill Roberts [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179616846251.1190409.331559976257880347.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=bill.roberts@arm.com \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=rick.p.edgecombe@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®