From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E864F378839 for ; Tue, 7 Jul 2026 19:11:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783451517; cv=none; b=mXSMu1bpQQYSAhaPEtm9/auTZW1cEbUDTbjkK0utI1isB45hQuCWb/8wYlkcunk6z+fx9iOc3A8xU8uvvD3/HKe+vbJYMtN47vEoW7Uqmun0LbWl0xLlxha9s4De1ssF2oh92YwD7ZGNUHoi/gSfFrM6fAtGdV/GqrUTeGdVLBo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783451517; c=relaxed/simple; bh=oI4VL4jJGWTIpMM1H9ulAjfkE6mmeJVBXxKEOuvcC0M=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=sRM9iBmSlWu+tg05v818+tzjaA3OGK6LyoDBfcD57w7NwXlULhnBRAUvaSnVa8nTPerinvavskquu4ikHz62Fj4qvQN9WeKZWhogYEqDXp7vsGxpxgjVaaVyupWWSspYEWy9B28ZLYz63k8a4matmTNLKQ1BLqpnsLIttQadzzM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=kSBxT/Kv; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="kSBxT/Kv" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 11A3B2E9D; Tue, 7 Jul 2026 12:11:51 -0700 (PDT) Received: from fedora (LJ9QCPV96V.austin.arm.com [10.118.109.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 19B923F905; Tue, 7 Jul 2026 12:11:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1783451515; bh=oI4VL4jJGWTIpMM1H9ulAjfkE6mmeJVBXxKEOuvcC0M=; h=From:To:Cc:Subject:Date:From; b=kSBxT/Kv2nJIlHXnWr2OgVm4+4pUW401C5XPztyx4v9dtjNLiHsqSwsEfZBHcF9Un I1vGjM4Ab/3z5aV4ecVYcLRDueZ1Lxa9hna83fJLkTZsstMsVd3c2ikKYT6skH2vFI ijqhYQpZmnNvfwxmhwMPPhuAdoDG36e02+dzg+8g= From: Bill Roberts To: rick.p.edgecombe@intel.com, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: Bill Roberts , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] arch/x86: handle ARCH_SHSTK_ENABLE explicitly Date: Tue, 7 Jul 2026 14:11:35 -0500 Message-ID: <20260707191136.1732277-1-bill.roberts@arm.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The arch_prctl() handling for shadow stack operations checks that the operation being specified is a specific value, except for the ARCH_SHSTK_ENABLE condition, which is treated like a default case in a switch. However, the special handling for ARCH_SHSTK_UNLOCK is only performed when task != current. As a result, an ARCH_SHSTK_UNLOCK request for the current task bypasses the unlock check and falls through to the ARCH_SHSTK_ENABLE path, causing the request to be interpreted as an enable operation instead. To fix this, handle ARCH_SHSTK_ENABLE explicitly rather than relying on it as the default case. This fixes the incorrect dispatch and makes the operation handling more robust by requiring each operation to be matched explicitly. Signed-off-by: Bill Roberts --- 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 0ca64900192f..65c896d02379 100644 --- a/arch/x86/kernel/shstk.c +++ b/arch/x86/kernel/shstk.c @@ -607,11 +607,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; } -- 2.54.0