Skip to content

Commit 3e21938

Browse files
Alexandre Ghitibjorn-rivos
authored andcommitted
riscv: Fix module_alloc() that did not reset the linear mapping permissions
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: 0cff8bf ("riscv: avoid the PIC offset of static percpu data in module beyond 2G limits") Signed-off-by: Alexandre Ghiti <[email protected]> Signed-off-by: Björn Töpel <[email protected]>
1 parent 19f19bd commit 3e21938

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/riscv/kernel/module.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,8 @@ void *module_alloc(unsigned long size)
840840
{
841841
return __vmalloc_node_range(size, 1, MODULES_VADDR,
842842
MODULES_END, GFP_KERNEL,
843-
PAGE_KERNEL, 0, NUMA_NO_NODE,
843+
PAGE_KERNEL, VM_FLUSH_RESET_PERMS,
844+
NUMA_NO_NODE,
844845
__builtin_return_address(0));
845846
}
846847
#endif

0 commit comments

Comments
 (0)