[PATCH 0/6] Restructure per-task CFI prctl() and ptrace interfaces

From: Paul Walmsley

Date: Fri Apr 03 2026 - 21:41:35 EST


Restructure the per-task CFI indirect branch landing pad prctl()
interface, as suggested by Linus [1]. In place of the current
approach, which follows the style of shadow stack control prctl()s
(PR_{GET,SET,LOCK}_SHADOW_STACK_STATUS), adopt the style of the
speculation control prctl() constants (PR_{GET,SET}_SPECULATION_CTRL).

Then, to improve readability, expand "indir_br_lp", "lpad", and
related abbreviations in the interfaces, also as requested by Linus.
While here, expand "ss" in the shadow stack ptrace macros to "shadow
stack".

While here, let's fix a few bugs in the interfaces that we should have
caught earlier:

- Fix a misspelling of "PTRACE" in one of the macros that is defined
in a uapi header file

- Add a "lock" parameter to the state locking functions, fixing a bug
when a locked process calls exec()

This series is intended to be applied before the v7.0 release, since
it changes user API constants. This series applies on commit
2ff48e0382102b29cba20cdd8bf16a0f045f6e33 ("selftests: riscv: Add
braces around EXPECT_EQ()") in the RISC-V fixes branch.


- Paul

1. https://lore.kernel.org/linux-riscv/CAHk-=whhSLGZAx3N5jJpb4GLFDqH_QvS07D+6BnkPWmCEzTAgw@xxxxxxxxxxxxxx/

---

Paul Walmsley (5):
riscv: ptrace: cfi: fix "PRACE" typo in uapi header
riscv: ptrace: expand "LP" references to "branch landing pads" in uapi headers
prctl: rename branch landing pad implementation functions to be more explicit
riscv: ptrace: cfi: expand "SS" references to "shadow stack" in uapi headers
prctl: cfi: change the branch landing pad prctl()s to be more descriptive

Zong Li (1):
riscv: cfi: clear CFI lock status in start_thread()


Documentation/arch/riscv/zicfilp.rst | 63 ++++++++++++--------
arch/riscv/include/asm/usercfi.h | 8 +--
arch/riscv/include/uapi/asm/ptrace.h | 42 +++++++------
arch/riscv/kernel/process.c | 2 +
arch/riscv/kernel/ptrace.c | 22 +++----
arch/riscv/kernel/usercfi.c | 39 ++++++------
include/linux/cpu.h | 6 +-
include/uapi/linux/prctl.h | 37 +++++-------
kernel/sys.c | 30 +++++-----
tools/perf/trace/beauty/include/uapi/linux/prctl.h | 36 +++++------
tools/testing/selftests/riscv/cfi/cfitests.c | 13 ++--
11 files changed, 154 insertions(+), 144 deletions(-)