Re: How to handle concurrent access to /dev/ttyprintk ?

From: Greg Kroah-Hartman
Date: Mon Apr 12 2021 - 06:44:26 EST


On Mon, Apr 12, 2021 at 07:39:04PM +0900, Tetsuo Handa wrote:
> What is the intended usage of /dev/ttyprintk ?
>
> It seems that drivers/char/ttyprintk.c was not designed to be opened by
> multiple processes. As a result, syzbot can trigger tty_warn() flooding
> enough to fire khungtaskd warning due to tty_port_close().
>
> Do we need to allow concurrent access to /dev/ttyprintk ?
> If we can't change /dev/ttyprintk exclusively open()able by only
> one thread, how to handle concurrent access to /dev/ttyprintk ?

Like any tty port, if you have multiple accesses, all bets are off and
hilarity ensues. Just don't do that and expect things to be working
well.

And trying to "open exclusive only" just does not work, the kernel can
not enforce that at all, sorry. Any driver that you see trying to do
that is trivial to work around in userspace, making the kernel code
pointless.

That being said, triggering warning messages is not good, we should fix
that where possible as what's preventing any other tty device from doing
the same?

thanks,

greg k-h