Re: [PATCH] printk: handle blank console arguments passed in.

From: Sergey Senozhatsky
Date: Wed Oct 07 2020 - 10:39:27 EST


On (20/10/07 21:30), Sergey Senozhatsky wrote:
> On (20/10/07 09:28), Petr Mladek wrote:
> >
> > /*
> > * Dirty hack to prevent using any console with tty
> > * binding as a fallback and adding the empty
> > * name into console_cmdline array.
> > */
> > preferred_console = MAX_CMDLINECONSOLES;
[..]
> Hint: I can crash my laptop when I remove the "console=" boot param and
> comment out init_dup(file) calls in console_on_rootfs().

My guess is that since we don't have stdin/out/err fds then,
theoretically, something like this can happen

int main()
{
...
int fd = open(.... );
int fd = open(..., "vfat.ko");

//fd is 1

fprintf(stdout, "loading vfat\n");
...
}

stdout (fd 1) is not stdout, it's fd that we got from open(vfat.ko).

Does this make sense?

-ss