]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-4.14/drivers-misc-fix-out-of-bounds-access-in-function-pa.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.14 / drivers-misc-fix-out-of-bounds-access-in-function-pa.patch
CommitLineData
1cd4ef76
SL
1From 3c92db0ab6524efd502a7bde35672b3f4c9ae500 Mon Sep 17 00:00:00 2001
2From: Young Xiao <YangX92@hotmail.com>
3Date: Fri, 12 Apr 2019 15:45:06 +0800
4Subject: Drivers: misc: fix out-of-bounds access in function
5 param_set_kgdbts_var
6
7[ Upstream commit b281218ad4311a0342a40cb02fb17a363df08b48 ]
8
9There is an out-of-bounds access to "config[len - 1]" array when the
10variable "len" is zero.
11
12See commit dada6a43b040 ("kgdboc: fix KASAN global-out-of-bounds bug
13in param_set_kgdboc_var()") for details.
14
15Signed-off-by: Young Xiao <YangX92@hotmail.com>
16Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17Signed-off-by: Sasha Levin <sashal@kernel.org>
18---
19 drivers/misc/kgdbts.c | 4 ++--
20 1 file changed, 2 insertions(+), 2 deletions(-)
21
22diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
23index fc7efedbc4be..94cbc5c98cae 100644
24--- a/drivers/misc/kgdbts.c
25+++ b/drivers/misc/kgdbts.c
26@@ -1134,7 +1134,7 @@ static void kgdbts_put_char(u8 chr)
27
28 static int param_set_kgdbts_var(const char *kmessage, struct kernel_param *kp)
29 {
30- int len = strlen(kmessage);
31+ size_t len = strlen(kmessage);
32
33 if (len >= MAX_CONFIG_LEN) {
34 printk(KERN_ERR "kgdbts: config string too long\n");
35@@ -1154,7 +1154,7 @@ static int param_set_kgdbts_var(const char *kmessage, struct kernel_param *kp)
36
37 strcpy(config, kmessage);
38 /* Chop out \n char as a result of echo */
39- if (config[len - 1] == '\n')
40+ if (len && config[len - 1] == '\n')
41 config[len - 1] = '\0';
42
43 /* Go and configure with the new params. */
44--
452.20.1
46