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 525BF31E106 for ; Mon, 15 Jun 2026 20:00:14 +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=1781553615; cv=none; b=qPemEYo6K+CYs3rByRw/AiMeVMscJGGBJMKoUaECqR+aTXJJG4oaOOqFOXVpvZupy60ASH51zW1BTTVzOhVxh4IQRJK7y8CdjGC5HeCPPnkSU/sZ5ApHshwiYv32Z2TT214RwRcUmu4ZmEeFWD2JFZeheQ5axu3zJlk8mStKZb8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781553615; c=relaxed/simple; bh=cO+JvwzcXsPZir38MNa45kK3zLc5xZPmc4wjEEOxrVY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=F+D9Gb2O554h23E+Wk7acYJWR4Csx7LL8yejzXEWcbJeNgfvFrly9KqgIUMUG4+aCJvY4gk7d1R6hlhwkRAlE48xEqDUhpI+0+xxVQjMWiceZvavlHz5ZDEKFYIEOcaBlcH0ULfM10dFdfVks16ODeBrLQW4wcT5pd5Y993/NWo= 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=q+Xd2gVO; 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="q+Xd2gVO" 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 C257C354B; Mon, 15 Jun 2026 13:00:08 -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 54A2C3F763; Mon, 15 Jun 2026 13:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1781553613; bh=cO+JvwzcXsPZir38MNa45kK3zLc5xZPmc4wjEEOxrVY=; h=From:To:Cc:Subject:Date:From; b=q+Xd2gVO6oCI3myDvWn9LVx2bBLKR+idt1nlTqa/rLR475cruz5Iy3jBXv70j6hss hwiqq/z6n4FmpzOkhEFZFpmmyDbX6onlYMaakRXi6qVtWHlceLblJIF0d+Z/xHk5wd rgm/ZZdjpVRDK3//TJ5Z9T0GMzMcmgI0iix9YacE= 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] x86/shstk: shadow stack enabling write return code change Date: Mon, 15 Jun 2026 15:00:02 -0500 Message-ID: <20260615200002.259275-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 When enabling write to a shadow stack that is not enabled, it will return EPERM. However, that error code doesn't fit the condition and it should be EINVAL, as that state change cannot be fulfilled due to an invalid argument not a permissions issue. Investigating userspace call sites, they do not rely on this specific error message, nor could 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". Signed-off-by: Bill Roberts --- 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 0ca64900192f..eb690ba90180 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) -- 2.54.0