]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.0.14/arm64-fix-wrong-check-of-on_sdei_stack-in-nmi-contex.patch
Linux 4.19.41
[thirdparty/kernel/stable-queue.git] / releases / 5.0.14 / arm64-fix-wrong-check-of-on_sdei_stack-in-nmi-contex.patch
1 From ecc9bccbd70ef9fc103e55719787d3c9d9b8f4d5 Mon Sep 17 00:00:00 2001
2 From: Wei Li <liwei391@huawei.com>
3 Date: Mon, 1 Apr 2019 11:55:57 +0800
4 Subject: arm64: fix wrong check of on_sdei_stack in nmi context
5
6 [ Upstream commit 1c41860864c8ae0387ef7d44f0000e99cbb2e06d ]
7
8 When doing unwind_frame() in the context of pseudo nmi (need enable
9 CONFIG_ARM64_PSEUDO_NMI), reaching the bottom of the stack (fp == 0,
10 pc != 0), function on_sdei_stack() will return true while the sdei acpi
11 table is not inited in fact. This will cause a "NULL pointer dereference"
12 oops when going on.
13
14 Reviewed-by: Julien Thierry <julien.thierry@arm.com>
15 Signed-off-by: Wei Li <liwei391@huawei.com>
16 Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
17 Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
18 ---
19 arch/arm64/kernel/sdei.c | 6 ++++++
20 1 file changed, 6 insertions(+)
21
22 diff --git a/arch/arm64/kernel/sdei.c b/arch/arm64/kernel/sdei.c
23 index 5ba4465e44f0..ea94cf8f9dc6 100644
24 --- a/arch/arm64/kernel/sdei.c
25 +++ b/arch/arm64/kernel/sdei.c
26 @@ -94,6 +94,9 @@ static bool on_sdei_normal_stack(unsigned long sp, struct stack_info *info)
27 unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_normal_ptr);
28 unsigned long high = low + SDEI_STACK_SIZE;
29
30 + if (!low)
31 + return false;
32 +
33 if (sp < low || sp >= high)
34 return false;
35
36 @@ -111,6 +114,9 @@ static bool on_sdei_critical_stack(unsigned long sp, struct stack_info *info)
37 unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_critical_ptr);
38 unsigned long high = low + SDEI_STACK_SIZE;
39
40 + if (!low)
41 + return false;
42 +
43 if (sp < low || sp >= high)
44 return false;
45
46 --
47 2.20.1
48