mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 16:13:19 +09:00
x86/modules: Set VM_FLUSH_RESET_PERMS in module_alloc()
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
This commit is contained in:
committed by
Peter Zijlstra
parent
2cb15faaed
commit
4c4eb3ecc9
@@ -413,8 +413,6 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
|
|||||||
/* ALLOC_TRAMP flags lets us know we created it */
|
/* ALLOC_TRAMP flags lets us know we created it */
|
||||||
ops->flags |= FTRACE_OPS_FL_ALLOC_TRAMP;
|
ops->flags |= FTRACE_OPS_FL_ALLOC_TRAMP;
|
||||||
|
|
||||||
set_vm_flush_reset_perms(trampoline);
|
|
||||||
|
|
||||||
if (likely(system_state != SYSTEM_BOOTING))
|
if (likely(system_state != SYSTEM_BOOTING))
|
||||||
set_memory_ro((unsigned long)trampoline, npages);
|
set_memory_ro((unsigned long)trampoline, npages);
|
||||||
set_memory_x((unsigned long)trampoline, npages);
|
set_memory_x((unsigned long)trampoline, npages);
|
||||||
|
|||||||
@@ -414,7 +414,6 @@ void *alloc_insn_page(void)
|
|||||||
if (!page)
|
if (!page)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
set_vm_flush_reset_perms(page);
|
|
||||||
/*
|
/*
|
||||||
* First make the page read-only, and only then make it executable to
|
* First make the page read-only, and only then make it executable to
|
||||||
* prevent it from being W+X in between.
|
* prevent it from being W+X in between.
|
||||||
|
|||||||
@@ -74,10 +74,11 @@ void *module_alloc(unsigned long size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
p = __vmalloc_node_range(size, MODULE_ALIGN,
|
p = __vmalloc_node_range(size, MODULE_ALIGN,
|
||||||
MODULES_VADDR + get_module_load_offset(),
|
MODULES_VADDR + get_module_load_offset(),
|
||||||
MODULES_END, gfp_mask,
|
MODULES_END, gfp_mask, PAGE_KERNEL,
|
||||||
PAGE_KERNEL, VM_DEFER_KMEMLEAK, NUMA_NO_NODE,
|
VM_FLUSH_RESET_PERMS | VM_DEFER_KMEMLEAK,
|
||||||
__builtin_return_address(0));
|
NUMA_NO_NODE, __builtin_return_address(0));
|
||||||
|
|
||||||
if (p && (kasan_alloc_module_shadow(p, size, gfp_mask) < 0)) {
|
if (p && (kasan_alloc_module_shadow(p, size, gfp_mask) < 0)) {
|
||||||
vfree(p);
|
vfree(p);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user