module.c (9e87e48f8e5de2146842fd0ff436e0256b52c4a9) | module.c (78cac48c0434c82e860fade3cd0420a7a4adbb08) |
---|---|
1/* Kernel module help for x86. 2 Copyright (C) 2001 Rusty Russell. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 --- 19 unchanged lines hidden (view full) --- 28#include <linux/bug.h> 29#include <linux/mm.h> 30#include <linux/gfp.h> 31#include <linux/jump_label.h> 32#include <linux/random.h> 33 34#include <asm/page.h> 35#include <asm/pgtable.h> | 1/* Kernel module help for x86. 2 Copyright (C) 2001 Rusty Russell. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 --- 19 unchanged lines hidden (view full) --- 28#include <linux/bug.h> 29#include <linux/mm.h> 30#include <linux/gfp.h> 31#include <linux/jump_label.h> 32#include <linux/random.h> 33 34#include <asm/page.h> 35#include <asm/pgtable.h> |
36#include <asm/setup.h> |
|
36 37#if 0 38#define DEBUGP(fmt, ...) \ 39 printk(KERN_DEBUG fmt, ##__VA_ARGS__) 40#else 41#define DEBUGP(fmt, ...) \ 42do { \ 43 if (0) \ 44 printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ 45} while (0) 46#endif 47 48#ifdef CONFIG_RANDOMIZE_BASE 49static unsigned long module_load_offset; | 37 38#if 0 39#define DEBUGP(fmt, ...) \ 40 printk(KERN_DEBUG fmt, ##__VA_ARGS__) 41#else 42#define DEBUGP(fmt, ...) \ 43do { \ 44 if (0) \ 45 printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ 46} while (0) 47#endif 48 49#ifdef CONFIG_RANDOMIZE_BASE 50static unsigned long module_load_offset; |
50static int randomize_modules = 1; | |
51 52/* Mutex protects the module_load_offset. */ 53static DEFINE_MUTEX(module_kaslr_mutex); 54 | 51 52/* Mutex protects the module_load_offset. */ 53static DEFINE_MUTEX(module_kaslr_mutex); 54 |
55static int __init parse_nokaslr(char *p) 56{ 57 randomize_modules = 0; 58 return 0; 59} 60early_param("nokaslr", parse_nokaslr); 61 | |
62static unsigned long int get_module_load_offset(void) 63{ | 55static unsigned long int get_module_load_offset(void) 56{ |
64 if (randomize_modules) { | 57 if (kaslr_enabled()) { |
65 mutex_lock(&module_kaslr_mutex); 66 /* 67 * Calculate the module_load_offset the first time this 68 * code is called. Once calculated it stays the same until 69 * reboot. 70 */ 71 if (module_load_offset == 0) 72 module_load_offset = --- 191 unchanged lines hidden --- | 58 mutex_lock(&module_kaslr_mutex); 59 /* 60 * Calculate the module_load_offset the first time this 61 * code is called. Once calculated it stays the same until 62 * reboot. 63 */ 64 if (module_load_offset == 0) 65 module_load_offset = --- 191 unchanged lines hidden --- |