linux/drivers/net
Souradeep Chakrabarti e0526ec536 hv_netvsc: Fix race condition between netvsc_probe and netvsc_remove
In commit ac50476717 ("hv_netvsc: Disable NAPI before closing the
VMBus channel"), napi_disable was getting called for all channels,
including all subchannels without confirming if they are enabled or not.

This caused hv_netvsc getting hung at napi_disable, when netvsc_probe()
has finished running but nvdev->subchan_work has not started yet.
netvsc_subchan_work() -> rndis_set_subchannel() has not created the
sub-channels and because of that netvsc_sc_open() is not running.
netvsc_remove() calls cancel_work_sync(&nvdev->subchan_work), for which
netvsc_subchan_work did not run.

netif_napi_add() sets the bit NAPI_STATE_SCHED because it ensures NAPI
cannot be scheduled. Then netvsc_sc_open() -> napi_enable will clear the
NAPIF_STATE_SCHED bit, so it can be scheduled. napi_disable() does the
opposite.

Now during netvsc_device_remove(), when napi_disable is called for those
subchannels, napi_disable gets stuck on infinite msleep.

This fix addresses this problem by ensuring that napi_disable() is not
getting called for non-enabled NAPI struct.
But netif_napi_del() is still necessary for these non-enabled NAPI struct
for cleanup purpose.

Call trace:
[  654.559417] task:modprobe        state:D stack:    0 pid: 2321 ppid:  1091 flags:0x00004002
[  654.568030] Call Trace:
[  654.571221]  <TASK>
[  654.573790]  __schedule+0x2d6/0x960
[  654.577733]  schedule+0x69/0xf0
[  654.581214]  schedule_timeout+0x87/0x140
[  654.585463]  ? __bpf_trace_tick_stop+0x20/0x20
[  654.590291]  msleep+0x2d/0x40
[  654.593625]  napi_disable+0x2b/0x80
[  654.597437]  netvsc_device_remove+0x8a/0x1f0 [hv_netvsc]
[  654.603935]  rndis_filter_device_remove+0x194/0x1c0 [hv_netvsc]
[  654.611101]  ? do_wait_intr+0xb0/0xb0
[  654.615753]  netvsc_remove+0x7c/0x120 [hv_netvsc]
[  654.621675]  vmbus_remove+0x27/0x40 [hv_vmbus]

Cc: stable@vger.kernel.org
Fixes: ac50476717 ("hv_netvsc: Disable NAPI before closing the VMBus channel")
Signed-off-by: Souradeep Chakrabarti <schakrabarti@linux.microsoft.com>
Reviewed-by: Dexuan Cui <decui@microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/1706686551-28510-1-git-send-email-schakrabarti@linux.microsoft.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-02-01 08:33:43 -08:00
..
arcnet arcnet: restoring support for multiple Sohard Arcnet cards 2023-12-04 18:01:20 -08:00
bonding
caif
can net: can: Use device_get_match_data() 2024-01-19 08:08:53 -06:00
dsa net: dsa: mv88e6xxx: Fix failed probe due to unsupported C45 reads 2024-01-31 15:57:07 -08:00
ethernet octeontx2-pf: Remove xdp queues on program detach 2024-02-01 15:26:23 +01:00
fddi
fjes fjes: fix memleaks in fjes_hw_setup 2024-01-24 18:03:53 -08:00
hamradio
hippi
hyperv hv_netvsc: Fix race condition between netvsc_probe and netvsc_remove 2024-02-01 08:33:43 -08:00
ieee802154
ipa net: ipa: Convert to platform remove callback returning void 2023-12-05 19:51:09 -08:00
ipvlan ipvlan: Remove usage of the deprecated ida_simple_xx() API 2024-01-07 22:32:48 +00:00
mctp
mdio net: mdio: mux-bcm-iproc: Use alignment helpers and SZ_4K 2024-01-03 16:40:59 -08:00
netdevsim net: netdevsim: don't try to destroy PHC on VFs 2024-01-17 10:56:44 +00:00
pcs net: pcs: rzn1-miic: Convert to platform remove callback returning void 2023-12-05 19:51:09 -08:00
phy net: phy: mediatek-ge-soc: sync driver with MediaTek SDK 2024-01-25 17:34:57 -08:00
plip
ppp ppp: Fix spelling typo in comment in ppp_async_encode() 2024-01-02 16:26:09 -08:00
pse-pd
slip net: fill in MODULE_DESCRIPTION()s for SLIP 2024-01-11 16:16:08 -08:00
team team: Fix use-after-free when an option instance allocation fails 2023-12-08 10:45:49 -08:00
thunderbolt
usb USB / Thunderbolt changes for 6.8-rc1 2024-01-18 11:43:55 -08:00
vmxnet3 net: ethtool: pass a pointer to parameters to get/set_rxfh ethtool ops 2023-12-13 22:07:16 -08:00
vxlan vxlan: mdb: Add MDB bulk deletion support 2023-12-20 11:27:21 +00:00
wan net: fill in MODULE_DESCRIPTION()s for ds26522 module 2024-01-11 16:16:08 -08:00
wireguard
wireless wireless fixes for v6.8-rc2 2024-01-23 08:38:13 -08:00
wwan net: wwan: qcom_bam_dmux: Convert to platform remove callback returning void 2023-12-05 19:54:44 -08:00
xen-netback xen-netback: properly sync TX responses 2024-02-01 08:29:36 -08:00
Kconfig virtio-net: support rx netdim 2023-12-13 12:49:05 +00:00
LICENSE.SRC
Makefile
Space.c
amt.c amt: do not use overwrapped cb area 2024-01-11 16:55:17 -08:00
bareudp.c
dummy.c
eql.c
geneve.c geneve: use DEV_STATS_INC() 2024-01-05 19:07:18 -08:00
gtp.c
ifb.c
loopback.c
macsec.c Revert "net: macsec: use skb_ensure_writable_head_tail to expand the skb" 2024-01-23 17:17:04 -08:00
macvlan.c macvlan: implement .parse_protocol hook function in macvlan_hard_header_ops 2023-12-05 13:41:48 +01:00
macvtap.c
mdio.c
mhi_net.c
mii.c
net_failover.c
netconsole.c
netkit.c
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
sungem_phy.c
tap.c
tun.c tun: add missing rx stats accounting in tun_xdp_act 2024-01-22 10:58:04 +00:00
veth.c netdev 2023-12-18 16:46:08 -08:00
virtio_net.c virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings 2024-01-11 16:54:34 -08:00
vrf.c
vsockmon.c
xen-netfront.c