serial: 8250: Check for valid console index
PATCH 1/1 serial: 8250: Check for valid console index
Let's not allow negative numbers for console index.
--- drivers/tty/serial/8250/8250_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/8250/8250_core.c +1 -1
@@ -611,7 +611,7 @@ static int univ8250_console_setup(struct console *co, char *options)* if so, search for the first available port that does have * console support. */ -if (co->index >=UART_NR ) +if (co->index <0 || co->index >=UART_NR ) co->index =0 ;/*
Signature · 1 line
2.42.0
Quoted 11 lines · Tony Lindgren
Let's not allow negative numbers for console index.
Signed-off-by Tony Lindgren <[email protected]>--- drivers/tty/serial/8250/8250_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/8250/8250_core.c static int univ8250_console_setup(struct console *co, char *options) · line 615
Quoted 6 lines
drivers/tty/serial/8250/8250_core.c +1
-1@@ -611,7 +611,7 @@ static int univ8250_console_setup(struct console *co, char *options)* if so, search for the first available port that does have * console support. */ -if (co->index >=UART_NR ) +if (co->index <0 || co->index >=UART_NR ) co->index =0 ;
The inconsistencies how different serial drivers handle this situation seem staggering. Perhaps there should be some effort to make the behavior uniform across them?
Signature · 1 line
i.
Quoted 9 lines · Ilpo Järvinen
Quoted 7 lines · Tony Lindgren
Let's not allow negative numbers for console index.
Signed-off-by Tony Lindgren <[email protected]>--- drivers/tty/serial/8250/8250_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines
drivers/tty/serial/8250/8250_core.c static int univ8250_console_setup(struct console *co, char *options) · line 615
Quoted 10 lines
drivers/tty/serial/8250/8250_core.c +1
-1@@ -611,7 +611,7 @@ static int univ8250_console_setup(struct console *co, char *options)* if so, search for the first available port that does have * console support. */ -if (co->index >=UART_NR ) +if (co->index <0 || co->index >=UART_NR ) co->index =0 ;The inconsistencies how different serial drivers handle this situation seem staggering. Perhaps there should be some effort to make the behavior uniform across them?
Hmm yeah we should just have them all check for co->index < 0.
Regards,
Tony
Quoted 25 lines · Tony Lindgren
Quoted 9 lines · Ilpo Järvinen
Quoted 7 lines · Tony Lindgren
Let's not allow negative numbers for console index.
Signed-off-by Tony Lindgren <[email protected]>--- drivers/tty/serial/8250/8250_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 14 lines
drivers/tty/serial/8250/8250_core.c static int univ8250_console_setup(struct console *co, char *options) · line 615
Quoted 10 lines
drivers/tty/serial/8250/8250_core.c +1
-1@@ -611,7 +611,7 @@ static int univ8250_console_setup(struct console *co, char *options)* if so, search for the first available port that does have * console support. */ -if (co->index >=UART_NR ) +if (co->index <0 || co->index >=UART_NR ) co->index =0 ;The inconsistencies how different serial drivers handle this situation seem staggering. Perhaps there should be some effort to make the behavior uniform across them?
Quoted 1 line
Hmm yeah we should just have them all check for
co->index< 0.
Right but it's only about that, some return -Exx codes (more than one -Exx variant) and some do assign just 0 like here.
Signature · 1 line
i.
Quoted 27 lines · Ilpo Järvinen
Quoted 25 lines · Tony Lindgren
Quoted 23 lines · Ilpo Järvinen
Quoted 11 lines · Tony Lindgren
Let's not allow negative numbers for console index.
Signed-off-by Tony Lindgren <[email protected]>--- drivers/tty/serial/8250/8250_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/tty/serial/8250/8250_core.c static int univ8250_console_setup(struct console *co, char *options) · line 615
Quoted 6 lines
drivers/tty/serial/8250/8250_core.c +1
-1@@ -611,7 +611,7 @@ static int univ8250_console_setup(struct console *co, char *options)* if so, search for the first available port that does have * console support. */ -if (co->index >=UART_NR ) +if (co->index <0 || co->index >=UART_NR ) co->index =0 ;The inconsistencies how different serial drivers handle this situation seem staggering. Perhaps there should be some effort to make the behavior uniform across them?
Quoted 4 lines
Quoted 1 line
Hmm yeah we should just have them all check for
co->index< 0.Right but it's only about that, some return -Exx codes (more than one -Exx variant) and some do assign just 0 like here.
What do you have in mind then? They should all assume co->index < 0 is an invalid console index still, right :)
Regards,
Tony
Quoted 1 line · Tony Lindgren
Let's not allow negative numbers for console index.
...
drivers/tty/serial/8250/8250_core.c static int univ8250_console_setup(struct console *co, char *options) · line 615
Quoted 3 lines
drivers/tty/serial/8250/8250_core.c +1
-1-if (co->index >=UART_NR ) +if (co->index <0 || co->index >=UART_NR ) co->index =0 ;
in_range() ?
Signature · 2 lines
With Best Regards, Andy Shevchenko