LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, "Jan Klötzke" <Jan.Kloetzke@preh.de>,
"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 4.19 17/32] usbnet: fix kernel crash after disconnect
Date: Mon, 3 Jun 2019 11:08:11 +0200 [thread overview]
Message-ID: <20190603090313.578874049@linuxfoundation.org> (raw)
In-Reply-To: <20190603090308.472021390@linuxfoundation.org>
From: Kloetzke Jan <Jan.Kloetzke@preh.de>
[ Upstream commit ad70411a978d1e6e97b1e341a7bde9a79af0c93d ]
When disconnecting cdc_ncm the kernel sporadically crashes shortly
after the disconnect:
[ 57.868812] Unable to handle kernel NULL pointer dereference at virtual address 00000000
...
[ 58.006653] PC is at 0x0
[ 58.009202] LR is at call_timer_fn+0xec/0x1b4
[ 58.013567] pc : [<0000000000000000>] lr : [<ffffff80080f5130>] pstate: 00000145
[ 58.020976] sp : ffffff8008003da0
[ 58.024295] x29: ffffff8008003da0 x28: 0000000000000001
[ 58.029618] x27: 000000000000000a x26: 0000000000000100
[ 58.034941] x25: 0000000000000000 x24: ffffff8008003e68
[ 58.040263] x23: 0000000000000000 x22: 0000000000000000
[ 58.045587] x21: 0000000000000000 x20: ffffffc68fac1808
[ 58.050910] x19: 0000000000000100 x18: 0000000000000000
[ 58.056232] x17: 0000007f885aff8c x16: 0000007f883a9f10
[ 58.061556] x15: 0000000000000001 x14: 000000000000006e
[ 58.066878] x13: 0000000000000000 x12: 00000000000000ba
[ 58.072201] x11: ffffffc69ff1db30 x10: 0000000000000020
[ 58.077524] x9 : 8000100008001000 x8 : 0000000000000001
[ 58.082847] x7 : 0000000000000800 x6 : ffffff8008003e70
[ 58.088169] x5 : ffffffc69ff17a28 x4 : 00000000ffff138b
[ 58.093492] x3 : 0000000000000000 x2 : 0000000000000000
[ 58.098814] x1 : 0000000000000000 x0 : 0000000000000000
...
[ 58.205800] [< (null)>] (null)
[ 58.210521] [<ffffff80080f5298>] expire_timers+0xa0/0x14c
[ 58.215937] [<ffffff80080f542c>] run_timer_softirq+0xe8/0x128
[ 58.221702] [<ffffff8008081120>] __do_softirq+0x298/0x348
[ 58.227118] [<ffffff80080a6304>] irq_exit+0x74/0xbc
[ 58.232009] [<ffffff80080e17dc>] __handle_domain_irq+0x78/0xac
[ 58.237857] [<ffffff8008080cf4>] gic_handle_irq+0x80/0xac
...
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/usb/usbnet.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -506,6 +506,7 @@ static int rx_submit (struct usbnet *dev
if (netif_running (dev->net) &&
netif_device_present (dev->net) &&
+ test_bit(EVENT_DEV_OPEN, &dev->flags) &&
!test_bit (EVENT_RX_HALT, &dev->flags) &&
!test_bit (EVENT_DEV_ASLEEP, &dev->flags)) {
switch (retval = usb_submit_urb (urb, GFP_ATOMIC)) {
@@ -1431,6 +1432,11 @@ netdev_tx_t usbnet_start_xmit (struct sk
spin_unlock_irqrestore(&dev->txq.lock, flags);
goto drop;
}
+ if (netif_queue_stopped(net)) {
+ usb_autopm_put_interface_async(dev->intf);
+ spin_unlock_irqrestore(&dev->txq.lock, flags);
+ goto drop;
+ }
#ifdef CONFIG_PM
/* if this triggers the device is still a sleep */
next prev parent reply other threads:[~2019-06-03 9:11 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-03 9:07 [PATCH 4.19 00/32] 4.19.48-stable review Greg Kroah-Hartman
2019-06-03 9:07 ` [PATCH 4.19 01/32] bonding/802.3ad: fix slave link initialization transition states Greg Kroah-Hartman
2019-06-03 9:07 ` [PATCH 4.19 02/32] cxgb4: offload VLAN flows regardless of VLAN ethtype Greg Kroah-Hartman
2019-06-03 9:07 ` [PATCH 4.19 03/32] inet: switch IP ID generator to siphash Greg Kroah-Hartman
2019-06-03 9:07 ` [PATCH 4.19 04/32] ipv4/igmp: fix another memory leak in igmpv3_del_delrec() Greg Kroah-Hartman
2019-06-03 9:07 ` [PATCH 4.19 05/32] ipv4/igmp: fix build error if !CONFIG_IP_MULTICAST Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 06/32] ipv6: Consider sk_bound_dev_if when binding a raw socket to an address Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 07/32] ipv6: Fix redirect with VRF Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 08/32] llc: fix skb leak in llc_build_and_send_ui_pkt() Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 09/32] net: dsa: mv88e6xxx: fix handling of upper half of STATS_TYPE_PORT Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 10/32] net: fec: fix the clk mismatch in failed_reset path Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 11/32] net-gro: fix use-after-free read in napi_gro_frags() Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 12/32] net: mvneta: Fix err code path of probe Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 13/32] net: mvpp2: fix bad MVPP2_TXQ_SCHED_TOKEN_CNTR_REG queue value Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 14/32] net: phy: marvell10g: report if the PHY fails to boot firmware Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 15/32] net: sched: dont use tc_action->order during action dump Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 16/32] net: stmmac: fix reset gpio free missing Greg Kroah-Hartman
2019-06-03 9:08 ` Greg Kroah-Hartman [this message]
2019-06-03 9:08 ` [PATCH 4.19 18/32] net/mlx5: Avoid double free in fs init error unwinding path Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 19/32] tipc: Avoid copying bytes beyond the supplied data Greg Kroah-Hartman
2019-06-04 7:49 ` Pavel Machek
2019-06-03 9:08 ` [PATCH 4.19 20/32] net/mlx5: Allocate root ns memory using kzalloc to match kfree Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 21/32] net/mlx5e: Disable rxhash when CQE compress is enabled Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 22/32] net: stmmac: dma channel control register need to be init first Greg Kroah-Hartman
2019-06-04 7:53 ` Pavel Machek
2019-06-03 9:08 ` [PATCH 4.19 23/32] bnxt_en: Fix aggregation buffer leak under OOM condition Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 24/32] net/tls: fix state removal with feature flags off Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 25/32] net/tls: dont ignore netdev notifications if no TLS features Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 26/32] crypto: vmx - ghash: do nosimd fallback manually Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 27/32] include/linux/compiler*.h: define asm_volatile_goto Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 28/32] compiler.h: give up __compiletime_assert_fallback() Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 29/32] jump_label: move asm goto support test to Kconfig Greg Kroah-Hartman
2019-06-04 9:30 ` Pavel Machek
2019-06-04 9:55 ` Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 30/32] xen/pciback: Dont disable PCI_COMMAND on PCI device reset Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 31/32] Revert "tipc: fix modprobe tipc failed after switch order of device registration" Greg Kroah-Hartman
2019-06-03 9:08 ` [PATCH 4.19 32/32] tipc: fix modprobe tipc failed after switch order of device registration Greg Kroah-Hartman
2019-06-03 15:09 ` [PATCH 4.19 00/32] 4.19.48-stable review kernelci.org bot
2019-06-03 17:16 ` Guenter Roeck
2019-06-03 18:33 ` Jon Hunter
2019-06-03 19:39 ` Naresh Kamboju
2019-06-03 23:33 ` shuah
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=20190603090313.578874049@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=Jan.Kloetzke@preh.de \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--subject='Re: [PATCH 4.19 17/32] usbnet: fix kernel crash after disconnect' \
/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
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).