mirror of
https://github.com/torvalds/linux.git
synced 2026-11-24 15:33:28 +00:00
arm64: kaslr: Use standard early random function
Commit585524081e("random: random.h should include archrandom.h, not the other way around") tries to fix a problem with recursive inclusion of linux/random.h and arch/archrandom.h for arm64. Unfortunately, this results in the following compile error if ARCH_RANDOM is disabled. arch/arm64/kernel/kaslr.c: In function 'kaslr_early_init': arch/arm64/kernel/kaslr.c:128:6: error: implicit declaration of function '__early_cpu_has_rndr'; did you mean '__early_pfn_to_nid'? [-Werror=implicit-function-declaration] if (__early_cpu_has_rndr()) { ^~~~~~~~~~~~~~~~~~~~ __early_pfn_to_nid arch/arm64/kernel/kaslr.c:131:7: error: implicit declaration of function '__arm64_rndr' [-Werror=implicit-function-declaration] if (__arm64_rndr(&raw)) ^~~~~~~~~~~~ The problem is that arch/archrandom.h is only included from linux/random.h if ARCH_RANDOM is enabled. If not, __arm64_rndr() and __early_cpu_has_rndr() are undeclared, causing the problem. Use arch_get_random_seed_long_early() instead of arm64 specific functions to solve the problem. Reported-by: Qian Cai <[email protected]> Fixes:585524081e("random: random.h should include archrandom.h, not the other way around") Cc: Qian Cai <[email protected]> Cc: Mark Brown <[email protected]> Reviewed-by: Mark Rutland <[email protected]> Reviewed-by: Mark Brown <[email protected]> Tested-by: Mark Brown <[email protected]> Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
committed by
Linus Torvalds
parent
0f5d0a4c01
commit
9bceb80b3c
@@ -84,6 +84,7 @@ u64 __init kaslr_early_init(u64 dt_phys)
|
||||
void *fdt;
|
||||
u64 seed, offset, mask, module_range;
|
||||
const u8 *cmdline, *str;
|
||||
unsigned long raw;
|
||||
int size;
|
||||
|
||||
/*
|
||||
@@ -122,15 +123,12 @@ u64 __init kaslr_early_init(u64 dt_phys)
|
||||
}
|
||||
|
||||
/*
|
||||
* Mix in any entropy obtainable architecturally, open coded
|
||||
* since this runs extremely early.
|
||||
* Mix in any entropy obtainable architecturally if enabled
|
||||
* and supported.
|
||||
*/
|
||||
if (__early_cpu_has_rndr()) {
|
||||
unsigned long raw;
|
||||
|
||||
if (__arm64_rndr(&raw))
|
||||
seed ^= raw;
|
||||
}
|
||||
if (arch_get_random_seed_long_early(&raw))
|
||||
seed ^= raw;
|
||||
|
||||
if (!seed) {
|
||||
kaslr_status = KASLR_DISABLED_NO_SEED;
|
||||
|
||||
Reference in New Issue
Block a user