Re: [PATCH v2 1/2] printk: Check valid console index for preferred console

Tony Lindgren
2023-10-12T06:25:43Z

* Jiri Slaby <jirislaby@kernel.org> [231012 05:54]:
> On 11. 10. 23, 9:43, Tony Lindgren wrote:
> > Let's check for valid console index values to avoid bogus console index
> > numbers from kernel command line. While struct console uses short for
> > index, and negative index values are used by some device drivers, we do
> > not want to allow negative values for preferred console.
> >
> > Let's change the idx to short to match struct console, and return an error
> > on negative values. And let's also constify idx while at it.
> >
> > Signed-off-by: Tony Lindgren <tony@atomide.com>
> ...
> > --- a/kernel/printk/printk.c
> > +++ b/kernel/printk/printk.c
> > @@ -2404,12 +2404,19 @@ static void set_user_specified(struct console_cmdline *c, bool user_specified)
> > console_set_on_cmdline = 1;
> > }
> > -static int __add_preferred_console(char *name, int idx, char *options,
> > +static int __add_preferred_console(const char *name, const short idx, char *options,
>
> This "const char *name" change is somehow not related to 1/2, but to 2/2, I
> suppose.

Thanks I just noticed that too, that sneaked in while I was resolving a
merge conflict while changing the order of the two patches.

Regards,

Tony