* [PATCH] serial: 8250: Check for valid console index
@ 2023-10-04 8:55 Tony Lindgren
2023-10-04 9:05 ` Ilpo Järvinen
2023-10-05 9:08 ` Andy Shevchenko
0 siblings, 2 replies; 6+ messages in thread
From: Tony Lindgren @ 2023-10-04 8:55 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: Andy Shevchenko, Dhruva Gole, Ilpo Järvinen, John Ogness,
Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra,
linux-kernel, linux-serial
Let's not allow negative numbers for console index.
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/tty/serial/8250/8250_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -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;
/*
--
2.42.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] serial: 8250: Check for valid console index
2023-10-04 8:55 [PATCH] serial: 8250: Check for valid console index Tony Lindgren
@ 2023-10-04 9:05 ` Ilpo Järvinen
2023-10-04 9:08 ` Tony Lindgren
2023-10-05 9:08 ` Andy Shevchenko
1 sibling, 1 reply; 6+ messages in thread
From: Ilpo Järvinen @ 2023-10-04 9:05 UTC (permalink / raw)
To: Tony Lindgren
Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Dhruva Gole,
John Ogness, Johan Hovold, Sebastian Andrzej Siewior,
Vignesh Raghavendra, LKML, linux-serial
On Wed, 4 Oct 2023, Tony Lindgren wrote:
> Let's not allow negative numbers for console index.
>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
> drivers/tty/serial/8250/8250_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
> --- a/drivers/tty/serial/8250/8250_core.c
> +++ b/drivers/tty/serial/8250/8250_core.c
> @@ -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?
--
i.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] serial: 8250: Check for valid console index
2023-10-04 9:05 ` Ilpo Järvinen
@ 2023-10-04 9:08 ` Tony Lindgren
2023-10-04 9:13 ` Ilpo Järvinen
0 siblings, 1 reply; 6+ messages in thread
From: Tony Lindgren @ 2023-10-04 9:08 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Dhruva Gole,
John Ogness, Johan Hovold, Sebastian Andrzej Siewior,
Vignesh Raghavendra, LKML, linux-serial
* Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> [231004 09:05]:
> On Wed, 4 Oct 2023, Tony Lindgren wrote:
>
> > Let's not allow negative numbers for console index.
> >
> > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > ---
> > drivers/tty/serial/8250/8250_core.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
> > --- a/drivers/tty/serial/8250/8250_core.c
> > +++ b/drivers/tty/serial/8250/8250_core.c
> > @@ -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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] serial: 8250: Check for valid console index
2023-10-04 9:08 ` Tony Lindgren
@ 2023-10-04 9:13 ` Ilpo Järvinen
2023-10-04 9:21 ` Tony Lindgren
0 siblings, 1 reply; 6+ messages in thread
From: Ilpo Järvinen @ 2023-10-04 9:13 UTC (permalink / raw)
To: Tony Lindgren
Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Dhruva Gole,
John Ogness, Johan Hovold, Sebastian Andrzej Siewior,
Vignesh Raghavendra, LKML, linux-serial
[-- Attachment #1: Type: text/plain, Size: 1284 bytes --]
On Wed, 4 Oct 2023, Tony Lindgren wrote:
> * Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> [231004 09:05]:
> > On Wed, 4 Oct 2023, Tony Lindgren wrote:
> >
> > > Let's not allow negative numbers for console index.
> > >
> > > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > > ---
> > > drivers/tty/serial/8250/8250_core.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
> > > --- a/drivers/tty/serial/8250/8250_core.c
> > > +++ b/drivers/tty/serial/8250/8250_core.c
> > > @@ -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.
Right but it's only about that, some return -Exx codes (more than one -Exx
variant) and some do assign just 0 like here.
--
i.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] serial: 8250: Check for valid console index
2023-10-04 9:13 ` Ilpo Järvinen
@ 2023-10-04 9:21 ` Tony Lindgren
0 siblings, 0 replies; 6+ messages in thread
From: Tony Lindgren @ 2023-10-04 9:21 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Dhruva Gole,
John Ogness, Johan Hovold, Sebastian Andrzej Siewior,
Vignesh Raghavendra, LKML, linux-serial
* Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> [231004 09:13]:
> On Wed, 4 Oct 2023, Tony Lindgren wrote:
>
> > * Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> [231004 09:05]:
> > > On Wed, 4 Oct 2023, Tony Lindgren wrote:
> > >
> > > > Let's not allow negative numbers for console index.
> > > >
> > > > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > > > ---
> > > > drivers/tty/serial/8250/8250_core.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
> > > > --- a/drivers/tty/serial/8250/8250_core.c
> > > > +++ b/drivers/tty/serial/8250/8250_core.c
> > > > @@ -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.
>
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] serial: 8250: Check for valid console index
2023-10-04 8:55 [PATCH] serial: 8250: Check for valid console index Tony Lindgren
2023-10-04 9:05 ` Ilpo Järvinen
@ 2023-10-05 9:08 ` Andy Shevchenko
1 sibling, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2023-10-05 9:08 UTC (permalink / raw)
To: Tony Lindgren
Cc: Greg Kroah-Hartman, Jiri Slaby, Dhruva Gole, Ilpo Järvinen,
John Ogness, Johan Hovold, Sebastian Andrzej Siewior,
Vignesh Raghavendra, linux-kernel, linux-serial
On Wed, Oct 04, 2023 at 11:55:10AM +0300, Tony Lindgren wrote:
> Let's not allow negative numbers for console index.
...
> - if (co->index >= UART_NR)
> + if (co->index < 0 || co->index >= UART_NR)
> co->index = 0;
in_range() ?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-10-05 14:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-04 8:55 [PATCH] serial: 8250: Check for valid console index Tony Lindgren
2023-10-04 9:05 ` Ilpo Järvinen
2023-10-04 9:08 ` Tony Lindgren
2023-10-04 9:13 ` Ilpo Järvinen
2023-10-04 9:21 ` Tony Lindgren
2023-10-05 9:08 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).