[PATCH] x86/kaslr: take CONFIG_RANDOMIZE_MEMORY into account in kaslr_enabled()
From: Mike Rapoport
Date: Mon May 25 2020 - 05:18:21 EST
Until refactoring of the init_trampoline(), kaslr_enabled() was used only
inside '#ifdef CONFIG_RANDOMIZE_MEMORY' and reported only the state of the
command line override.
The simplification of init_trampoline() made kaslr_enabled() visible for
builds with CONFIG_RANDOMIZE_MEMORY=n and in this case it will return true
if the randomization was not disabled on the command line.
This in turn will call a dummy init_trampoline_kaslr() instead of setting
trampline_pgd_entry directly.
As the result, the kernel reboots while starting the secondary CPUs, e.g.
kernel test bot reported:
...
[ 0.244628] Performance Events: unsupported p6 CPU model 60 no PMU driver, software events only.
[ 0.244993] rcu: Hierarchical SRCU implementation.
[ 0.245617] smp: Bringing up secondary CPUs ...
[ 0.247388] x86: Booting SMP configuration:
BUG: kernel reboot-without-warning in boot stage
Adding a check for IS_ENABLED(CONFIG_RANDOMIZE_MEMORY) to kaslr_enabled()
resolves the issue.
Signed-off-by: Mike Rapoport <rppt@xxxxxxxxxxxxx>
Reported-by: kbuild test robot <lkp@xxxxxxxxx>
---
arch/x86/include/asm/setup.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
index d95cacf210bb..84b645cc8bc9 100644
--- a/arch/x86/include/asm/setup.h
+++ b/arch/x86/include/asm/setup.h
@@ -75,7 +75,8 @@ extern char _text[];
static inline bool kaslr_enabled(void)
{
- return !!(boot_params.hdr.loadflags & KASLR_FLAG);
+ return IS_ENABLED(CONFIG_RANDOMIZE_MEMORY) &&
+ !!(boot_params.hdr.loadflags & KASLR_FLAG);
}
/*
--
2.26.2