mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Jan Kara <jack@suse.cz>
Cc: Christian Brauner <brauner@kernel.org>,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Jiri Slaby <jirislaby@kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-serial <linux-serial@vger.kernel.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH] tty: tty_io: fix race between tty_fops and hung_up_tty_fops
Date: Mon, 22 Jul 2024 18:24:50 +0200	[thread overview]
Message-ID: <2024072238-reversing-despise-b555@gregkh> (raw)
In-Reply-To: <20240722161041.t6vizbeuxy5kj4kz@quack3>

On Mon, Jul 22, 2024 at 06:10:41PM +0200, Jan Kara wrote:
> On Mon 22-07-24 16:41:22, Christian Brauner wrote:
> > On Fri, Jul 19, 2024 at 10:37:47PM GMT, Tetsuo Handa wrote:
> > > syzbot is reporting data race between __tty_hangup() and __fput(), and
> > > Dmitry Vyukov mentioned that this race has possibility of NULL pointer
> > > dereference, for tty_fops implements e.g. splice_read callback whereas
> > > hung_up_tty_fops does not.
> > > 
> > >   CPU0                                  CPU1
> > >   ----                                  ----
> > >   do_splice_read() {
> > >                                         __tty_hangup() {
> > >     // f_op->splice_read was copy_splice_read
> > >     if (unlikely(!in->f_op->splice_read))
> > >       return warn_unsupported(in, "read");
> > >                                           filp->f_op = &hung_up_tty_fops;
> > >     // f_op->splice_read is now NULL
> > >     return in->f_op->splice_read(in, ppos, pipe, len, flags);
> > >                                         }
> > >   }
> > > 
> > > Fix possibility of NULL pointer dereference by implementing missing
> > > callbacks, and suppress KCSAN messages by adding __data_racy qualifier
> > > to "struct file"->f_op .
> > 
> > This f_op replacing without synchronization seems really iffy imho.
> 
> Yeah, when I saw this I was also going "ouch". I was just waiting whether a
> tty maintainer will comment ;)

I really didn't want to :)

> Anyway this replacement of ops in file /
> inode has proven problematic in almost every single case where it was used
> leading to subtle issues.

Yeah, let's not do this.

Let me dig after -rc1 is out and see if there's a better way to handle
this contrived race condition...

thanks,

greg k-h

  reply	other threads:[~2024-07-22 16:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-19 13:37 Tetsuo Handa
2024-07-22 14:41 ` Christian Brauner
2024-07-22 16:10   ` Jan Kara
2024-07-22 16:24     ` Greg Kroah-Hartman [this message]
2024-07-22 22:20       ` Tetsuo Handa
2024-07-25 14:08         ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2024072238-reversing-despise-b555@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=jirislaby@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®