linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Andrey Konovalov <andreyknvl@google.com>
Cc: Greg KH <greg@kroah.com>,
	syzbot <syzbot+30cf45ebfe0b0c4847a1@syzkaller.appspotmail.com>,
	Bjorn Helgaas <bhelgaas@google.com>, <kirr@nexedi.com>,
	Kernel development list <linux-kernel@vger.kernel.org>,
	USB list <linux-usb@vger.kernel.org>,
	Guenter Roeck <linux@roeck-us.net>, <lkundrak@v3.sk>,
	<logang@deltatee.com>,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>
Subject: Re: KASAN: use-after-free Read in ld_usb_release
Date: Mon, 12 Aug 2019 10:21:14 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.1908121020180.1659-100000@iolanthe.rowland.org> (raw)
In-Reply-To: <CAAeHK+xZgjD+gP=pCkk0uKVkuPG+XZ26mgNQCGzw2ea5mqFTJg@mail.gmail.com>

On Mon, 12 Aug 2019, Andrey Konovalov wrote:

> Alan, could you submit this patch (if you haven't already)? Looks like
> it fixes this bug (and might fix some others).

I will.  I was waiting to see if Greg KH had any comments.

Alan Stern


> >  drivers/usb/core/file.c |   10 +++++-----
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > Index: usb-devel/drivers/usb/core/file.c
> > ===================================================================
> > --- usb-devel.orig/drivers/usb/core/file.c
> > +++ usb-devel/drivers/usb/core/file.c
> > @@ -193,9 +193,10 @@ int usb_register_dev(struct usb_interfac
> >                 intf->minor = minor;
> >                 break;
> >         }
> > -       up_write(&minor_rwsem);
> > -       if (intf->minor < 0)
> > +       if (intf->minor < 0) {
> > +               up_write(&minor_rwsem);
> >                 return -EXFULL;
> > +       }
> >
> >         /* create a usb class device for this usb interface */
> >         snprintf(name, sizeof(name), class_driver->name, minor - minor_base);
> > @@ -203,12 +204,11 @@ int usb_register_dev(struct usb_interfac
> >                                       MKDEV(USB_MAJOR, minor), class_driver,
> >                                       "%s", kbasename(name));
> >         if (IS_ERR(intf->usb_dev)) {
> > -               down_write(&minor_rwsem);
> >                 usb_minors[minor] = NULL;
> >                 intf->minor = -1;
> > -               up_write(&minor_rwsem);
> >                 retval = PTR_ERR(intf->usb_dev);
> >         }
> > +       up_write(&minor_rwsem);
> >         return retval;
> >  }
> >  EXPORT_SYMBOL_GPL(usb_register_dev);
> > @@ -234,12 +234,12 @@ void usb_deregister_dev(struct usb_inter
> >                 return;
> >
> >         dev_dbg(&intf->dev, "removing %d minor\n", intf->minor);
> > +       device_destroy(usb_class->class, MKDEV(USB_MAJOR, intf->minor));
> >
> >         down_write(&minor_rwsem);
> >         usb_minors[intf->minor] = NULL;
> >         up_write(&minor_rwsem);
> >
> > -       device_destroy(usb_class->class, MKDEV(USB_MAJOR, intf->minor));
> >         intf->usb_dev = NULL;
> >         intf->minor = -1;
> >         destroy_usb_class();


  reply	other threads:[~2019-08-12 14:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-09 13:18 KASAN: use-after-free Read in ld_usb_release syzbot
2019-08-09 16:51 ` Alan Stern
2019-08-09 17:33   ` Andrey Konovalov
2019-08-09 17:53     ` syzbot
2019-08-12 12:07   ` Andrey Konovalov
2019-08-12 14:21     ` Alan Stern [this message]
2019-08-12 14:31       ` Greg KH
2019-08-12 15:31   ` Greg KH
2019-08-12 20:11   ` [PATCH] USB: core: Fix races in character device registration and deregistraion Alan Stern
2019-08-12 20:52     ` 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=Pine.LNX.4.44L0.1908121020180.1659-100000@iolanthe.rowland.org \
    --to=stern@rowland.harvard.edu \
    --cc=andreyknvl@google.com \
    --cc=bhelgaas@google.com \
    --cc=greg@kroah.com \
    --cc=kirr@nexedi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lkundrak@v3.sk \
    --cc=logang@deltatee.com \
    --cc=syzbot+30cf45ebfe0b0c4847a1@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /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;
as well as URLs for NNTP newsgroup(s).