]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
a64239f4fcb7b9a96a89e8090d8fec1ce9036074
[thirdparty/kernel/stable-queue.git] /
1 From ccde460b9ae5c2bd5e4742af0a7f623c2daad566 Mon Sep 17 00:00:00 2001
2 From: He Zhe <zhe.he@windriver.com>
3 Date: Tue, 14 Aug 2018 23:33:42 +0800
4 Subject: x86/corruption-check: Fix panic in memory_corruption_check() when boot option without value is provided
5
6 From: He Zhe <zhe.he@windriver.com>
7
8 commit ccde460b9ae5c2bd5e4742af0a7f623c2daad566 upstream.
9
10 memory_corruption_check[{_period|_size}]()'s handlers do not check input
11 argument before passing it to kstrtoul() or simple_strtoull(). The argument
12 would be a NULL pointer if each of the kernel parameters, without its
13 value, is set in command line and thus cause the following panic.
14
15 PANIC: early exception 0xe3 IP 10:ffffffff73587c22 error 0 cr2 0x0
16 [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.18-rc8+ #2
17 [ 0.000000] RIP: 0010:kstrtoull+0x2/0x10
18 ...
19 [ 0.000000] Call Trace
20 [ 0.000000] ? set_corruption_check+0x21/0x49
21 [ 0.000000] ? do_early_param+0x4d/0x82
22 [ 0.000000] ? parse_args+0x212/0x330
23 [ 0.000000] ? rdinit_setup+0x26/0x26
24 [ 0.000000] ? parse_early_options+0x20/0x23
25 [ 0.000000] ? rdinit_setup+0x26/0x26
26 [ 0.000000] ? parse_early_param+0x2d/0x39
27 [ 0.000000] ? setup_arch+0x2f7/0xbf4
28 [ 0.000000] ? start_kernel+0x5e/0x4c2
29 [ 0.000000] ? load_ucode_bsp+0x113/0x12f
30 [ 0.000000] ? secondary_startup_64+0xa5/0xb0
31
32 This patch adds checks to prevent the panic.
33
34 Signed-off-by: He Zhe <zhe.he@windriver.com>
35 Cc: Linus Torvalds <torvalds@linux-foundation.org>
36 Cc: Peter Zijlstra <peterz@infradead.org>
37 Cc: Thomas Gleixner <tglx@linutronix.de>
38 Cc: gregkh@linuxfoundation.org
39 Cc: kstewart@linuxfoundation.org
40 Cc: pombredanne@nexb.com
41 Cc: stable@vger.kernel.org
42 Link: http://lkml.kernel.org/r/1534260823-87917-1-git-send-email-zhe.he@windriver.com
43 Signed-off-by: Ingo Molnar <mingo@kernel.org>
44 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
45
46 ---
47 arch/x86/kernel/check.c | 15 +++++++++++++++
48 1 file changed, 15 insertions(+)
49
50 --- a/arch/x86/kernel/check.c
51 +++ b/arch/x86/kernel/check.c
52 @@ -30,6 +30,11 @@ static __init int set_corruption_check(c
53 ssize_t ret;
54 unsigned long val;
55
56 + if (!arg) {
57 + pr_err("memory_corruption_check config string not provided\n");
58 + return -EINVAL;
59 + }
60 +
61 ret = kstrtoul(arg, 10, &val);
62 if (ret)
63 return ret;
64 @@ -44,6 +49,11 @@ static __init int set_corruption_check_p
65 ssize_t ret;
66 unsigned long val;
67
68 + if (!arg) {
69 + pr_err("memory_corruption_check_period config string not provided\n");
70 + return -EINVAL;
71 + }
72 +
73 ret = kstrtoul(arg, 10, &val);
74 if (ret)
75 return ret;
76 @@ -58,6 +68,11 @@ static __init int set_corruption_check_s
77 char *end;
78 unsigned size;
79
80 + if (!arg) {
81 + pr_err("memory_corruption_check_size config string not provided\n");
82 + return -EINVAL;
83 + }
84 +
85 size = memparse(arg, &end);
86
87 if (*end == '\0')