]> git.baikalelectronics.ru Git - kernel.git/commit
RISC-V: Make mmap() with PROT_WRITE imply PROT_READ
authorPalmer Dabbelt <palmer@rivosinc.com>
Thu, 13 Oct 2022 19:49:12 +0000 (12:49 -0700)
committerPalmer Dabbelt <palmer@rivosinc.com>
Thu, 13 Oct 2022 19:49:12 +0000 (12:49 -0700)
commitc15fad1ac8d743c6bcfb0cd217427d804899fa0d
tree41138155d3670d302192e9d8b3cf3f4aeeecac14
parentad50f53c2417d4f48402a5c7bfda2666b37df0c9
parentd3cbf9913501a79a787fe6426227b55e192736a0
RISC-V: Make mmap() with PROT_WRITE imply PROT_READ

Commit 106b53788afb ("riscv: mmap with PROT_WRITE but no PROT_READ is
invalid") made mmap() reject mappings with only PROT_WRITE set in an
attempt to fix an observed inconsistency in behavior when attempting
to read from a PROT_WRITE-only mapping. The root cause of this behavior
was actually that while RISC-V's protection_map maps VM_WRITE to
readable PTE permissions (since write-only PTEs are considered reserved
by the privileged spec), the page fault handler considered loads from
VM_WRITE-only VMAs illegal accesses. Fix the underlying cause by
handling faults in VM_WRITE-only VMAs (patch 1) and then re-enable
use of mmap(PROT_WRITE) (patch 2), making RISC-V's behavior consistent
with all other architectures that don't support write-only PTEs.

* remotes/palmer/riscv-wonly:
  riscv: Allow PROT_WRITE-only mmap()
  riscv: Make VM_WRITE imply VM_READ

Link: https://lore.kernel.org/r/20220915193702.2201018-1-abrestic@rivosinc.com/
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>