Skip to content

Commit 7ab72c5

Browse files
abrestic-rivospalmer-dabbelt
authored andcommitted
riscv: Make VM_WRITE imply VM_READ
RISC-V does not presently have write-only mappings as that PTE bit pattern is considered reserved in the privileged spec, so allow handling of read faults in VMAs that have VM_WRITE without VM_READ in order to be consistent with other architectures that have similar limitations. Fixes: 2139619 ("riscv: mmap with PROT_WRITE but no PROT_READ is invalid") Reviewed-by: Atish Patra <[email protected]> Signed-off-by: Andrew Bresticker <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]/ Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 568035b commit 7ab72c5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/riscv/mm/fault.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ static inline bool access_error(unsigned long cause, struct vm_area_struct *vma)
184184
}
185185
break;
186186
case EXC_LOAD_PAGE_FAULT:
187-
if (!(vma->vm_flags & VM_READ)) {
187+
/* Write implies read */
188+
if (!(vma->vm_flags & (VM_READ | VM_WRITE))) {
188189
return true;
189190
}
190191
break;

0 commit comments

Comments
 (0)