Commit 84763495 authored by Yuqian Yang's avatar Yuqian Yang Committed by Huacai Chen
Browse files

LoongArch: Improve the logging of disabling KASLR



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: default avatarWentao Guan <guanwentao@uniontech.com>
Signed-off-by: default avatarYuqian Yang <yangyuqian@uniontech.com>
Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
parent e3f4591f
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -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;
}