* [PATCH 6.1 1/1] x86/modules: Set VM_FLUSH_RESET_PERMS in module_alloc()
2025-05-21 16:59 [PATCH 6.1 0/1] Oopses on module unload seen on 6.1.y Fedor Pchelkin
@ 2025-05-21 16:59 ` Fedor Pchelkin
2025-05-22 12:17 ` Jack Wang
1 sibling, 0 replies; 3+ messages in thread
From: Fedor Pchelkin @ 2025-05-21 16:59 UTC (permalink / raw)
To: Pawan Gupta, Greg Kroah-Hartman, stable
Cc: Fedor Pchelkin, Steven Rostedt, Masami Hiramatsu, Mark Rutland,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
Peter Zijlstra, Mike Rapoport (Microsoft), linux-kernel,
lvc-project
From: Thomas Gleixner <tglx@linutronix.de>
commit 4c4eb3ecc91f4fee6d6bf7cfbc1e21f2e38d19ff upstream.
Instead of resetting permissions all over the place when freeing module
memory tell the vmalloc code to do so. Avoids the exercise for the next
upcoming user.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220915111143.406703869@infradead.org
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
---
arch/x86/kernel/ftrace.c | 2 --
arch/x86/kernel/kprobes/core.c | 1 -
arch/x86/kernel/module.c | 9 +++++----
3 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index e73743701530..48cf91625a16 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -415,8 +415,6 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
/* ALLOC_TRAMP flags lets us know we created it */
ops->flags |= FTRACE_OPS_FL_ALLOC_TRAMP;
- set_vm_flush_reset_perms(trampoline);
-
if (likely(system_state != SYSTEM_BOOTING))
set_memory_ro((unsigned long)trampoline, npages);
set_memory_x((unsigned long)trampoline, npages);
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 991f00c817e6..180c708879d2 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -427,7 +427,6 @@ void *alloc_insn_page(void)
if (!page)
return NULL;
- set_vm_flush_reset_perms(page);
/*
* First make the page read-only, and only then make it executable to
* prevent it from being W+X in between.
diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
index 7728060b640c..c34ea5e028c4 100644
--- a/arch/x86/kernel/module.c
+++ b/arch/x86/kernel/module.c
@@ -74,10 +74,11 @@ void *module_alloc(unsigned long size)
return NULL;
p = __vmalloc_node_range(size, MODULE_ALIGN,
- MODULES_VADDR + get_module_load_offset(),
- MODULES_END, gfp_mask,
- PAGE_KERNEL, VM_DEFER_KMEMLEAK, NUMA_NO_NODE,
- __builtin_return_address(0));
+ MODULES_VADDR + get_module_load_offset(),
+ MODULES_END, gfp_mask, PAGE_KERNEL,
+ VM_FLUSH_RESET_PERMS | VM_DEFER_KMEMLEAK,
+ NUMA_NO_NODE, __builtin_return_address(0));
+
if (p && (kasan_alloc_module_shadow(p, size, gfp_mask) < 0)) {
vfree(p);
return NULL;
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 6.1 1/1] x86/modules: Set VM_FLUSH_RESET_PERMS in module_alloc()
2025-05-21 16:59 [PATCH 6.1 0/1] Oopses on module unload seen on 6.1.y Fedor Pchelkin
2025-05-21 16:59 ` [PATCH 6.1 1/1] x86/modules: Set VM_FLUSH_RESET_PERMS in module_alloc() Fedor Pchelkin
@ 2025-05-22 12:17 ` Jack Wang
1 sibling, 0 replies; 3+ messages in thread
From: Jack Wang @ 2025-05-22 12:17 UTC (permalink / raw)
To: pchelkin, Pawan Gupta, Greg Kroah-Hartman, stable
Cc: bp, dave.hansen, linux-kernel, lvc-project, mark.rutland,
mhiramat, mingo, peterz, rostedt, rppt, tglx, x86
From: Fedor Pchelkin <pchelkin@ispras.ru>
From: Thomas Gleixner <tglx@linutronix.de>
commit 4c4eb3ecc91f4fee6d6bf7cfbc1e21f2e38d19ff upstream.
Instead of resetting permissions all over the place when freeing module
memory tell the vmalloc code to do so. Avoids the exercise for the next
upcoming user.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220915111143.406703869@infradead.org
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
I confirm this patch fixed the random crashing ontop of 6.1.139 I've experienced
on our Icelake and Cascadelake servers, servers are working fine after appling
the fix, thx!
Tested-by: Jack Wang <jinpu.wang@ionos.com>
^ permalink raw reply [flat|nested] 3+ messages in thread