提交 a87f04c3 编写于 作者: G Guenter Roeck 提交者: Yang Yingliang

arm64: kaslr: Use standard early random function

mainline inclusion
from mainline-v5.8
commit 9bceb80b
category:bugfix
bugzilla:NA
CVE:NA

-------------------

Commit 58552408 ("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: NQian Cai <cai@lca.pw>
Fixes: 58552408 ("random: random.h should include archrandom.h, not the other way around")
Cc: Qian Cai <cai@lca.pw>
Cc: Mark Brown <broonie@kernel.org>
Reviewed-by: NMark Rutland <mark.rutland@arm.com>
Reviewed-by: NMark Brown <broonie@kernel.org>
Tested-by: NMark Brown <broonie@kernel.org>
Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 4faad749
...@@ -90,6 +90,7 @@ u64 __init kaslr_early_init(u64 dt_phys) ...@@ -90,6 +90,7 @@ u64 __init kaslr_early_init(u64 dt_phys)
void *fdt; void *fdt;
u64 seed, offset, mask, module_range; u64 seed, offset, mask, module_range;
const u8 *cmdline, *str; const u8 *cmdline, *str;
unsigned long raw;
int size; int size;
/* /*
...@@ -128,15 +129,12 @@ u64 __init kaslr_early_init(u64 dt_phys) ...@@ -128,15 +129,12 @@ u64 __init kaslr_early_init(u64 dt_phys)
} }
/* /*
* Mix in any entropy obtainable architecturally, open coded * Mix in any entropy obtainable architecturally if enabled
* since this runs extremely early. * and supported.
*/ */
if (__early_cpu_has_rndr()) {
unsigned long raw;
if (__arm64_rndr(&raw)) if (arch_get_random_seed_long_early(&raw))
seed ^= raw; seed ^= raw;
}
if (!seed) { if (!seed) {
kaslr_status = KASLR_DISABLED_NO_SEED; kaslr_status = KASLR_DISABLED_NO_SEED;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册