Skip to contentSkip to conversation

disable kaslr in kdump kernel

PATCH In review Dave Young 2 participants 4 messages Feb 11, 2014 – Feb 12, 2014 x86

lore
Share & tools
lore

Dave Young

author
#0 lore raw

PATCH 1/1 disable kaslr in kdump kernel

KASLR does not work in kdump kernel because it's too early that mem=exactmap has not been parsed.

Since KASLR does not make much sense for kdump kernel thus let's disable it for kdump kernel. To check if it is a kdump kernel I just check the cmdline param elfcorehdr just like is_kdump_kernel.

---
 linux-2.6/arch/x86/boot/compressed/aslr.c |    5 +++++
 1 file changed, 5 insertions(+)
arch/x86/boot/compressed/aslr.c +5 -0
Index: dyoung/git/linux-2.6/arch/x86/boot/compressed/aslr.c
===================================================================
@@ -293,6 +293,11 @@ unsigned char *choose_kernel_location(un
 		goto out;
 	}
 
+	if (cmdline_find_option("elfcorehdr", NULL, 0) != -1) {
+		debug_putstr("KASLR disabled...\n");
+		goto out;
+	}
+
 	/* Record the various known unsafe memory ranges. */
 	mem_avoid_init((unsigned long)input, input_size,
 		       (unsigned long)output, output_size);
#1 lore raw
Quoted 9 lines · Dave Young

KASLR does not work in kdump kernel because it's too early that mem=exactmap has not been parsed.

Since KASLR does not make much sense for kdump kernel thus let's disable it for kdump kernel. To check if it is a kdump kernel I just check the cmdline param elfcorehdr just like is_kdump_kernel.

I don't think it is a good idea. I don't like hardcoding second kernel's behavior. I rather vary second kernel's behavior based on command line parameters or based on values passed in bootparams.

So I am more than happy to pass command line option "nokaslr" instead of hardcoding this in kernel.

Thanks
Vivek

Quoted 20 lines
---
 linux-2.6/arch/x86/boot/compressed/aslr.c |    5 +++++
 1 file changed, 5 insertions(+)

Index: dyoung/git/linux-2.6/arch/x86/boot/compressed/aslr.c
===================================================================

arch/x86/boot/compressed/aslr.c +5 -0
@@ -293,6 +293,11 @@ unsigned char *choose_kernel_location(un
 		goto out;
 	}
 
+	if (cmdline_find_option("elfcorehdr", NULL, 0) != -1) {
+		debug_putstr("KASLR disabled...\n");
+		goto out;
+	}
+
 	/* Record the various known unsafe memory ranges. */
 	mem_avoid_init((unsigned long)input, input_size,
 		       (unsigned long)output, output_size);
author
#2 lore raw
Quoted 9 lines · Vivek Goyal
Quoted 8 lines · Dave Young

KASLR does not work in kdump kernel because it's too early that mem=exactmap has not been parsed.

Since KASLR does not make much sense for kdump kernel thus let's disable it for kdump kernel. To check if it is a kdump kernel I just check the cmdline param elfcorehdr just like is_kdump_kernel.

Quoted 8 lines
Quoted 1 line

I don't think it is a good idea. I don't like hardcoding second kernel's behavior. I rather vary second kernel's behavior based on command line parameters or based on values passed in bootparams.

So I am more than happy to pass command line option "nokaslr" instead of hardcoding this in kernel.

That's also fine to me, but I think we'd better add it to documentation?

Quoted 24 lines

Thanks
Vivek

Quoted 20 lines
---
 linux-2.6/arch/x86/boot/compressed/aslr.c |    5 +++++
 1 file changed, 5 insertions(+)

Index: dyoung/git/linux-2.6/arch/x86/boot/compressed/aslr.c
===================================================================

arch/x86/boot/compressed/aslr.c +5 -0
@@ -293,6 +293,11 @@ unsigned char *choose_kernel_location(un
 		goto out;
 	}
 
+	if (cmdline_find_option("elfcorehdr", NULL, 0) != -1) {
+		debug_putstr("KASLR disabled...\n");
+		goto out;
+	}
+
 	/* Record the various known unsafe memory ranges. */
 	mem_avoid_init((unsigned long)input, input_size,
 		       (unsigned long)output, output_size);
#3 lore raw
Quoted 12 lines · Dave Young
Quoted 11 lines · Vivek Goyal
Quoted 9 lines · Dave Young

KASLR does not work in kdump kernel because it's too early that mem=exactmap has not been parsed.

Since KASLR does not make much sense for kdump kernel thus let's disable it for kdump kernel. To check if it is a kdump kernel I just check the cmdline param elfcorehdr just like is_kdump_kernel.

Quoted 8 lines
Quoted 6 lines

I don't think it is a good idea. I don't like hardcoding second kernel's behavior. I rather vary second kernel's behavior based on command line parameters or based on values passed in bootparams.

So I am more than happy to pass command line option "nokaslr" instead of hardcoding this in kernel.

That's also fine to me, but I think we'd better add it to documentation?

Adding documentation is fine. May be Documentation/kdump/kdump.txt. Create a section where we mention some of the preferred command line settings for kdump to work.

Thanks
Vivek