Messages in this thread | | | Date | Mon, 12 Apr 2021 14:04:55 +0200 | From | Greg Kroah-Hartman <> | Subject | Re: How to handle concurrent access to /dev/ttyprintk ? |
| |
On Mon, Apr 12, 2021 at 08:25:27PM +0900, Tetsuo Handa wrote: > On 2021/04/12 19:44, Greg Kroah-Hartman wrote: > > 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. > > You mean something like below cannot be used? > > diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c > index 6a0059e508e3..57200569918a 100644 > --- a/drivers/char/ttyprintk.c > +++ b/drivers/char/ttyprintk.c > @@ -84,14 +84,26 @@ static int tpk_printk(const unsigned char *buf, int count) > return count; > } > > +static DEFINE_MUTEX(open_close_lock);
Hah, nope, does not work at all!
Think about sending an open file descriptor all around the system, or through a pipe, your "open only once" check does not prevent that at all.
> > 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. > > Since syzkaller is a fuzzer, syzkaller happily opens /dev/ttyprintk from > multiple threads. Should we update syzkaller to use CONFIG_TTY_PRINTK=n ?
Why? Can you not hit the same tty code paths from any other tty driver being open multiple times? Why is ttyprintk somehow "special" here?
thanks,
greg k-h
| |