]> www.infradead.org Git - users/hch/configfs.git/commitdiff
riscv: Make VM_WRITE imply VM_READ
authorAndrew Bresticker <abrestic@rivosinc.com>
Thu, 15 Sep 2022 19:37:01 +0000 (15:37 -0400)
committerPalmer Dabbelt <palmer@rivosinc.com>
Thu, 22 Sep 2022 16:44:50 +0000 (09:44 -0700)
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: 2139619bcad7 ("riscv: mmap with PROT_WRITE but no PROT_READ is invalid")
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Signed-off-by: Andrew Bresticker <abrestic@rivosinc.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220915193702.2201018-2-abrestic@rivosinc.com/
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/mm/fault.c

index f2fbd1400b7c9ade4fffd340a64dc96597e4c729..d86f7cebd4a7ef3799089cbbbbe61f1a1b099605 100644 (file)
@@ -184,7 +184,8 @@ static inline bool access_error(unsigned long cause, struct vm_area_struct *vma)
                }
                break;
        case EXC_LOAD_PAGE_FAULT:
-               if (!(vma->vm_flags & VM_READ)) {
+               /* Write implies read */
+               if (!(vma->vm_flags & (VM_READ | VM_WRITE))) {
                        return true;
                }
                break;