Re: [PATCH v26 10/28] riscv/mm: Implement map_shadow_stack() syscall

Paul Walmsley
2026-01-29T08:42:38Z

Hi,

On Mon, 26 Jan 2026, Deepak Gupta wrote:

> Can you apply following diff on `allocate_shadow_stack` function in this
> patch.
> This fixes the bug that I earlier mentioned. We shouldn't be returning
> location
> to token and instead return base address of shadow stack. Userspace consumer
> should be determining token location itself. This matches the ABI of other
> arches. Sorry for being late on this.
>
> diff --git a/arch/riscv/kernel/usercfi.c b/arch/riscv/kernel/usercfi.c
> index 27b36034ea85..a8530e6afb1e 100644
> --- a/arch/riscv/kernel/usercfi.c
> +++ b/arch/riscv/kernel/usercfi.c
> @@ -232,7 +232,7 @@ static unsigned long allocate_shadow_stack(unsigned long
> addr, unsigned long siz
> {
> int flags = MAP_ANONYMOUS | MAP_PRIVATE;
> struct mm_struct *mm = current->mm;
> - unsigned long populate, tok_loc = 0;
> + unsigned long populate;
>
> if (addr)
> flags |= MAP_FIXED_NOREPLACE;
> @@ -245,13 +245,11 @@ static unsigned long allocate_shadow_stack(unsigned long
> addr, unsigned long siz
> if (!set_tok || IS_ERR_VALUE(addr))
> goto out;
>
> - if (create_rstor_token(addr + token_offset, &tok_loc)) {
> + if (create_rstor_token(addr + token_offset, NULL)) {
> vm_munmap(addr, size);
> return -EINVAL;
> }
>
> - addr = tok_loc;
> -
> out:
> return addr;
> }

Thanks, this fix has been rolled into the queued patch. The Reviewed-by:s
and Tested-by:s have been dropped.

- Paul