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 417EF3B42EF for ; Mon, 15 Jun 2026 19:52:27 +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=1781553150; cv=none; b=CT+IIBI3jiWu4DTMEfpFfnSTALtf2JyNwb2+fhlEuKdU2xKLWchtVmt1wXmxlUmGiHBdTuAbeklyENbxdLSWzsKbBTjddfSezssHQLZri/WIg/atcMZaTj3Y/LER75TujAD06AO7DSn8q8khnRyjWlGRH/KBX1qkEB+726LtmKg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781553150; c=relaxed/simple; bh=lmFwa7IXcA9vBgJyWTNwFoD83DBOEdUaCBk2XE0GT80=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=VB4CdL1oKif15pNmpPIFpu5yPmh0QQLh1aCXZjy1dUUP9lCYyUkRLmZ5bVshqt8rDKjqjfQdLOjlB5T5CdNxoIaYheZnPDUA6/jkO9EgJua2zVbDEb5gwKUhJWqlzUwjCYl/X0K++RzAwm44sXHQqE25CeJnkZO0kdf7LYZZ6sU= 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=O+56GYMS; 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="O+56GYMS" 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 8B0C1354B; Mon, 15 Jun 2026 12:52:21 -0700 (PDT) Received: from fedora (LJ9QCPV96V.austin.arm.com [10.118.102.30]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 502083F763; Mon, 15 Jun 2026 12:52:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1781553146; bh=lmFwa7IXcA9vBgJyWTNwFoD83DBOEdUaCBk2XE0GT80=; h=From:To:Cc:Subject:Date:From; b=O+56GYMSstPUeMpl2ZlbymMzEVKFmiPT4tCM1XXQmnNYecMpfJfnxNJoS7xsqipz3 sojZhKEpwiEo/pQHbPLrrk1DzysR8p/1ZU0M0F4QB/Lnbcv1aldeplEsPYPKHgK29B kl0kmoJxrLIfz9gzIYM9NeZDl7psax6D+8ngu+cQ= 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 1/2] arch/x86: do not allow unlock to set bits Date: Mon, 15 Jun 2026 14:51:54 -0500 Message-ID: <20260615195156.257950-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 Currently, the code for handling arch_prctl for shadow stack operations is written to exit early on all operations but enable. However, the check for ARCH_SHSTK_UNLOCK is gated on a check for task != current, which means that if current == task, ARCH_SHSTK_UNLOCK can be used to set feature bits by virtue of skipping that check. This seems not as intended, and the check should first check that the operation is ARCH_SHSTK_UNLOCK and then check the task status to determine the error code. Signed-off-by: Bill Roberts --- arch/x86/kernel/shstk.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/shstk.c b/arch/x86/kernel/shstk.c index 0ca64900192f..664167f94acd 100644 --- a/arch/x86/kernel/shstk.c +++ b/arch/x86/kernel/shstk.c @@ -583,12 +583,13 @@ long shstk_prctl(struct task_struct *task, int option, unsigned long arg2) } /* Only allow via ptrace */ - if (task != current) { - if (option == ARCH_SHSTK_UNLOCK && IS_ENABLED(CONFIG_CHECKPOINT_RESTORE)) { - task->thread.features_locked &= ~features; - return 0; - } - return -EINVAL; + if (option == ARCH_SHSTK_UNLOCK) { + if (task == current) + return -EPERM; + if (!IS_ENABLED(CONFIG_CHECKPOINT_RESTORE)) + return -EINVAL; + task->thread.features_locked &= ~features; + return 0; } /* Do not allow to change locked features */ -- 2.54.0