]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
riscv/mm: ensure PROT_WRITE leads to VM_READ | VM_WRITE
authorDeepak Gupta <debug@rivosinc.com>
Mon, 26 Jan 2026 04:09:53 +0000 (21:09 -0700)
committerPaul Walmsley <pjw@kernel.org>
Mon, 26 Jan 2026 04:09:53 +0000 (21:09 -0700)
commit6c7559f22b6fcb2d4b52c445434c71ade36b004c
tree3d0c2641945ee59b10700161bd2c057f2d37a906
parent79dd4f2f40d0414aab670c46b801b11850306448
riscv/mm: ensure PROT_WRITE leads to VM_READ | VM_WRITE

'arch_calc_vm_prot_bits' is implemented on risc-v to return VM_READ |
VM_WRITE if PROT_WRITE is specified. Similarly 'riscv_sys_mmap' is
updated to convert all incoming PROT_WRITE to (PROT_WRITE | PROT_READ).
This is to make sure that any existing apps using PROT_WRITE still work.

Earlier 'protection_map[VM_WRITE]' used to pick read-write PTE encodings.
Now 'protection_map[VM_WRITE]' will always pick PAGE_SHADOWSTACK PTE
encodings for shadow stack. The above changes ensure that existing apps
continue to work because underneath, the kernel will be picking
'protection_map[VM_WRITE|VM_READ]' PTE encodings.

Reviewed-by: Zong Li <zong.li@sifive.com>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Deepak Gupta <debug@rivosinc.com>
Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de> # QEMU, custom CVA6
Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-6-b55691eacf4f@rivosinc.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/include/asm/mman.h [new file with mode: 0644]
arch/riscv/include/asm/pgtable.h
arch/riscv/kernel/sys_riscv.c
arch/riscv/mm/init.c