WSL2-Linux-Kernel/arch/riscv/kernel
Alexandre Ghiti c1669b54c3 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 14:52:50 -08:00
..
probes riscv: kprobes: allow writing to x0 2023-11-28 16:56:35 +00:00
vdso riscv: vdso: fix section overlapping under some conditions 2022-12-08 11:28:42 +01:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
Makefile riscv: fix oops caused by irqsoff latency tracer 2022-03-02 11:48:08 +01:00
asm-offsets.c riscv: Introduce structure that group all variables regarding kernel mapping 2021-07-05 18:04:00 -07:00
cacheinfo.c drivers: base: cacheinfo: Get rid of DEFINE_SMP_CALL_CACHE_FUNCTION() 2021-09-01 10:29:10 +02:00
cpu-hotplug.c riscv: cpu-hotplug: clear cpu from numa map when teardown 2022-02-16 12:56:18 +01:00
cpu.c RISC-V: Rename and move plic_find_hart_id() to arch directory 2020-06-09 19:11:20 -07:00
cpu_ops.c treewide: Convert macro and uses of __section(foo) to __section("foo") 2020-10-25 14:51:49 -07:00
cpu_ops_sbi.c RISC-V: Support cpu hotplug 2020-03-31 11:28:30 -07:00
cpu_ops_spinwait.c RISC-V: Add cpu_ops and modify default booting method 2020-03-31 11:25:56 -07:00
cpufeature.c riscv: Add __init section marker to some functions again 2021-05-29 13:39:27 -07:00
crash_dump.c RISC-V: Add crash kernel support 2021-04-26 08:25:24 -07:00
crash_save_regs.S RISC-V: Fixup get incorrect user mode PC for kernel mode regs 2022-08-17 14:22:52 +02:00
efi-header.S RISC-V: Add PE/COFF header for EFI stub 2020-10-02 14:31:16 -07:00
efi.c riscv: read-only pages should not be writable 2022-06-14 18:36:11 +02:00
entry.S riscv: fix race when vmap stack overflow 2022-12-08 11:28:44 +01:00
fpu.S riscv: abstract out CSR names for supervisor vs machine mode 2019-11-05 09:20:42 -08:00
ftrace.c RISC-V: Don't check text_mutex during stop_machine 2023-03-17 08:48:57 +01:00
head.S riscv: Initialize thread pointer before calling C functions 2022-06-09 10:22:26 +02:00
head.h RISC-V: enable XIP 2021-04-26 08:31:28 -07:00
image-vars.h arch/riscv:fix typo in a comment in arch/riscv/kernel/image-vars.h 2021-02-18 23:18:00 -08:00
irq.c RISC-V: Remove do_IRQ() function 2020-06-09 19:11:24 -07:00
jump_label.c riscv: Add jump-label implementation 2020-07-30 11:37:43 -07:00
kexec_relocate.S riscv: Don't use va_pa_offset on kdump 2022-01-27 11:02:50 +01:00
kgdb.c riscv: Fix "no previous prototype" compile warning in kgdb.c file 2020-07-09 20:09:30 -07:00
machine_kexec.c riscv: kexec: Fixup irq controller broken in kexec crash path 2022-12-08 11:28:44 +01:00
mcount-dyn.S riscv: ftrace: Reduce the detour code size to half 2023-03-10 09:40:12 +01:00
mcount.S riscv: Workaround mcount name prior to clang-13 2021-04-26 08:25:01 -07:00
module-sections.c riscv: add missing header file includes 2019-10-28 00:46:01 -07:00
module.c riscv: Fix module_alloc() that did not reset the linear mapping permissions 2024-01-25 14:52:50 -08:00
patch.c riscv: Check if the code to patch lies in the exit section 2024-01-25 14:52:50 -08:00
perf_callchain.c uaccess: fix type mismatch warnings from access_ok() 2022-04-08 14:24:01 +02:00
perf_event.c riscv: perf_event: Make some funciton static 2020-05-11 13:48:19 -07:00
perf_regs.c perf/arch: Remove perf_sample_data::regs_user_copy 2020-11-09 18:12:34 +01:00
process.c riscv: process: fix kernel info leakage 2022-11-16 09:58:23 +01:00
ptrace.c riscv: Ensure the value of FP registers in the core dump file is up to date 2021-08-24 20:54:10 -07:00
reset.c riscv: set default pm_power_off to NULL 2022-08-17 14:22:49 +02:00
riscv_ksyms.c riscv: provide memmove implementation 2020-12-10 17:27:54 -08:00
sbi.c RISC-V Patches for the 5.13 Merge Window, Part 1 2021-05-06 09:24:18 -07:00
setup.c riscv: Do not set initial_boot_params to the linear address of the dtb 2023-05-01 08:23:24 +09:00
signal.c riscv: add icache flush for nommu sigreturn trampoline 2023-04-20 12:13:55 +02:00
smp.c RISC-V: Use common riscv_cpuid_to_hartid_mask() for both SMP=y and SMP=n 2022-01-27 11:02:50 +01:00
smpboot.c riscv: topology: fix default topology reporting 2022-10-26 12:34:22 +02:00
soc.c riscv: Fix builtin DTB handling 2021-01-07 19:00:50 -08:00
stacktrace.c riscv: Use READ_ONCE_NOCHECK in imprecise unwinding stack mode 2023-03-17 08:48:57 +01:00
sys_riscv.c riscv: Allow PROT_WRITE-only mmap() 2022-10-26 12:34:22 +02:00
syscall_table.c riscv/vdso: Refactor asm/vdso.h 2021-10-02 13:42:23 -07:00
time.c RISC-V: time: initialize hrtimer based broadcast clock event device 2023-03-10 09:39:16 +01:00
trace_irq.c riscv: fix oops caused by irqsoff latency tracer 2022-03-02 11:48:08 +01:00
trace_irq.h riscv: fix oops caused by irqsoff latency tracer 2022-03-02 11:48:08 +01:00
traps.c riscv: Avoid enabling interrupts in die() 2023-03-17 08:48:51 +01:00
traps_misaligned.c riscv: fix misaligned access handling of C.SWSP and C.SDSP 2023-12-13 18:36:41 +01:00
vdso.c riscv/vdso: make arch_setup_additional_pages wait for mmap_sem for write killable 2021-10-02 13:42:26 -07:00
vmlinux-xip.lds.S riscv: Check if the code to patch lies in the exit section 2024-01-25 14:52:50 -08:00
vmlinux.lds.S riscv: Check if the code to patch lies in the exit section 2024-01-25 14:52:50 -08:00