]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
x86/modules: Set VM_FLUSH_RESET_PERMS in module_alloc()
authorThomas Gleixner <tglx@linutronix.de>
Thu, 15 Sep 2022 11:10:44 +0000 (13:10 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 May 2025 12:08:28 +0000 (14:08 +0200)
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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kernel/ftrace.c
arch/x86/kernel/kprobes/core.c
arch/x86/kernel/module.c

index c15e3bdc61e300a8cecef46db842afb44da7c011..fee8c63e15d474424d9da330e6f0dbe450808f65 100644 (file)
@@ -422,8 +422,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);
index 99dd504307fdc46c36116fbd4f643665a6eb24ae..2a0563780ebb2b3ebc850c92a8ed960358625c6b 100644 (file)
@@ -403,7 +403,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.
index 183b8d541b5448b50ba91a22ea0db283efda3dc9..f0f2bbf73f205ea3b0328af8f58c2674fb7cb137 100644 (file)
@@ -74,10 +74,10 @@ 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_module_alloc(p, size, gfp_mask) < 0)) {
                vfree(p);
                return NULL;