Re: [PATCH v12 17/28] riscv/signal: save and restore of shadow stack for signal

Radim Krčmář
2025-04-10T08:49:34Z

2025-03-14T14:39:36-07:00, Deepak Gupta <debug@rivosinc.com>:
> diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c
> @@ -140,6 +142,62 @@ static long __restore_v_state(struct pt_regs *regs, void __user *sc_vec)
> return copy_from_user(current->thread.vstate.datap, datap, riscv_v_vsize);
> }
>
> +static long save_cfiss_state(struct pt_regs *regs, void __user *sc_cfi)
> +{
> + struct __sc_riscv_cfi_state __user *state = sc_cfi;
> + unsigned long ss_ptr = 0;
> + long err = 0;
> +
> + if (!IS_ENABLED(CONFIG_RISCV_USER_CFI) || !is_shstk_enabled(current))

!is_shstk_enabled() should be enough here.

[The rest looks fine, but I'll need more time to think about it.
I'll return to this patch in v13.]