Skip to content
Commit 67180e07 authored by Hsieh-Tseng Shen's avatar Hsieh-Tseng Shen Committed by Greg Kroah-Hartman
Browse files

riscv: mm: Ensure prot of VM_WRITE and VM_EXEC must be readable



[ Upstream commit 6569fc12 ]

Commit 8aeb7b17 ("RISC-V: Make mmap() with PROT_WRITE imply PROT_READ")
allows riscv to use mmap with PROT_WRITE only, and meanwhile mmap with w+x
is also permitted. However, when userspace tries to access this page with
PROT_WRITE|PROT_EXEC, which causes infinite loop at load page fault as
well as it triggers soft lockup. According to riscv privileged spec,
"Writable pages must also be marked readable". The fix to drop the
`PAGE_COPY_READ_EXEC` and then `PAGE_COPY_EXEC` would be just used instead.
This aligns the other arches (i.e arm64) for protection_map.

Fixes: 8aeb7b17 ("RISC-V: Make mmap() with PROT_WRITE imply PROT_READ")
Signed-off-by: default avatarHsieh-Tseng Shen <woodrow.shen@sifive.com>
Reviewed-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20230425102828.1616812-1-woodrow.shen@sifive.com


Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent e4b76cd7
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment