mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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>,
	"Borislav Petkov (AMD)" <bp@alien8.de>,
	Rick Edgecombe <rick.p.edgecombe@intel.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/cpu] x86/shstk: Return the correct error value when user shadow stacks are disabled
Date: Tue, 15 Sep 2026 02:10:33 -0000	[thread overview]
Message-ID: <178943823398.1720534.11395643464501049097.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20260707184542.1721085-1-bill.roberts@arm.com>

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     9025f3bf73f0565eaa271ecc15f468b1d1e4cbaa
Gitweb:        https://git.kernel.org/tip/9025f3bf73f0565eaa271ecc15f468b1d1e4cbaa
Author:        Bill Roberts <bill.roberts@arm.com>
AuthorDate:    Tue, 07 Jul 2026 13:45:42 -05:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 14 Sep 2026 18:57:04 -07:00

x86/shstk: Return the correct error value when user shadow stacks are disabled

The WRSS instruction (the special instruction that writes to shadow stacks)
cannot be used in userspace unless IA32_U_CET.SH_STK_EN=1 (user shadow
stack is enabled). So the kernel *should* return -EINVAL to userspace if
it tries to enable it when shadow stack is disabled. However, currently,
it will return -EPERM. But, that error code doesn't fit the condition as
the failure is due to an invalid state change request not a permission
issue.

Investigating userspace call sites, like glibc and criu (checkpoint code),
they do not rely on this specific error message, nor could a userspace
effectively utilize this specific return error code to indicate a
difference in "I cannot enable write because of invalid permissions"
versus "I cannot enable write because the shadow stack is disabled".

  [ bp: Fixup commit title. ]

Signed-off-by: Bill Roberts <bill.roberts@arm.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Link: https://patch.msgid.link/20260707184542.1721085-1-bill.roberts@arm.com
---
 arch/x86/kernel/shstk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/shstk.c b/arch/x86/kernel/shstk.c
index 0ca6490..eb690ba 100644
--- a/arch/x86/kernel/shstk.c
+++ b/arch/x86/kernel/shstk.c
@@ -490,7 +490,7 @@ static int wrss_control(bool enable)
 	 * when disabling.
 	 */
 	if (!features_enabled(ARCH_SHSTK_SHSTK))
-		return -EPERM;
+		return -EINVAL;
 
 	/* Already enabled/disabled? */
 	if (features_enabled(ARCH_SHSTK_WRSS) == enable)

      parent reply	other threads:[~2026-09-15  2:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 18:45 [PATCH v2] x86/shstk: shadow stack enabling write return code change Bill Roberts
2026-07-07 18:56 ` Edgecombe, Rick P
2026-07-08 16:46 ` Dave Hansen
2026-07-08 20:56   ` Bill Roberts
2026-07-08 21:00     ` Dave Hansen
2026-07-14 20:22       ` Bill Roberts
2026-07-14 20:27         ` Dave Hansen
2026-09-09 18:50           ` Bill Roberts
2026-09-09 18:59             ` Edgecombe, Rick P
2026-09-02 21:11 ` [tip: x86/cpu] x86/shstk: Shadow " tip-bot2 for Bill Roberts
2026-09-15  2:06   ` Borislav Petkov
2026-09-15  2:10 ` 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=178943823398.1720534.11395643464501049097.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=bill.roberts@arm.com \
    --cc=bp@alien8.de \
    --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®