|
@@ -14,6 +14,13 @@
|
|
static const char build_str[] = UTS_RELEASE " (" LINUX_COMPILE_BY "@"
|
|
static const char build_str[] = UTS_RELEASE " (" LINUX_COMPILE_BY "@"
|
|
LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION;
|
|
LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION;
|
|
|
|
|
|
|
|
+struct kaslr_setup_data {
|
|
|
|
+ __u64 next;
|
|
|
|
+ __u32 type;
|
|
|
|
+ __u32 len;
|
|
|
|
+ __u8 data[1];
|
|
|
|
+} kaslr_setup_data;
|
|
|
|
+
|
|
#define I8254_PORT_CONTROL 0x43
|
|
#define I8254_PORT_CONTROL 0x43
|
|
#define I8254_PORT_COUNTER0 0x40
|
|
#define I8254_PORT_COUNTER0 0x40
|
|
#define I8254_CMD_READBACK 0xC0
|
|
#define I8254_CMD_READBACK 0xC0
|
|
@@ -295,7 +302,29 @@ static unsigned long find_random_addr(unsigned long minimum,
|
|
return slots_fetch_random();
|
|
return slots_fetch_random();
|
|
}
|
|
}
|
|
|
|
|
|
-unsigned char *choose_kernel_location(unsigned char *input,
|
|
|
|
|
|
+static void add_kaslr_setup_data(struct boot_params *params, __u8 enabled)
|
|
|
|
+{
|
|
|
|
+ struct setup_data *data;
|
|
|
|
+
|
|
|
|
+ kaslr_setup_data.type = SETUP_KASLR;
|
|
|
|
+ kaslr_setup_data.len = 1;
|
|
|
|
+ kaslr_setup_data.next = 0;
|
|
|
|
+ kaslr_setup_data.data[0] = enabled;
|
|
|
|
+
|
|
|
|
+ data = (struct setup_data *)(unsigned long)params->hdr.setup_data;
|
|
|
|
+
|
|
|
|
+ while (data && data->next)
|
|
|
|
+ data = (struct setup_data *)(unsigned long)data->next;
|
|
|
|
+
|
|
|
|
+ if (data)
|
|
|
|
+ data->next = (unsigned long)&kaslr_setup_data;
|
|
|
|
+ else
|
|
|
|
+ params->hdr.setup_data = (unsigned long)&kaslr_setup_data;
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+unsigned char *choose_kernel_location(struct boot_params *params,
|
|
|
|
+ unsigned char *input,
|
|
unsigned long input_size,
|
|
unsigned long input_size,
|
|
unsigned char *output,
|
|
unsigned char *output,
|
|
unsigned long output_size)
|
|
unsigned long output_size)
|
|
@@ -306,14 +335,17 @@ unsigned char *choose_kernel_location(unsigned char *input,
|
|
#ifdef CONFIG_HIBERNATION
|
|
#ifdef CONFIG_HIBERNATION
|
|
if (!cmdline_find_option_bool("kaslr")) {
|
|
if (!cmdline_find_option_bool("kaslr")) {
|
|
debug_putstr("KASLR disabled by default...\n");
|
|
debug_putstr("KASLR disabled by default...\n");
|
|
|
|
+ add_kaslr_setup_data(params, 0);
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
#else
|
|
#else
|
|
if (cmdline_find_option_bool("nokaslr")) {
|
|
if (cmdline_find_option_bool("nokaslr")) {
|
|
debug_putstr("KASLR disabled by cmdline...\n");
|
|
debug_putstr("KASLR disabled by cmdline...\n");
|
|
|
|
+ add_kaslr_setup_data(params, 0);
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
+ add_kaslr_setup_data(params, 1);
|
|
|
|
|
|
/* Record the various known unsafe memory ranges. */
|
|
/* Record the various known unsafe memory ranges. */
|
|
mem_avoid_init((unsigned long)input, input_size,
|
|
mem_avoid_init((unsigned long)input, input_size,
|