Re: [PATCH] riscv: ptrace: reject CFI regset access when extensions are absent
From: Paul Walmsley
Date: Wed Oct 07 2026 - 11:46:45 EST
On Thu, 20 Aug 2026, Chen Pei wrote:
> riscv_cfi_get() and riscv_cfi_set() do not check whether the Zicfilp
> or Zicfiss extensions are present. On systems without them,
> PTRACE_GETREGSET on REGSET_CFI still succeeds and returns a zeroed
> user_cfi_state, misleading debuggers into believing the register set
> is available, and PTRACE_SETREGSET silently accepts writes that have
> no effect (e.g. clearing SR_ELP).
>
> Reject the access with -EINVAL when neither branch landing pads nor
> shadow stack is available to userspace, using the same availability
> helpers as the prctl path.
>
> Fixes: 2af7c9cf021c ("riscv/ptrace: expose riscv CFI status and state via ptrace and in core files")
> Signed-off-by: Chen Pei <cp0613@xxxxxxxxxxxxxxxxx>
Thanks, queued for v7.3-rc.
- Paul