Skip to content

Commit 2203e1a

Browse files
brooniectmarinas
authored andcommitted
arm64: kaslr: Check command line before looking for a seed
Now that we print diagnostics at boot the reason why we do not initialise KASLR matters. Currently we check for a seed before we check if the user has explicitly disabled KASLR on the command line which will result in misleading diagnostics so reverse the order of those checks. We still parse the seed from the DT early so that if the user has both provided a seed and disabled KASLR on the command line we still mask the seed on the command line. Signed-off-by: Mark Brown <[email protected]> Acked-by: Mark Rutland <[email protected]> Signed-off-by: Catalin Marinas <[email protected]>
1 parent 294a9dd commit 2203e1a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

arch/arm64/kernel/kaslr.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ enum kaslr_status {
2626
KASLR_DISABLED_FDT_REMAP,
2727
};
2828

29-
enum kaslr_status __ro_after_init kaslr_status;
29+
static enum kaslr_status __initdata kaslr_status;
3030
u64 __ro_after_init module_alloc_base;
3131
u16 __initdata memstart_offset_seed;
3232

@@ -108,10 +108,6 @@ u64 __init kaslr_early_init(u64 dt_phys)
108108
* Retrieve (and wipe) the seed from the FDT
109109
*/
110110
seed = get_kaslr_seed(fdt);
111-
if (!seed) {
112-
kaslr_status = KASLR_DISABLED_NO_SEED;
113-
return 0;
114-
}
115111

116112
/*
117113
* Check if 'nokaslr' appears on the command line, and
@@ -124,6 +120,11 @@ u64 __init kaslr_early_init(u64 dt_phys)
124120
return 0;
125121
}
126122

123+
if (!seed) {
124+
kaslr_status = KASLR_DISABLED_NO_SEED;
125+
return 0;
126+
}
127+
127128
/*
128129
* OK, so we are proceeding with KASLR enabled. Calculate a suitable
129130
* kernel image offset from the seed. Let's place the kernel in the

0 commit comments

Comments
 (0)