android_kernel_xiaomi_sm7250/arch/riscv/kernel
Andrew Bresticker a293360273 riscv: Allow PROT_WRITE-only mmap()
commit 9e2e6042a7ec6504fe8e366717afa2f40cf16488 upstream.

Commit 2139619bcad7 ("riscv: mmap with PROT_WRITE but no PROT_READ is
invalid") made mmap() return EINVAL if PROT_WRITE was set wihtout
PROT_READ with the justification that a write-only PTE is considered a
reserved PTE permission bit pattern in the privileged spec. This check
is unnecessary since we let VM_WRITE imply VM_READ on RISC-V, and it is
inconsistent with other architectures that don't support write-only PTEs,
creating a potential software portability issue. Just remove the check
altogether and let PROT_WRITE imply PROT_READ as is the case on other
architectures.

Note that this also allows PROT_WRITE|PROT_EXEC mappings which were
disallowed prior to the aforementioned commit; PROT_READ is implied in
such mappings as well.

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-3-abrestic@rivosinc.com/
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-10-26 13:19:21 +02:00
..
vdso riscv: fix vdso build with lld 2020-05-20 08:18:39 +02:00
.gitignore RISC-V: Build Infrastructure 2017-09-26 15:26:49 -07:00
asm-offsets.c RISC-V: Task implementation 2017-09-26 15:26:46 -07:00
cacheinfo.c drivers: base: cacheinfo: Get rid of DEFINE_SMP_CALL_CACHE_FUNCTION() 2021-09-26 13:39:48 +02:00
cpu.c
cpufeature.c RISC-V: User-facing API 2017-09-26 15:26:48 -07:00
entry.S riscv,entry: fix misaligned base for excp_vect_table 2021-04-16 11:49:30 +02:00
ftrace.c RISC-V: Take text_mutex in ftrace_init_nop() 2020-10-01 13:14:50 +02:00
head.S RISC-V: Add the directive for alignment of stvec's value 2018-08-13 08:31:31 -07:00
irq.c clocksource: new RISC-V SBI timer driver 2018-08-13 08:31:31 -07:00
Makefile perf: riscv: preliminary RISC-V support 2018-06-04 14:02:01 -07:00
mcount-dyn.S riscv/ftrace: Add DYNAMIC_FTRACE_WITH_REGS support 2018-04-02 19:59:13 -07:00
mcount.S riscv: Workaround mcount name prior to clang-13 2021-05-22 10:59:49 +02:00
module-sections.c RISC-V: Add section of GOT.PLT for kernel module 2018-04-02 20:00:54 -07:00
module.c riscv: Fix auipc+jalr relocation range checks 2022-03-16 13:20:27 +01:00
module.lds riscv module: remove (NOLOAD) 2022-04-15 14:15:00 +02:00
perf_event.c RISC-V: Fix !CONFIG_SMP compilation error 2018-08-13 08:31:32 -07:00
process.c Merge branch 'work.whack-a-mole' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2018-01-31 19:18:12 -08:00
ptrace.c riscv: fix trace_sys_exit hook 2019-02-20 10:25:40 +01:00
reset.c
riscv_ksyms.c riscv: split the declaration of __copy_user 2018-06-09 12:34:31 -07:00
setup.c riscv: set max_pfn to the PFN of the last page 2020-05-27 17:37:28 +02:00
signal.c RISC-V: User-facing API 2017-09-26 15:26:48 -07:00
smp.c RISC-V: simplify software interrupt / IPI code 2018-08-13 08:31:30 -07:00
smpboot.c clocksource: new RISC-V SBI timer driver 2018-08-13 08:31:31 -07:00
stacktrace.c riscv: stacktrace: Fix undefined reference to `walk_stackframe' 2020-06-03 08:19:30 +02:00
sys_riscv.c riscv: Allow PROT_WRITE-only mmap() 2022-10-26 13:19:21 +02:00
syscall_table.c RISC-V: Make __NR_riscv_flush_icache visible to userspace 2018-01-07 15:14:37 -08:00
time.c riscv: Fix kernel time_init() 2021-01-27 11:05:37 +01:00
traps.c RISC-V: Add fast call path of crash_kexec() 2022-08-25 11:15:46 +02:00
vdso.c riscv: remove redundant unlikely() 2018-01-30 19:12:06 -08:00
vmlinux.lds.S RISC-V: Build Infrastructure 2017-09-26 15:26:49 -07:00