Skip to contentSkip to conversation

kgdbts: Passing ekgdbts to command line causes panic

PATCH In review Defang Bo 3 participants 4 messages Dec 28, 2020 – Jan 5, 2021 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Defang Bo

author
#0 lore raw

PATCH 1/1 kgdbts: Passing ekgdbts to command line causes panic

Similar to commit<1bd54d851f50>("kgdboc: Passing ekgdboc to command line causes panic"), kgdbts_option_setup does not check input argument before passing it to strlen. The argument would be a NULL pointer.

---
 drivers/misc/kgdbts.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/misc/kgdbts.c +5 -0
index 945701b..b077547 100644
@@ -1057,6 +1057,11 @@ static void kgdbts_run_tests(void)
 
 static int kgdbts_option_setup(char *opt)
 {
+	if (!opt) {
+		pr_err("kgdbts: config string not provided\n");
+		return -EINVAL;
+	}
+
 	if (strlen(opt) >= MAX_CONFIG_LEN) {
 		printk(KERN_ERR "kgdbts: config string too long\n");
 		return -ENOSPC;
Signature · 1 line
2.7.4
#1 lore raw
Quoted 3 lines · Defang Bo

Similar to commit<1bd54d851f50>("kgdboc: Passing ekgdboc to command line causes panic"), kgdbts_option_setup does not check input argument before passing it to strlen. The argument would be a NULL pointer.

Something seems to be missing here.

The ekgdbts parameter mentioned in the subject line doesn't exist so how can including it on the kernel command line could provoke a panic.

Please can you share the kernel boot arguments you used when you tested this patch?

Daniel.

Quoted 24 lines
---
 drivers/misc/kgdbts.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/misc/kgdbts.c +5 -0
index 945701b..b077547 100644
@@ -1057,6 +1057,11 @@ static void kgdbts_run_tests(void)
 
 static int kgdbts_option_setup(char *opt)
 {
+	if (!opt) {
+		pr_err("kgdbts: config string not provided\n");
+		return -EINVAL;
+	}
+
 	if (strlen(opt) >= MAX_CONFIG_LEN) {
 		printk(KERN_ERR "kgdbts: config string too long\n");
 		return -ENOSPC;
Signature · 1 line
2.7.4

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Please avoid top posting. Threads on LKML are typically presented as follows.

Quoted 14 lines · bodefang

At 2021-01-04 19:28:54, "Daniel Thompson" <[email protected]>

Quoted 12 lines · wrote:
Quoted 4 lines · Defang Bo

Similar to commit<1bd54d851f50>("kgdboc: Passing ekgdboc to command line causes panic"), kgdbts_option_setup does not check input argument before passing it to strlen. The argument would be a NULL pointer.

Something seems to be missing here.

The ekgdbts parameter mentioned in the subject line doesn't exist so how can including it on the kernel command line could provoke a panic.

Quoted 7 lines
Quoted 2 lines

Please can you share the kernel boot arguments you used when you tested this patch?

I use static analysis tool to find these funcs are similar to the commit<1bd54d851f50>(kgdboc: Passing ekgdboc to command line causes panic), so it's just defensive, I haven't actually hitted this but there actually seems a problem here.

I don't see how a problem that occured when ekgdboc is parsed can occur because this module does not parse ekgdbts! Are there really any circumstances where kgdbts_option_setup() can be called with a NULL argument?

Daniel.

maintainer
#4 lore raw
In reply to Defang Bo
Quoted 1 line · Defang Bo

Similar to commit<1bd54d851f50>("kgdboc: Passing ekgdboc to command line causes panic"),

Please wrap your lines, and use the correct way to reference a commit in a changelog as documented. It should look like:
1bd54d851f50 ("kgdboc: Passing ekgdboc to command line causes panic")

Quoted 2 lines

kgdbts_option_setup does not check input argument before passing it to strlen. The argument would be a NULL pointer.

What argument?

As others pointed out, your subject line does not make sense, please fix up.

thanks,

greg k-h