diff options
author | Young Xiao <YangX92@hotmail.com> | 2019-04-12 03:45:06 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-04-25 16:23:06 -0400 |
commit | b281218ad4311a0342a40cb02fb17a363df08b48 (patch) | |
tree | dd6e5b40e6ffd8793af4d033ef833e2b4e452a67 /drivers/misc/kgdbts.c | |
parent | 15235f1f495efc5ed435cf6fff95066ba85c5328 (diff) |
Drivers: misc: fix out-of-bounds access in function param_set_kgdbts_var
There is an out-of-bounds access to "config[len - 1]" array when the
variable "len" is zero.
See commit dada6a43b040 ("kgdboc: fix KASAN global-out-of-bounds bug
in param_set_kgdboc_var()") for details.
Signed-off-by: Young Xiao <YangX92@hotmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/kgdbts.c')
-rw-r--r-- | drivers/misc/kgdbts.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c index de20bdaa148d..8b01257783dd 100644 --- a/drivers/misc/kgdbts.c +++ b/drivers/misc/kgdbts.c | |||
@@ -1135,7 +1135,7 @@ static void kgdbts_put_char(u8 chr) | |||
1135 | static int param_set_kgdbts_var(const char *kmessage, | 1135 | static int param_set_kgdbts_var(const char *kmessage, |
1136 | const struct kernel_param *kp) | 1136 | const struct kernel_param *kp) |
1137 | { | 1137 | { |
1138 | int len = strlen(kmessage); | 1138 | size_t len = strlen(kmessage); |
1139 | 1139 | ||
1140 | if (len >= MAX_CONFIG_LEN) { | 1140 | if (len >= MAX_CONFIG_LEN) { |
1141 | printk(KERN_ERR "kgdbts: config string too long\n"); | 1141 | printk(KERN_ERR "kgdbts: config string too long\n"); |
@@ -1155,7 +1155,7 @@ static int param_set_kgdbts_var(const char *kmessage, | |||
1155 | 1155 | ||
1156 | strcpy(config, kmessage); | 1156 | strcpy(config, kmessage); |
1157 | /* Chop out \n char as a result of echo */ | 1157 | /* Chop out \n char as a result of echo */ |
1158 | if (config[len - 1] == '\n') | 1158 | if (len && config[len - 1] == '\n') |
1159 | config[len - 1] = '\0'; | 1159 | config[len - 1] = '\0'; |
1160 | 1160 | ||
1161 | /* Go and configure with the new params. */ | 1161 | /* Go and configure with the new params. */ |