aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2014-06-13 16:30:36 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-06-16 17:30:44 -0400
commit24f2e0273f80ec262a772059e140a0adef35296d (patch)
treeabc4fadb0de6845ed9c4b88918f14b54e5d213c5
parenta6e15a39048ec3229b9a53425f4384f55f6cc1b3 (diff)
x86, kaslr: boot-time selectable with hibernation
Changes kASLR from being compile-time selectable (blocked by CONFIG_HIBERNATION), to being boot-time selectable (with hibernation available by default) via the "kaslr" kernel command line. Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--Documentation/kernel-parameters.txt11
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--arch/x86/boot/compressed/aslr.c9
-rw-r--r--kernel/power/hibernate.c6
4 files changed, 21 insertions, 6 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index f8f0466b8b1d..884904975d0b 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1474,6 +1474,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1474 js= [HW,JOY] Analog joystick 1474 js= [HW,JOY] Analog joystick
1475 See Documentation/input/joystick.txt. 1475 See Documentation/input/joystick.txt.
1476 1476
1477 kaslr/nokaslr [X86]
1478 Enable/disable kernel and module base offset ASLR
1479 (Address Space Layout Randomization) if built into
1480 the kernel. When CONFIG_HIBERNATION is selected,
1481 kASLR is disabled by default. When kASLR is enabled,
1482 hibernation will be disabled.
1483
1477 keepinitrd [HW,ARM] 1484 keepinitrd [HW,ARM]
1478 1485
1479 kernelcore=nn[KMG] [KNL,X86,IA-64,PPC] This parameter 1486 kernelcore=nn[KMG] [KNL,X86,IA-64,PPC] This parameter
@@ -2110,10 +2117,6 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
2110 noapic [SMP,APIC] Tells the kernel to not make use of any 2117 noapic [SMP,APIC] Tells the kernel to not make use of any
2111 IOAPICs that may be present in the system. 2118 IOAPICs that may be present in the system.
2112 2119
2113 nokaslr [X86]
2114 Disable kernel and module base offset ASLR (Address
2115 Space Layout Randomization) if built into the kernel.
2116
2117 noautogroup Disable scheduler automatic task group creation. 2120 noautogroup Disable scheduler automatic task group creation.
2118 2121
2119 nobats [PPC] Do not use BATs for mapping kernel lowmem 2122 nobats [PPC] Do not use BATs for mapping kernel lowmem
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index fcefdda5136d..a8f749ef0fdc 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1672,7 +1672,6 @@ config RELOCATABLE
1672config RANDOMIZE_BASE 1672config RANDOMIZE_BASE
1673 bool "Randomize the address of the kernel image" 1673 bool "Randomize the address of the kernel image"
1674 depends on RELOCATABLE 1674 depends on RELOCATABLE
1675 depends on !HIBERNATION
1676 default n 1675 default n
1677 ---help--- 1676 ---help---
1678 Randomizes the physical and virtual address at which the 1677 Randomizes the physical and virtual address at which the
diff --git a/arch/x86/boot/compressed/aslr.c b/arch/x86/boot/compressed/aslr.c
index 4dbf967da50d..fc6091abedb7 100644
--- a/arch/x86/boot/compressed/aslr.c
+++ b/arch/x86/boot/compressed/aslr.c
@@ -289,10 +289,17 @@ unsigned char *choose_kernel_location(unsigned char *input,
289 unsigned long choice = (unsigned long)output; 289 unsigned long choice = (unsigned long)output;
290 unsigned long random; 290 unsigned long random;
291 291
292#ifdef CONFIG_HIBERNATION
293 if (!cmdline_find_option_bool("kaslr")) {
294 debug_putstr("KASLR disabled by default...\n");
295 goto out;
296 }
297#else
292 if (cmdline_find_option_bool("nokaslr")) { 298 if (cmdline_find_option_bool("nokaslr")) {
293 debug_putstr("KASLR disabled...\n"); 299 debug_putstr("KASLR disabled by cmdline...\n");
294 goto out; 300 goto out;
295 } 301 }
302#endif
296 303
297 /* Record the various known unsafe memory ranges. */ 304 /* Record the various known unsafe memory ranges. */
298 mem_avoid_init((unsigned long)input, input_size, 305 mem_avoid_init((unsigned long)input, input_size,
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 258f492f0347..fcc2611d3f14 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -1153,6 +1153,11 @@ static int __init nohibernate_setup(char *str)
1153 return 1; 1153 return 1;
1154} 1154}
1155 1155
1156static int __init kaslr_nohibernate_setup(char *str)
1157{
1158 return nohibernate_setup(str);
1159}
1160
1156__setup("noresume", noresume_setup); 1161__setup("noresume", noresume_setup);
1157__setup("resume_offset=", resume_offset_setup); 1162__setup("resume_offset=", resume_offset_setup);
1158__setup("resume=", resume_setup); 1163__setup("resume=", resume_setup);
@@ -1160,3 +1165,4 @@ __setup("hibernate=", hibernate_setup);
1160__setup("resumewait", resumewait_setup); 1165__setup("resumewait", resumewait_setup);
1161__setup("resumedelay=", resumedelay_setup); 1166__setup("resumedelay=", resumedelay_setup);
1162__setup("nohibernate", nohibernate_setup); 1167__setup("nohibernate", nohibernate_setup);
1168__setup("kaslr", kaslr_nohibernate_setup);