From: Paul Walmsley <pjw@kernel.org>
To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: torvalds@linux-foundation.org, tglx@linutronix.de,
peterz@infradead.org, broonie@kernel.org,
Deepak Gupta <debug@rivosinc.com>
Subject: [PATCH 5/6] riscv: ptrace: cfi: expand "SS" references to "shadow stack" in uapi headers
Date: Fri, 3 Apr 2026 19:41:49 -0600 [thread overview]
Message-ID: <177526690559.878386.3568474283537905257.stgit@seppa> (raw)
In-Reply-To: <177526680875.878386.16551569883089050686.stgit@seppa>
Similar to the recent change to expand "LP" to "branch landing pad",
let's expand "SS" in the ptrace uapi macros to "shadow stack" as well.
This aligns with the existing prctl() arguments, which use the
expanded "shadow stack" names, rather than just the abbreviation.
Link: https://lore.kernel.org/linux-riscv/CAHk-=whhSLGZAx3N5jJpb4GLFDqH_QvS07D+6BnkPWmCEzTAgw@mail.gmail.com/
Cc: Deepak Gupta <debug@rivosinc.com>
Signed-off-by: Paul Walmsley <pjw@kernel.org>
---
arch/riscv/include/uapi/asm/ptrace.h | 18 +++++++++---------
arch/riscv/kernel/ptrace.c | 10 +++++-----
tools/testing/selftests/riscv/cfi/cfitests.c | 4 ++--
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/arch/riscv/include/uapi/asm/ptrace.h b/arch/riscv/include/uapi/asm/ptrace.h
index 9985bd58148e..3de2b7124aff 100644
--- a/arch/riscv/include/uapi/asm/ptrace.h
+++ b/arch/riscv/include/uapi/asm/ptrace.h
@@ -135,25 +135,25 @@ struct __sc_riscv_cfi_state {
#define PTRACE_CFI_BRANCH_LANDING_PAD_EN_BIT 0
#define PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_BIT 1
#define PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_BIT 2
-#define PTRACE_CFI_SS_EN_BIT 3
-#define PTRACE_CFI_SS_LOCK_BIT 4
-#define PTRACE_CFI_SS_PTR_BIT 5
+#define PTRACE_CFI_SHADOW_STACK_EN_BIT 3
+#define PTRACE_CFI_SHADOW_STACK_LOCK_BIT 4
+#define PTRACE_CFI_SHADOW_STACK_PTR_BIT 5
#define PTRACE_CFI_BRANCH_LANDING_PAD_EN_STATE _BITUL(PTRACE_CFI_BRANCH_LANDING_PAD_EN_BIT)
#define PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_STATE \
_BITUL(PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_BIT)
#define PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_STATE \
_BITUL(PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_BIT)
-#define PTRACE_CFI_SS_EN_STATE _BITUL(PTRACE_CFI_SS_EN_BIT)
-#define PTRACE_CFI_SS_LOCK_STATE _BITUL(PTRACE_CFI_SS_LOCK_BIT)
-#define PTRACE_CFI_SS_PTR_STATE _BITUL(PTRACE_CFI_SS_PTR_BIT)
+#define PTRACE_CFI_SHADOW_STACK_EN_STATE _BITUL(PTRACE_CFI_SHADOW_STACK_EN_BIT)
+#define PTRACE_CFI_SHADOW_STACK_LOCK_STATE _BITUL(PTRACE_CFI_SHADOW_STACK_LOCK_BIT)
+#define PTRACE_CFI_SHADOW_STACK_PTR_STATE _BITUL(PTRACE_CFI_SHADOW_STACK_PTR_BIT)
#define PTRACE_CFI_STATE_INVALID_MASK ~(PTRACE_CFI_BRANCH_LANDING_PAD_EN_STATE | \
PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_STATE | \
PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_STATE | \
- PTRACE_CFI_SS_EN_STATE | \
- PTRACE_CFI_SS_LOCK_STATE | \
- PTRACE_CFI_SS_PTR_STATE)
+ PTRACE_CFI_SHADOW_STACK_EN_STATE | \
+ PTRACE_CFI_SHADOW_STACK_LOCK_STATE | \
+ PTRACE_CFI_SHADOW_STACK_PTR_STATE)
struct __cfi_status {
__u64 cfi_state;
diff --git a/arch/riscv/kernel/ptrace.c b/arch/riscv/kernel/ptrace.c
index b6156625d6f8..93de2e7a3074 100644
--- a/arch/riscv/kernel/ptrace.c
+++ b/arch/riscv/kernel/ptrace.c
@@ -311,10 +311,10 @@ static int riscv_cfi_get(struct task_struct *target,
}
if (is_shstk_enabled(target)) {
- user_cfi.cfi_status.cfi_state |= (PTRACE_CFI_SS_EN_STATE |
- PTRACE_CFI_SS_PTR_STATE);
+ user_cfi.cfi_status.cfi_state |= (PTRACE_CFI_SHADOW_STACK_EN_STATE |
+ PTRACE_CFI_SHADOW_STACK_PTR_STATE);
user_cfi.cfi_status.cfi_state |= is_shstk_locked(target) ?
- PTRACE_CFI_SS_LOCK_STATE : 0;
+ PTRACE_CFI_SHADOW_STACK_LOCK_STATE : 0;
user_cfi.shstk_ptr = get_active_shstk(target);
}
@@ -350,7 +350,7 @@ static int riscv_cfi_set(struct task_struct *target,
*/
if ((user_cfi.cfi_status.cfi_state &
(PTRACE_CFI_BRANCH_LANDING_PAD_EN_STATE | PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_STATE |
- PTRACE_CFI_SS_EN_STATE | PTRACE_CFI_SS_LOCK_STATE)) ||
+ PTRACE_CFI_SHADOW_STACK_EN_STATE | PTRACE_CFI_SHADOW_STACK_LOCK_STATE)) ||
(user_cfi.cfi_status.cfi_state & PTRACE_CFI_STATE_INVALID_MASK))
return -EINVAL;
@@ -365,7 +365,7 @@ static int riscv_cfi_set(struct task_struct *target,
/* If shadow stack enabled on target, set new shadow stack pointer */
if (is_shstk_enabled(target) &&
- (user_cfi.cfi_status.cfi_state & PTRACE_CFI_SS_PTR_STATE))
+ (user_cfi.cfi_status.cfi_state & PTRACE_CFI_SHADOW_STACK_PTR_STATE))
set_active_shstk(target, user_cfi.shstk_ptr);
return 0;
diff --git a/tools/testing/selftests/riscv/cfi/cfitests.c b/tools/testing/selftests/riscv/cfi/cfitests.c
index 68374a27ec81..0dac74b8553c 100644
--- a/tools/testing/selftests/riscv/cfi/cfitests.c
+++ b/tools/testing/selftests/riscv/cfi/cfitests.c
@@ -95,8 +95,8 @@ bool cfi_ptrace_test(void)
switch (ptrace_test_num) {
#define CFI_ENABLE_MASK (PTRACE_CFI_BRANCH_LANDING_PAD_EN_STATE | \
- PTRACE_CFI_SS_EN_STATE | \
- PTRACE_CFI_SS_PTR_STATE)
+ PTRACE_CFI_SHADOW_STACK_EN_STATE | \
+ PTRACE_CFI_SHADOW_STACK_PTR_STATE)
case 0:
if ((cfi_reg.cfi_status.cfi_state & CFI_ENABLE_MASK) != CFI_ENABLE_MASK)
ksft_exit_fail_msg("%s: ptrace_getregset failed, %llu\n", __func__,
next prev parent reply other threads:[~2026-04-04 1:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-04 1:40 [PATCH 0/6] Restructure per-task CFI prctl() and ptrace interfaces Paul Walmsley
2026-04-04 1:41 ` [PATCH 1/6] riscv: ptrace: cfi: fix "PRACE" typo in uapi header Paul Walmsley
2026-04-04 1:41 ` [PATCH 2/6] riscv: cfi: clear CFI lock status in start_thread() Paul Walmsley
2026-04-04 1:41 ` [PATCH 3/6] riscv: ptrace: expand "LP" references to "branch landing pads" in uapi headers Paul Walmsley
2026-04-04 1:41 ` [PATCH 4/6] prctl: rename branch landing pad implementation functions to be more explicit Paul Walmsley
2026-04-04 1:41 ` Paul Walmsley [this message]
2026-04-04 1:41 ` [PATCH 6/6] prctl: cfi: change the branch landing pad prctl()s to be more descriptive Paul Walmsley
2026-04-04 1:50 ` [PATCH 0/6] Restructure per-task CFI prctl() and ptrace interfaces patchwork-bot+linux-riscv
2026-04-05 0:50 ` patchwork-bot+linux-riscv
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=177526690559.878386.3568474283537905257.stgit@seppa \
--to=pjw@kernel.org \
--cc=broonie@kernel.org \
--cc=debug@rivosinc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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®