Skip to contentSkip to conversation

printk: Check valid console index for preferred console

PATCH Superseded Tony Lindgren 1 participant 2 messages Oct 4, 2023 – Oct 11, 2023 Printk

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 printk: Check valid console index for preferred console

Let's check for valid console index values.

---
 kernel/printk/printk.c | 4 ++++
 1 file changed, 4 insertions(+)
kernel/printk/printk.c +4 -0
@@ -2410,6 +2410,10 @@ static int __add_preferred_console(char *name, int idx, char *options,
 	struct console_cmdline *c;
 	int i;
 
+	/* See struct console */
+	if (idx > SHRT_MAX)
+		return -EINVAL;
+
 	/*
 	 *	See if this tty is not yet registered, and
 	 *	if we have a slot free.
Signature · 1 line
2.42.0
#1 lore raw

kernel/printk/printk.c static int __add_preferred_console(char *name, int idx, char *options, · line 2416

Quoted 10 lines · Tony Lindgren
kernel/printk/printk.c +4 -0
@@ -2410,6 +2410,10 @@ static int __add_preferred_console(char *name, int idx, char *options,
 	struct console_cmdline *c;
 	int i;
 
+	/* See struct console */
+	if (idx > SHRT_MAX)
+		return -EINVAL;
+

We can just use const short idx for preferred console and return an error for negative values for preferred console. I'll send out v2 patch.

Regards,

Tony