All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] arch/x86: do not allow unlock to set bits
@ 2026-06-15 19:51 Bill Roberts
  2026-06-15 19:51 ` [PATCH 2/2] selftest/x86: test ARCH_SHSTK_UNLOCK Bill Roberts
  2026-06-29 21:44 ` [PATCH 1/2] arch/x86: do not allow unlock to set bits Edgecombe, Rick P
  0 siblings, 2 replies; 9+ messages in thread
From: Bill Roberts @ 2026-06-15 19:51 UTC (permalink / raw)
  To: rick.p.edgecombe, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin
  Cc: Bill Roberts, linux-kernel

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 <bill.roberts@arm.com>
---
 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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-06-30 17:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15 19:51 [PATCH 1/2] arch/x86: do not allow unlock to set bits Bill Roberts
2026-06-15 19:51 ` [PATCH 2/2] selftest/x86: test ARCH_SHSTK_UNLOCK Bill Roberts
2026-06-29 21:46   ` Edgecombe, Rick P
2026-06-29 17:09     ` Bill Roberts
2026-06-30 17:02       ` Edgecombe, Rick P
2026-06-29 21:57   ` Edgecombe, Rick P
2026-06-29 17:13     ` Bill Roberts
2026-06-29 21:44 ` [PATCH 1/2] arch/x86: do not allow unlock to set bits Edgecombe, Rick P
2026-06-29 17:05   ` Bill Roberts

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.