Skip to content

Commit 976643a

Browse files
Yoha-testDaniel Thompson
authored andcommitted
misc: kgdbts: 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 dada6a4 ("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: Daniel Thompson <daniel.thompson@linaro.org>
1 parent 9b555c4 commit 976643a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/misc/kgdbts.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ static void kgdbts_put_char(u8 chr)
11351135
static int param_set_kgdbts_var(const char *kmessage,
11361136
const struct kernel_param *kp)
11371137
{
1138-
int len = strlen(kmessage);
1138+
size_t len = strlen(kmessage);
11391139

11401140
if (len >= MAX_CONFIG_LEN) {
11411141
printk(KERN_ERR "kgdbts: config string too long\n");
@@ -1155,7 +1155,7 @@ static int param_set_kgdbts_var(const char *kmessage,
11551155

11561156
strcpy(config, kmessage);
11571157
/* Chop out \n char as a result of echo */
1158-
if (config[len - 1] == '\n')
1158+
if (len && config[len - 1] == '\n')
11591159
config[len - 1] = '\0';
11601160

11611161
/* Go and configure with the new params. */

0 commit comments

Comments
 (0)