aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/module.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2015-03-05 14:52:18 -0500
committerIngo Molnar <mingo@kernel.org>2015-03-05 14:52:18 -0500
commit33ca8a53f262b4af40611bea331b8c87d133af72 (patch)
treed6468c820a556c4915bcb5b761204a0fb19e8225 /arch/x86/kernel/module.c
parentdb2dcb4f91d5fec5c346a82c309187ee821e2495 (diff)
parent13a7a6ac0a11197edcd0f756a035f472b42cdf8b (diff)
Merge tag 'v4.0-rc2' into irq/core, to refresh the tree before applying new changes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel/module.c')
-rw-r--r--arch/x86/kernel/module.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
index e69f9882bf95..9bbb9b35c144 100644
--- a/arch/x86/kernel/module.c
+++ b/arch/x86/kernel/module.c
@@ -24,6 +24,7 @@
24#include <linux/fs.h> 24#include <linux/fs.h>
25#include <linux/string.h> 25#include <linux/string.h>
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/kasan.h>
27#include <linux/bug.h> 28#include <linux/bug.h>
28#include <linux/mm.h> 29#include <linux/mm.h>
29#include <linux/gfp.h> 30#include <linux/gfp.h>
@@ -46,21 +47,13 @@ do { \
46 47
47#ifdef CONFIG_RANDOMIZE_BASE 48#ifdef CONFIG_RANDOMIZE_BASE
48static unsigned long module_load_offset; 49static unsigned long module_load_offset;
49static int randomize_modules = 1;
50 50
51/* Mutex protects the module_load_offset. */ 51/* Mutex protects the module_load_offset. */
52static DEFINE_MUTEX(module_kaslr_mutex); 52static DEFINE_MUTEX(module_kaslr_mutex);
53 53
54static int __init parse_nokaslr(char *p)
55{
56 randomize_modules = 0;
57 return 0;
58}
59early_param("nokaslr", parse_nokaslr);
60
61static unsigned long int get_module_load_offset(void) 54static unsigned long int get_module_load_offset(void)
62{ 55{
63 if (randomize_modules) { 56 if (kaslr_enabled) {
64 mutex_lock(&module_kaslr_mutex); 57 mutex_lock(&module_kaslr_mutex);
65 /* 58 /*
66 * Calculate the module_load_offset the first time this 59 * Calculate the module_load_offset the first time this
@@ -83,13 +76,22 @@ static unsigned long int get_module_load_offset(void)
83 76
84void *module_alloc(unsigned long size) 77void *module_alloc(unsigned long size)
85{ 78{
79 void *p;
80
86 if (PAGE_ALIGN(size) > MODULES_LEN) 81 if (PAGE_ALIGN(size) > MODULES_LEN)
87 return NULL; 82 return NULL;
88 return __vmalloc_node_range(size, 1, 83
84 p = __vmalloc_node_range(size, MODULE_ALIGN,
89 MODULES_VADDR + get_module_load_offset(), 85 MODULES_VADDR + get_module_load_offset(),
90 MODULES_END, GFP_KERNEL | __GFP_HIGHMEM, 86 MODULES_END, GFP_KERNEL | __GFP_HIGHMEM,
91 PAGE_KERNEL_EXEC, NUMA_NO_NODE, 87 PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
92 __builtin_return_address(0)); 88 __builtin_return_address(0));
89 if (p && (kasan_module_alloc(p, size) < 0)) {
90 vfree(p);
91 return NULL;
92 }
93
94 return p;
93} 95}
94 96
95#ifdef CONFIG_X86_32 97#ifdef CONFIG_X86_32