mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 17:43:52 +02:00
'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>
27 lines
623 B
C
27 lines
623 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __ASM_MMAN_H__
|
|
#define __ASM_MMAN_H__
|
|
|
|
#include <linux/compiler.h>
|
|
#include <linux/types.h>
|
|
#include <linux/mm.h>
|
|
#include <uapi/asm/mman.h>
|
|
|
|
static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
|
|
unsigned long pkey __always_unused)
|
|
{
|
|
unsigned long ret = 0;
|
|
|
|
/*
|
|
* If PROT_WRITE was specified, force it to VM_READ | VM_WRITE.
|
|
* Only VM_WRITE means shadow stack.
|
|
*/
|
|
if (prot & PROT_WRITE)
|
|
ret = (VM_READ | VM_WRITE);
|
|
return ret;
|
|
}
|
|
|
|
#define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
|
|
|
|
#endif /* ! __ASM_MMAN_H__ */
|