From: Oliver Neukum <oneukum@suse.com>
To: Greg KH <gregKH@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] usblp: fix race between disconnect() and read()
Date: Thu, 17 Sep 2020 14:03:11 +0200 [thread overview]
Message-ID: <1600344191.2424.44.camel@suse.com> (raw)
In-Reply-To: <20200917114347.GA3436799@kroah.com>
Am Donnerstag, den 17.09.2020, 13:43 +0200 schrieb Greg KH:
> On Thu, Sep 17, 2020 at 12:34:27PM +0200, Oliver Neukum wrote:
> > read() needs to check whether the device has been
> > disconnected before it tries to talk to the device.
> >
> > Signed-off-by: Oliver Neukum <oneukum@suse.com>
> > Reported-by: syzbot+be5b5f86a162a6c281e6@syzkaller.appspotmail.com
> > ---
> > drivers/usb/class/usblp.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
> > index 084c48c5848f..67cbd42421be 100644
> > --- a/drivers/usb/class/usblp.c
> > +++ b/drivers/usb/class/usblp.c
> > @@ -827,6 +827,11 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t len, lo
> > if (rv < 0)
> > return rv;
> >
> > + if (!usblp->present) {
> > + count = -ENODEV;
> > + goto done;
> > + }
> > +
>
> What prevents ->present from not being changed right after this test?
Hi,
the mutex taken in
rv = usblp_rwait_and_lock(usblp, !!(file->f_flags & O_NONBLOCK));
right above it. Yes, this driver is a mess. But short of adding
a ton of comments or rewriting the whole thing I have no idea
what to do about that.
Regards
Oliver
next prev parent reply other threads:[~2020-09-17 12:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-17 10:34 [PATCH] usblp: fix race between disconnect() and read() Oliver Neukum
2020-09-17 11:43 ` Greg KH
2020-09-17 12:03 ` Oliver Neukum [this message]
2020-09-17 16:45 ` Greg KH
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=1600344191.2424.44.camel@suse.com \
--to=oneukum@suse.com \
--cc=gregKH@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.