]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
LoongArch: Improve the logging of disabling KASLR
authorYuqian Yang <yangyuqian@uniontech.com>
Wed, 22 Apr 2026 07:45:11 +0000 (15:45 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Wed, 22 Apr 2026 07:45:11 +0000 (15:45 +0800)
Whether KASLR is disabled is not handled in nokaslr() which is the early
param "nokaslr" setup function, but in kaslr_disabled(). However, the
logging was previously done in nokaslr() and lack detail. So we move the
logging to the right place and add more specific infomation about why it
is disabled.

Suggested-by: Wentao Guan <guanwentao@uniontech.com>
Signed-off-by: Yuqian Yang <yangyuqian@uniontech.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kernel/relocate.c

index 82aa3f0359278e10fad660395f285cf0fc0de553..16f6a9b39659f525bee97cc347d375826f959d8a 100644 (file)
@@ -128,24 +128,28 @@ static inline __init unsigned long get_random_boot(void)
 
 static int __init nokaslr(char *p)
 {
-       pr_info("KASLR is disabled.\n");
-
-       return 0; /* Print a notice and silence the boot warning */
+       return 0; /* Just silence the boot warning */
 }
 early_param("nokaslr", nokaslr);
 
+#define KASLR_DISABLED_MESSAGE "KASLR is disabled by %s in %s cmdline.\n"
+
 static inline __init bool kaslr_disabled(void)
 {
        char *str;
        const char *builtin_cmdline = CONFIG_CMDLINE;
 
        str = strstr(builtin_cmdline, "nokaslr");
-       if (str == builtin_cmdline || (str > builtin_cmdline && *(str - 1) == ' '))
+       if (str == builtin_cmdline || (str > builtin_cmdline && *(str - 1) == ' ')) {
+               pr_info(KASLR_DISABLED_MESSAGE, "\'nokaslr\'", "built-in");
                return true;
+       }
 
        str = strstr(boot_command_line, "nokaslr");
-       if (str == boot_command_line || (str > boot_command_line && *(str - 1) == ' '))
+       if (str == boot_command_line || (str > boot_command_line && *(str - 1) == ' ')) {
+               pr_info(KASLR_DISABLED_MESSAGE, "\'nokaslr\'", "bootloader");
                return true;
+       }
 
 #ifdef CONFIG_HIBERNATION
        str = strstr(builtin_cmdline, "nohibernate");
@@ -165,17 +169,23 @@ static inline __init bool kaslr_disabled(void)
                return false;
 
        str = strstr(builtin_cmdline, "resume=");
-       if (str == builtin_cmdline || (str > builtin_cmdline && *(str - 1) == ' '))
+       if (str == builtin_cmdline || (str > builtin_cmdline && *(str - 1) == ' ')) {
+               pr_info(KASLR_DISABLED_MESSAGE, "\'resume=\'", "built-in");
                return true;
+       }
 
        str = strstr(boot_command_line, "resume=");
-       if (str == boot_command_line || (str > boot_command_line && *(str - 1) == ' '))
+       if (str == boot_command_line || (str > boot_command_line && *(str - 1) == ' ')) {
+               pr_info(KASLR_DISABLED_MESSAGE, "\'resume=\'", "bootloader");
                return true;
+       }
 #endif
 
        str = strstr(boot_command_line, "kexec_file");
-       if (str == boot_command_line || (str > boot_command_line && *(str - 1) == ' '))
+       if (str == boot_command_line || (str > boot_command_line && *(str - 1) == ' ')) {
+               pr_info(KASLR_DISABLED_MESSAGE, "\'kexec_file\'", "bootloader");
                return true;
+       }
 
        return false;
 }