acrn-kernel/arch/riscv/kernel
Alexandre Ghiti d2ebb8143b riscv: Fix module_alloc() that did not reset the linear mapping permissions
[ Upstream commit 749b94b08005929bbc636df21a23322733166e35 ]

After unloading a module, we must reset the linear mapping permissions,
see the example below:

Before unloading a module:

0xffffaf809d65d000-0xffffaf809d6dc000    0x000000011d65d000       508K PTE .   ..     ..   D A G . . W R V
0xffffaf809d6dc000-0xffffaf809d6dd000    0x000000011d6dc000         4K PTE .   ..     ..   D A G . . . R V
0xffffaf809d6dd000-0xffffaf809d6e1000    0x000000011d6dd000        16K PTE .   ..     ..   D A G . . W R V
0xffffaf809d6e1000-0xffffaf809d6e7000    0x000000011d6e1000        24K PTE .   ..     ..   D A G . X . R V

After unloading a module:

0xffffaf809d65d000-0xffffaf809d6e1000    0x000000011d65d000       528K PTE .   ..     ..   D A G . . W R V
0xffffaf809d6e1000-0xffffaf809d6e7000    0x000000011d6e1000        24K PTE .   ..     ..   D A G . X W R V

The last mapping is not reset and we end up with WX mappings in the linear
mapping.

So add VM_FLUSH_RESET_PERMS to our module_alloc() definition.

Fixes: 0cff8bff7a ("riscv: avoid the PIC offset of static percpu data in module beyond 2G limits")
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20231213134027.155327-2-alexghiti@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:27:45 -08:00
..
compat_vdso
probes
vdso
.gitignore
Makefile
alternative.c
asm-offsets.c
cacheinfo.c
compat_signal.c
compat_syscall_table.c
cpu-hotplug.c
cpu.c
cpu_ops.c
cpu_ops_sbi.c
cpu_ops_spinwait.c
cpufeature.c
crash_dump.c
crash_save_regs.S
efi-header.S
efi.c
elf_kexec.c
entry.S
fpu.S
ftrace.c
head.S
head.h
image-vars.h
irq.c
jump_label.c
kexec_relocate.S
kgdb.c
machine_kexec.c
machine_kexec_file.c
mcount-dyn.S
mcount.S
module-sections.c
module.c riscv: Fix module_alloc() that did not reset the linear mapping permissions 2024-01-25 15:27:45 -08:00
patch.c riscv: Check if the code to patch lies in the exit section 2024-01-25 15:27:45 -08:00
perf_callchain.c
perf_regs.c
process.c
ptrace.c
reset.c
riscv_ksyms.c
sbi.c
setup.c
signal.c
smp.c RISC-V: drop error print from riscv_hartid_to_cpuid() 2023-11-28 17:07:23 +00:00
smpboot.c
soc.c
stacktrace.c
suspend.c
suspend_entry.S
sys_riscv.c
syscall_table.c
time.c
trace_irq.c
trace_irq.h
traps.c
traps_misaligned.c riscv: fix misaligned access handling of C.SWSP and C.SDSP 2023-12-13 18:39:16 +01:00
vdso.c
vmlinux-xip.lds.S riscv: Check if the code to patch lies in the exit section 2024-01-25 15:27:45 -08:00
vmlinux.lds.S riscv: Check if the code to patch lies in the exit section 2024-01-25 15:27:45 -08:00