summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/kexec/kexec-tools/0001-arm64-kexec-disabled-check-if-kaslr-seed-dtb-propert.patch
blob: ddc1519126f0e1ce49138b8be2118b998f16d979 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
From d48ec5e1a5fb7907520dee71b1d94045486a0c29 Mon Sep 17 00:00:00 2001
From: Alexander Kamensky <alexander.kamensky42@gmail.com>
Date: Thu, 12 Nov 2020 12:56:46 -0800
Subject: [PATCH] arm64: kexec: disabled check if kaslr-seed dtb property was
 wiped

Kexec when loading arm64 kernel checks if chosen/kaslr-seed dtb property is
wiped. It's a good assertion to verify proper behavior of kernel. However,
if bootloader creates and fills kaslr-seed property and kernel is not
configured with CONFIG_RANDOMIZE_BASE then logic of reading and wiping
kaslr-seed does not run. As a result kaslr-seed property is not zero and when
kexec tries to load secondary kernel it fails with the following message:

setup_2nd_dtb: kaslr-seed is not wiped to 0.
kexec: setup_2nd_dtb failed.
kexec: load failed.

This was observed on Yocto Project on qemuarm64 machine with 5.8 kernel,
qemu 5.1.0. Qemu created kaslr-seed property but kernel was not configured
with CONFIG_RANDOMIZE_BASE.

Although check has some value, there is a use-case where it breaks kexec,
this patch removes it.

Note in described use-case the fact that kaslr-seed is not wiped and user
readable through /sys/firmware/fdt or
/sys/firmware/devicetree/base/chosen/kaslr-seed is not a security problem
as kaslr is disabled anyway.

Signed-off-by: Alexander Kamensky <alexander.kamensky42@gmail.com>
Upstream-Status: Submitted [http://lists.infradead.org/pipermail/kexec/2020-November/021740.html]
---
 kexec/arch/arm64/kexec-arm64.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
index ec6df4b..10238d9 100644
--- a/kexec/arch/arm64/kexec-arm64.c
+++ b/kexec/arch/arm64/kexec-arm64.c
@@ -503,7 +503,7 @@ static int setup_2nd_dtb(struct dtb *dtb, char *command_line, int on_crash)
 	int len, range_len;
 	int nodeoffset;
 	int new_size;
-	int i, result, kaslr_seed;
+	int i, result;
 
 	result = fdt_check_header(dtb->buf);
 
@@ -576,18 +576,6 @@ static int setup_2nd_dtb(struct dtb *dtb, char *command_line, int on_crash)
 			return result;
 		}
 	} else {
-		kaslr_seed = fdt64_to_cpu(*prop);
-
-		/* kaslr_seed must be wiped clean by primary
-		 * kernel during boot
-		 */
-		if (kaslr_seed != 0) {
-			dbgprintf("%s: kaslr-seed is not wiped to 0.\n",
-					__func__);
-			result = -EINVAL;
-			goto on_error;
-		}
-
 		/*
 		 * Invoke the getrandom system call with
 		 * GRND_NONBLOCK, to make sure we
-- 
2.25.1