linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Zhang, Qiang" <Qiang.Zhang@windriver.com>
To: Oliver Neukum <oneukum@suse.com>,
	syzbot <syzbot+9e04e2df4a32fb661daf@syzkaller.appspotmail.com>,
	"andreyknvl@google.com" <andreyknvl@google.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"gustavoars@kernel.org" <gustavoars@kernel.org>,
	"ingrassia@epigenesys.com" <ingrassia@epigenesys.com>,
	"lee.jones@linaro.org" <lee.jones@linaro.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"penguin-kernel@I-love.SAKURA.ne.jp" 
	<penguin-kernel@i-love.sakura.ne.jp>,
	"syzkaller-bugs@googlegroups.com"
	<syzkaller-bugs@googlegroups.com>
Subject: 回复: KASAN: use-after-free Read in service_outstanding_interrupt
Date: Tue, 5 Jan 2021 04:50:45 +0000	[thread overview]
Message-ID: <BYAPR11MB2632EDC88523D674D9C63E73FFD10@BYAPR11MB2632.namprd11.prod.outlook.com> (raw)
In-Reply-To: <6a56df508f597d38746878e80e1f159a556d3152.camel@suse.com>



________________________________________
发件人: Oliver Neukum <oneukum@suse.com>
发送时间: 2021年1月5日 0:28
收件人: syzbot; andreyknvl@google.com; gregkh@linuxfoundation.org; gustavoars@kernel.org; ingrassia@epigenesys.com; lee.jones@linaro.org; linux-kernel@vger.kernel.org; linux-usb@vger.kernel.org; penguin-kernel@I-love.SAKURA.ne.jp; syzkaller-bugs@googlegroups.com
主题: Re: KASAN: use-after-free Read in service_outstanding_interrupt

Am Donnerstag, den 17.12.2020, 19:21 -0800 schrieb syzbot:
> syzbot has found a reproducer for the following issue on:
>
> HEAD commit:    5e60366d Merge tag 'fallthrough-fixes-clang-5.11-rc1' of g..
> git tree:       https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
> console output: https://syzkaller.appspot.com/x/log.txt?x=12c5b623500000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=5cea7506b7139727
> dashboard link: https://syzkaller.appspot.com/bug?extid=9e04e2df4a32fb661daf
> compiler:       gcc (GCC) 10.1.0-syz 20200507
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=175adf07500000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1672680f500000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: >syzbot+9e04e2df4a32fb661daf@syzkaller.appspotmail.com
>
>#syz test: https://github.com/google/kasan.git  5e60366d
>

 Hello Oliver 
 
 this use-after-free still exists,It can be seen from calltrace that it is 
 usb_device's object  has been released when disconnect,
 can add a reference count to usb_device's object to avoid this problem 
 
 diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 508b1c3f8b73..001cb93da6bf 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -106,6 +106,7 @@ struct wdm_device {
 
        struct list_head        device_list;
        int                     (*manage_power)(struct usb_interface *, int);
+       struct usb_device       *usb_dev;
 };
 
 static struct usb_driver wdm_driver;
@@ -338,6 +339,7 @@ static void free_urbs(struct wdm_device *desc)
 
 static void cleanup(struct wdm_device *desc)
 {
+       usb_put_dev(desc->usb_dev);
        kfree(desc->sbuf);
        kfree(desc->inbuf);
        kfree(desc->orq);
@@ -855,6 +857,7 @@ static int wdm_create(struct usb_interface *intf, struct usb_endpoint_descripto
r
        desc->intf = intf;
        INIT_WORK(&desc->rxwork, wdm_rxwork);
        INIT_WORK(&desc->service_outs_intr, service_interrupt_work);
+       desc->usb_dev = usb_get_dev(interface_to_usbdev(intf));
 
        rv = -EINVAL;
        if (!usb_endpoint_is_int_in(ep))




>From f51e3c5a202f3abc805edd64b21a68d29dd9d60e Mon Sep 17 >00:00:00 2001
>From: Oliver Neukum <oneukum@suse.com>
>Date: Mon, 4 Jan 2021 17:26:33 +0100
>Subject: [PATCH] cdc-wdm: poison URBs upon disconnect
>
>We have a chicken and egg issue between interrupt and work.
>This should break the cycle.
>
>Signed-off-by: Oliver Neukum <oneukum@suse.com>
>---
>drivers/usb/class/cdc-wdm.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc->wdm.c
>index 02d0cfd23bb2..14eddda35280 100644
>--- a/drivers/usb/class/cdc-wdm.c
>+++ b/drivers/usb/class/cdc-wdm.c
>@@ -324,9 +324,9 @@ static void wdm_int_callback(struct urb *urb)
>static void kill_urbs(struct wdm_device *desc)
> {
>       /* the order here is essential */
>-       usb_kill_urb(desc->command);
>-       usb_kill_urb(desc->validity);
>-       usb_kill_urb(desc->response);
>+       usb_poison_urb(desc->command);
>+       usb_poison_urb(desc->validity);
>+       usb_poison_urb(desc->response);
> }
>
> static void free_urbs(struct wdm_device *desc)
>--
>2.26.2



  parent reply	other threads:[~2021-01-05  4:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-07 12:19 KASAN: use-after-free Read in service_outstanding_interrupt syzbot
2020-12-18  3:21 ` syzbot
2020-12-18 14:03   ` Tetsuo Handa
2020-12-19 15:25     ` [PATCH] USB: cdc-wdm: Fix use after free in service_outstanding_interrupt() Tetsuo Handa
2020-12-28 14:44       ` Oliver Neukum
2021-01-04 16:28   ` KASAN: use-after-free Read in service_outstanding_interrupt Oliver Neukum
2021-01-04 16:44     ` syzbot
2021-01-05  4:50     ` Zhang, Qiang [this message]
2021-01-05 10:51       ` 回复: " Oliver Neukum
     [not found] ` <20201218082113.1238-1-hdanton@sina.com>
2020-12-18  8:28   ` Greg KH
     [not found]   ` <20201218100134.1351-1-hdanton@sina.com>
2020-12-18 10:32     ` 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=BYAPR11MB2632EDC88523D674D9C63E73FFD10@BYAPR11MB2632.namprd11.prod.outlook.com \
    --to=qiang.zhang@windriver.com \
    --cc=andreyknvl@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavoars@kernel.org \
    --cc=ingrassia@epigenesys.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=syzbot+9e04e2df4a32fb661daf@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).