Re: [PATCH] printk: handle blank console arguments passed in.
From: Guenter Roeck
Date: Wed Oct 07 2020 - 11:57:12 EST
On 10/7/20 5:30 AM, Sergey Senozhatsky wrote:
[ ... ]
>
> console_on_rootfs() attempts to filp_open()->tty_open() /dev/console.
> This ends up in printk's console_device(), which iterates the list of
> console drivers and returns associated console->device back to tty. The
> problem is that console drivers list is empty, so the function returns
> NULL, and filp_open("/dev/console") fails. But the console_on_rootfs()
> comment says that this function should never fail (!). This sort of
> makes me wonder if "console=" is actually legal.
>
I would not want to use a term such as "legal". It just happened to work
and was used.
> Hint: I can crash my laptop when I remove the "console=" boot param and
> comment out init_dup(file) calls in console_on_rootfs().
>
I can see to options: Link /dev/console to /dev/null if there is no console,
or do something like
if (IS_ERR(file)) {
pr_warn("Warning: unable to open an initial console.\n");
file = filp_open("/dev/null", O_RDWR, 0);
if (IS_ERR(file))
return;
}
Guenter