1 From d48ec5e1a5fb7907520dee71b1d94045486a0c29 Mon Sep 17 00:00:00 2001
2 From: Alexander Kamensky <alexander.kamensky42@gmail.com>
3 Date: Thu, 12 Nov 2020 12:56:46 -0800
4 Subject: [PATCH] arm64: kexec: disabled check if kaslr-seed dtb property was
7 Kexec when loading arm64 kernel checks if chosen/kaslr-seed dtb property is
8 wiped. It's a good assertion to verify proper behavior of kernel. However,
9 if bootloader creates and fills kaslr-seed property and kernel is not
10 configured with CONFIG_RANDOMIZE_BASE then logic of reading and wiping
11 kaslr-seed does not run. As a result kaslr-seed property is not zero and when
12 kexec tries to load secondary kernel it fails with the following message:
14 setup_2nd_dtb: kaslr-seed is not wiped to 0.
15 kexec: setup_2nd_dtb failed.
18 This was observed on Yocto Project on qemuarm64 machine with 5.8 kernel,
19 qemu 5.1.0. Qemu created kaslr-seed property but kernel was not configured
20 with CONFIG_RANDOMIZE_BASE.
22 Although check has some value, there is a use-case where it breaks kexec,
23 this patch removes it.
25 Note in described use-case the fact that kaslr-seed is not wiped and user
26 readable through /sys/firmware/fdt or
27 /sys/firmware/devicetree/base/chosen/kaslr-seed is not a security problem
28 as kaslr is disabled anyway.
30 Signed-off-by: Alexander Kamensky <alexander.kamensky42@gmail.com>
31 Upstream-Status: Submitted [http://lists.infradead.org/pipermail/kexec/2020-November/021740.html]
33 kexec/arch/arm64/kexec-arm64.c | 14 +-------------
34 1 file changed, 1 insertion(+), 13 deletions(-)
36 Index: kexec-tools-2.0.20/kexec/arch/arm64/kexec-arm64.c
37 ===================================================================
38 --- kexec-tools-2.0.20.orig/kexec/arch/arm64/kexec-arm64.c
39 +++ kexec-tools-2.0.20/kexec/arch/arm64/kexec-arm64.c
40 @@ -428,7 +428,7 @@ static int setup_2nd_dtb(struct dtb *dtb
44 - int result, kaslr_seed;
47 result = fdt_check_header(dtb->buf);
49 @@ -499,18 +499,6 @@ static int setup_2nd_dtb(struct dtb *dtb
53 - kaslr_seed = fdt64_to_cpu(*prop);
55 - /* kaslr_seed must be wiped clean by primary
56 - * kernel during boot
58 - if (kaslr_seed != 0) {
59 - dbgprintf("%s: kaslr-seed is not wiped to 0.\n",
66 * Invoke the getrandom system call with
67 * GRND_NONBLOCK, to make sure we