From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=193.142.43.55 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796168466; b=vlRTwHh50nlk9EnSo02BDqiPQaNCWoXlXtRuOy5TvY7LmPwJJgB4Ogc41oDZ8ceuhhsf jIZ9/wPogNX1sV3ril3wDmKRQu/qzVSr24r8NFGo9GkjLG4ZqaAcSRmlZgOBokL4a5WZW K2l5nu5M3RxZ5OZwZjWOE+gJMyHI3oMYmNfM7KejX6iXdH8fYexmQisF+OZcdyFas1WNw Ft3zgJ7l4o5CYWproUMgQHbz1smOTZk3kxnyfrQLfkOtklTAfrxuDjR/L1Z68+0+BUmLb kA9fJjwnMJ+YOkKWTLpUOm/1yeY++FLkrBnaw3cWMgtMuvqvf12MK8VCaf1SjLO1DBw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796168466; h=DMARC-Filter:Date:DKIM-Signature:DKIM-Signature:From:Sender:Reply-to: To:Subject:Cc:In-Reply-To:References:MIME-Version:Message-ID:Robot-ID: Robot-Unsubscribe:Precedence:Content-Type:Content-Transfer-Encoding; bh=ot0Gelp9OIrvVPN+rrc5urIPbqwQrba2JkMy2nx+BkA=; b=oj7ISAhIMdDsSrLEAlTRJJlYOkJC3hOg/Ls3KfE1HTC05EeQnNpLDOMEWhl33oWVFYYe 5l5y5YFIUifeJZB82ykW+bs8oRdih3mQ7VIzVFzBbVWTl65j73UFvya/1tPO5WyOYIw3q 6RfzV41sQyEXyvwyROpKmUkJOUwqP6R1WnlChgpIPPMqtn4hnun9me7Dw0HzMvSUUGdF8 Hpb9dhxo9t2L3heGDEJkMNMjz0L0nWVuAfrIqVYZTxQgn5oycI642BMc8jYjKzOJXv9D7 PPBdMXpIhwgSlNPxVRAmdic8LTHVDImT48/BlsVEKL2/l56YKv8jrq/FGXYmQlCmE2Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=s3UbGhOK; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=TisyX5D4; arc=none smtp.remote-ip=193.142.43.55 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 574A4606A682; Tue, 1 Dec 2026 23:41:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 574A4606A682 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=s3UbGhOK; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=TisyX5D4 Date: Tue, 01 Dec 2026 23:41:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1796168464; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ot0Gelp9OIrvVPN+rrc5urIPbqwQrba2JkMy2nx+BkA=; b=s3UbGhOKqR7m+QnasgOERZjfdHcZVK6J0VOaQRXDeaK8nDTlI6J2f/YbXGiau5SQeYOO+T QPSI32JTsCF72YbrlwEeqROO1SL4UTZvP/Gyx1sIGro8yX1ETOW6KrPprflEPK7eV5099B YDQdLnMuOLTJIVJvmPS9sR/8d7SPh8sMuHJn/L8KLhHPUS9X66jbQFmISZ7tJa4/vv0lFB pAmAZCDCUJ1smbdnpmbj+JAHXBjIJfpvCWnWdy7juyPcRy+tP8tl+aEIKbeG6s3T+0Tpea cq5uIwJLs0rukSEINFEHJXtBPX6dBoAO8mNSgXgYjOWeWWbJYKpDoUVyx06MNw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1796168464; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ot0Gelp9OIrvVPN+rrc5urIPbqwQrba2JkMy2nx+BkA=; b=TisyX5D4msL+fe7HdIWIRbLpKZsHKFYAN3oDDdjQOwV5pPGzd9JruHYuf4gAGAyNKkgq6w gssYT9ph/ThPlFBQ== From: "tip-bot2 for Bill Roberts" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/mm] x86/shstk: Avoid accidentally treating ARCH_SHSTK_UNLOCK as ARCH_SHSTK_ENABLE Cc: Bill Roberts , Dave Hansen , Rick Edgecombe , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20261102181708.29178-1-bill.roberts@arm.com> References: <20261102181708.29178-1-bill.roberts@arm.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-ID: <179616846251.1190409.331559976257880347.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/mm branch of tip: Commit-ID: 4ce4f49da646a7775fc6359ce5abb396725b77ad Gitweb: https://git.kernel.org/tip/4ce4f49da646a7775fc6359ce5abb396725= b77ad Author: Bill Roberts AuthorDate: Mon, 02 Nov 2026 12:17:07 -06:00 Committer: Dave Hansen 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 !=3D 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 =3D=3D 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 Signed-off-by: Dave Hansen Reviewed-by: Rick Edgecombe 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; } =20 - /* Handle ARCH_SHSTK_ENABLE */ - if (features & ARCH_SHSTK_SHSTK) - return shstk_setup(); - if (features & ARCH_SHSTK_WRSS) - return wrss_control(true); + if (option =3D=3D ARCH_SHSTK_ENABLE) { + if (features & ARCH_SHSTK_SHSTK) + return shstk_setup(); + if (features & ARCH_SHSTK_WRSS) + return wrss_control(true); + } + return -EINVAL; } =20