Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
From: syzbot <syzbot+a64a382964bf6c71a9c0@syzkaller.appspotmail.com>
To: Oliver Neukum <oneukum@suse.de>
Cc: andreyknvl@google.com, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	oneukum@suse.de, syzkaller-bugs@googlegroups.com
Subject: Re: Re: possible deadlock in usb_deregister_dev
Date: Tue, 06 Aug 2019 07:22:37 -0700
Message-ID: <0000000000006fd649058f738e01@google.com> (raw)
In-Reply-To: <1565101353.8136.27.camel@suse.de>

> Am Montag, den 05.08.2019, 04:58 -0700 schrieb syzbot:
>> Hello,

>> syzbot found the following crash on:

>> HEAD commit:    e96407b4 usb-fuzzer: main usb gadget fuzzer driver
>> git tree:       https://github.com/google/kasan.git usb-fuzzer
>> console output: https://syzkaller.appspot.com/x/log.txt?x=13b5bc8a600000
>> kernel config:   
>> https://syzkaller.appspot.com/x/.config?x=792eb47789f57810
>> dashboard link:  
>> https://syzkaller.appspot.com/bug?extid=a64a382964bf6c71a9c0
>> compiler:       gcc (GCC) 9.0.0 20181231 (experimental)

>> Unfortunately, I don't have any reproducer for this crash yet.

>> IMPORTANT: if you fix the bug, please add the following tag to the  
>> commit:
>> Reported-by: syzbot+a64a382964bf6c71a9c0@syzkaller.appspotmail.com

> #syz test: https://github.com/google/kasan.git e96407b4

This crash does not have a reproducer. I cannot test it.


>  From 973e82b3f583113e4d7fe5cd2f918a16022c4e38 Mon Sep 17 00:00:00 2001
> From: Oliver Neukum <oneukum@suse.com>
> Date: Tue, 6 Aug 2019 16:17:54 +0200
> Subject: [PATCH] usb: iowarrior: fix deadlock on disconnect

> We have to drop the mutex before we close() upon disconnect()
> as close() needs the lock. This is safe to do by dropping the
> mutex as intfdata is already set to NULL, so open() will fail.

> Fixes: 03f36e885fc26 ("USB: open disconnect race in iowarrior")
> Reported-by: syzbot+a64a382964bf6c71a9c0@syzkaller.appspotmail.com
> Signed-off-by: Oliver Neukum <oneukum@suse.com>
> ---
>   drivers/usb/misc/iowarrior.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)

> diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
> index ba05dd80a020..f5bed9f29e56 100644
> --- a/drivers/usb/misc/iowarrior.c
> +++ b/drivers/usb/misc/iowarrior.c
> @@ -866,19 +866,20 @@ static void iowarrior_disconnect(struct  
> usb_interface *interface)
>   	dev = usb_get_intfdata(interface);
>   	mutex_lock(&iowarrior_open_disc_lock);
>   	usb_set_intfdata(interface, NULL);
> +	/* prevent device read, write and ioctl */
> +	dev->present = 0;

>   	minor = dev->minor;
> +	mutex_unlock(&iowarrior_open_disc_lock);
> +	/* give back our minor - this will call close() locks need to be  
> dropped at this point*/

> -	/* give back our minor */
>   	usb_deregister_dev(interface, &iowarrior_class);

>   	mutex_lock(&dev->mutex);

>   	/* prevent device read, write and ioctl */
> -	dev->present = 0;

>   	mutex_unlock(&dev->mutex);
> -	mutex_unlock(&iowarrior_open_disc_lock);

>   	if (dev->opened) {
>   		/* There is a process that holds a filedescriptor to the device ,
> --
> 2.16.4


  reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-06 14:22 Oliver Neukum
2019-08-06 14:22 ` syzbot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-08-05 11:58 syzbot
2019-08-09 18:18 ` syzbot
2019-08-09 19:32   ` Alan Stern
2019-08-12 12:11     ` Andrey Konovalov
2019-08-12 12:31       ` syzbot

Reply instructions:

You may reply publically 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=0000000000006fd649058f738e01@google.com \
    --to=syzbot+a64a382964bf6c71a9c0@syzkaller.appspotmail.com \
    --cc=andreyknvl@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=oneukum@suse.de \
    --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

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git