aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/page_types.h
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2015-02-13 16:04:55 +0100
committerBorislav Petkov <bp@suse.de>2015-02-19 11:38:54 +0100
commitf47233c2d34f243ecdaac179c3408a39ff9216a7 (patch)
treeb42d4847dd27acbea3526134adfc3f7b5780c5cd /arch/x86/include/asm/page_types.h
parentLinux 3.19 (diff)
downloadlinux-dev-f47233c2d34f243ecdaac179c3408a39ff9216a7.tar.xz
linux-dev-f47233c2d34f243ecdaac179c3408a39ff9216a7.zip
x86/mm/ASLR: Propagate base load address calculation
Commit: e2b32e678513 ("x86, kaslr: randomize module base load address") makes the base address for module to be unconditionally randomized in case when CONFIG_RANDOMIZE_BASE is defined and "nokaslr" option isn't present on the commandline. This is not consistent with how choose_kernel_location() decides whether it will randomize kernel load base. Namely, CONFIG_HIBERNATION disables kASLR (unless "kaslr" option is explicitly specified on kernel commandline), which makes the state space larger than what module loader is looking at. IOW CONFIG_HIBERNATION && CONFIG_RANDOMIZE_BASE is a valid config option, kASLR wouldn't be applied by default in that case, but module loader is not aware of that. Instead of fixing the logic in module.c, this patch takes more generic aproach. It introduces a new bootparam setup data_type SETUP_KASLR and uses that to pass the information whether kaslr has been applied during kernel decompression, and sets a global 'kaslr_enabled' variable accordingly, so that any kernel code (module loading, livepatching, ...) can make decisions based on its value. x86 module loader is converted to make use of this flag. Signed-off-by: Jiri Kosina <jkosina@suse.cz> Acked-by: Kees Cook <keescook@chromium.org> Cc: "H. Peter Anvin" <hpa@linux.intel.com> Link: https://lkml.kernel.org/r/alpine.LNX.2.00.1502101411280.10719@pobox.suse.cz [ Always dump correct kaslr status when panicking ] Signed-off-by: Borislav Petkov <bp@suse.de>
Diffstat (limited to 'arch/x86/include/asm/page_types.h')
-rw-r--r--arch/x86/include/asm/page_types.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/x86/include/asm/page_types.h b/arch/x86/include/asm/page_types.h
index f97fbe3abb67..3d43ce36eaba 100644
--- a/arch/x86/include/asm/page_types.h
+++ b/arch/x86/include/asm/page_types.h
@@ -3,6 +3,7 @@
#include <linux/const.h>
#include <linux/types.h>
+#include <asm/bootparam.h>
/* PAGE_SHIFT determines the page size */
#define PAGE_SHIFT 12
@@ -51,6 +52,8 @@ extern int devmem_is_allowed(unsigned long pagenr);
extern unsigned long max_low_pfn_mapped;
extern unsigned long max_pfn_mapped;
+extern bool kaslr_enabled;
+
static inline phys_addr_t get_max_mapped(void)
{
return (phys_addr_t)max_pfn_mapped << PAGE_SHIFT;