From: David Miller <davem@davemloft.net>
To: Jan.Kloetzke@preh.de
Cc: oneukum@suse.com, jan@kloetzke.net, netdev@vger.kernel.org,
linux-usb@vger.kernel.org
Subject: Re: [PATCH v3] usbnet: fix kernel crash after disconnect
Date: Tue, 21 May 2019 13:47:04 -0700 (PDT) [thread overview]
Message-ID: <20190521.134704.1456978856134153782.davem@davemloft.net> (raw)
In-Reply-To: <20190521131826.30475-1-Jan.Kloetzke@preh.de>
From: Kloetzke Jan <Jan.Kloetzke@preh.de>
Date: Tue, 21 May 2019 13:18:40 +0000
> When disconnecting cdc_ncm the kernel sporadically crashes shortly
> after the disconnect:
...
> The crash happens roughly 125..130ms after the disconnect. This
> correlates with the 'delay' timer that is started on certain USB tx/rx
> errors in the URB completion handler.
>
> The problem is a race of usbnet_stop() with usbnet_start_xmit(). In
> usbnet_stop() we call usbnet_terminate_urbs() to cancel all URBs in
> flight. This only makes sense if no new URBs are submitted
> concurrently, though. But the usbnet_start_xmit() can run at the same
> time on another CPU which almost unconditionally submits an URB. The
> error callback of the new URB will then schedule the timer after it was
> already stopped.
>
> The fix adds a check if the tx queue is stopped after the tx list lock
> has been taken. This should reliably prevent the submission of new URBs
> while usbnet_terminate_urbs() does its job. The same thing is done on
> the rx side even though it might be safe due to other flags that are
> checked there.
>
> Signed-off-by: Jan Klötzke <Jan.Kloetzke@preh.de>
Applied.
prev parent reply other threads:[~2019-05-21 20:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-17 9:19 [PATCH] usbnet: fix kernel crash after disconnect Kloetzke Jan
2019-04-18 6:37 ` Oliver Neukum
2019-04-18 8:02 ` Kloetzke Jan
2019-04-18 23:35 ` David Miller
2019-04-19 7:17 ` Jan Klötzke
2019-04-29 18:48 ` Oliver Neukum
2019-04-30 14:08 ` Kloetzke Jan
2019-04-30 14:15 ` [PATCH v2] " Kloetzke Jan
2019-05-05 7:45 ` David Miller
2019-05-06 8:17 ` Oliver Neukum
2019-05-16 7:10 ` Kloetzke Jan
2019-05-21 0:09 ` David Miller
2019-05-21 9:48 ` Oliver Neukum
2019-05-21 10:12 ` Kloetzke Jan
2019-05-21 11:42 ` Oliver Neukum
2019-05-21 13:18 ` [PATCH v3] " Kloetzke Jan
2019-05-21 20:47 ` David Miller [this message]
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=20190521.134704.1456978856134153782.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=Jan.Kloetzke@preh.de \
--cc=jan@kloetzke.net \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oneukum@suse.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).