[PATCH 3/5] riscv: shstk: Use the new common vm_mmap_shadow_stack() helper
Catalin Marinas
catalin.marinas at arm.com
Tue Feb 24 09:57:55 PST 2026
Replace part of the allocate_shadow_stack() content with a call to
vm_mmap_shadow_stack().
Signed-off-by: Catalin Marinas <catalin.marinas at arm.com>
Cc: Paul Walmsley <pjw at kernel.org>
Cc: Palmer Dabbelt <palmer at dabbelt.com>
Cc: Albert Ou <aou at eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex at ghiti.fr>
Cc: Deepak Gupta <debug at rivosinc.com>
---
arch/riscv/kernel/usercfi.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/arch/riscv/kernel/usercfi.c b/arch/riscv/kernel/usercfi.c
index 1adba746f164..7e57f54dc5b2 100644
--- a/arch/riscv/kernel/usercfi.c
+++ b/arch/riscv/kernel/usercfi.c
@@ -230,17 +230,7 @@ int restore_user_shstk(struct task_struct *tsk, unsigned long shstk_ptr)
static unsigned long allocate_shadow_stack(unsigned long addr, unsigned long size,
unsigned long token_offset, bool set_tok)
{
- int flags = MAP_ANONYMOUS | MAP_PRIVATE;
- struct mm_struct *mm = current->mm;
- unsigned long populate;
-
- if (addr)
- flags |= MAP_FIXED_NOREPLACE;
-
- mmap_write_lock(mm);
- addr = do_mmap(NULL, addr, size, PROT_READ, flags,
- VM_SHADOW_STACK | VM_WRITE, 0, &populate, NULL);
- mmap_write_unlock(mm);
+ addr = vm_mmap_shadow_stack(addr, size, 0);
if (!set_tok || IS_ERR_VALUE(addr))
goto out;
More information about the linux-arm-kernel
mailing list