x86/KASLR: Warn when KASLR is disabled
authorKees Cook <keescook@chromium.org>
Wed, 20 Apr 2016 20:55:46 +0000 (13:55 -0700)
committerIngo Molnar <mingo@kernel.org>
Fri, 22 Apr 2016 08:00:51 +0000 (10:00 +0200)
If KASLR is built in but not available at run-time (either due to the
current conflict with hibernation, command-line request, or e820 parsing
failures), announce the state explicitly. To support this, a new "warn"
function is created, based on the existing "error" function.

Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bp@suse.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: H.J. Lu <hjl.tools@gmail.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yinghai Lu <yinghai@kernel.org>
Link: http://lkml.kernel.org/r/1461185746-8017-6-git-send-email-keescook@chromium.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/boot/compressed/kaslr.c
arch/x86/boot/compressed/misc.c
arch/x86/boot/compressed/misc.h

index 3ad71a0..8741a6d 100644 (file)
@@ -314,12 +314,12 @@ unsigned char *choose_random_location(unsigned char *input,
 
 #ifdef CONFIG_HIBERNATION
        if (!cmdline_find_option_bool("kaslr")) {
-               debug_putstr("KASLR disabled by default...\n");
+               warn("KASLR disabled: 'kaslr' not on cmdline (hibernation selected).");
                goto out;
        }
 #else
        if (cmdline_find_option_bool("nokaslr")) {
-               debug_putstr("KASLR disabled by cmdline...\n");
+               warn("KASLR disabled: 'nokaslr' on cmdline.");
                goto out;
        }
 #endif
@@ -333,7 +333,7 @@ unsigned char *choose_random_location(unsigned char *input,
        /* Walk e820 and find a random address. */
        random_addr = find_random_addr(choice, output_size);
        if (!random_addr) {
-               debug_putstr("KASLR could not find suitable E820 region...\n");
+               warn("KASLR disabled: could not find suitable E820 region!");
                goto out;
        }
 
index eacc855..c57d785 100644 (file)
@@ -166,11 +166,17 @@ void __puthex(unsigned long value)
        }
 }
 
-static void error(char *x)
+void warn(char *m)
 {
        error_putstr("\n\n");
-       error_putstr(x);
-       error_putstr("\n\n -- System halted");
+       error_putstr(m);
+       error_putstr("\n\n");
+}
+
+static void error(char *m)
+{
+       warn(m);
+       error_putstr(" -- System halted");
 
        while (1)
                asm("hlt");
index 9887e0d..e75f6cf 100644 (file)
@@ -35,6 +35,7 @@ extern memptr free_mem_end_ptr;
 extern struct boot_params *boot_params;
 void __putstr(const char *s);
 void __puthex(unsigned long value);
+void warn(char *m);
 #define error_putstr(__x)  __putstr(__x)
 #define error_puthex(__x)  __puthex(__x)