1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/net
Thomas Gleixner a53b59ece8 net: enic: Cure the enic api locking trainwreck
enic_dev_wait() has a BUG_ON(in_interrupt()).

Chasing the callers of enic_dev_wait() revealed the gems of enic_reset()
and enic_tx_hang_reset() which are both invoked through work queues in
order to be able to call rtnl_lock(). So far so good.

After locking rtnl both functions acquire enic::enic_api_lock which
serializes against the (ab)use from infiniband. This is where the
trainwreck starts.

enic::enic_api_lock is a spin_lock() which implicitly disables preemption,
but both functions invoke a ton of functions under that lock which can
sleep. The BUG_ON(in_interrupt()) does not trigger in that case because it
can't detect the preempt disabled condition.

This clearly has never been tested with any of the mandatory debug options
for 7+ years, which would have caught that for sure.

Cure it by adding a enic_api_busy member to struct enic, which is modified
and evaluated with enic::enic_api_lock held.

If enic_api_devcmd_proxy_by_index() observes enic::enic_api_busy as true,
it drops enic::enic_api_lock and busy waits for enic::enic_api_busy to
become false.

It would be smarter to wait for a completion of that busy period, but
enic_api_devcmd_proxy_by_index() is called with other spin locks held which
obviously can't sleep.

Remove the BUG_ON(in_interrupt()) check as well because it's incomplete and
with proper debugging enabled the problem would have been caught from the
debug checks in schedule_timeout().

Fixes: 0b038566c0 ("drivers/net: enic: Add an interface for USNIC to interact with firmware")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-09-29 14:02:53 -07:00
..
appletalk net/appletalk: Supply missing net/Space.h include file 2020-09-18 14:53:40 -07:00
arcnet treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
bonding treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
caif caif: fix cfv_netdev_tx()'s return type 2020-06-28 20:52:53 -07:00
can can: flexcan: add lx2160ar1 support 2020-09-22 16:55:34 +02:00
dsa net: dsa: tag_ocelot: use a short prefix on both ingress and egress 2020-09-26 14:17:58 -07:00
ethernet net: enic: Cure the enic api locking trainwreck 2020-09-29 14:02:53 -07:00
fddi fddi/skfp: Avoid the use of one-element array 2020-09-29 13:27:43 -07:00
fjes treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
hamradio treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
hippi hippi: switch from 'pci_' to 'dma_' API 2020-09-08 20:15:57 -07:00
hyperv hv_netvsc: Add validation for untrusted Hyper-V values 2020-09-17 16:21:26 -07:00
ieee802154 ieee802154/adf7242: check status of adf7242_read_reg 2020-08-03 20:19:21 +02:00
ipa net: ipa: fix two comments 2020-09-28 18:34:56 -07:00
ipvlan ipvlan: advertise link netns via netlink 2020-08-24 15:53:33 -07:00
mdio net: mdio-ipq4019: add Clause 45 support 2020-09-23 17:41:15 -07:00
netdevsim netdevsim: support the static IANA VXLAN port flag 2020-09-28 12:50:12 -07:00
pcs net: pcs-lynx: add support for 10GBASER 2020-09-24 19:49:36 -07:00
phy net: Use kobj_to_dev() API 2020-09-28 15:14:42 -07:00
plip treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
ppp mm, treewide: rename kzfree() to kfree_sensitive() 2020-08-07 11:33:22 -07:00
slip treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
team treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
usb Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-09-22 16:45:34 -07:00
vmxnet3 treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
wan Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-09-22 16:45:34 -07:00
wimax net: wimax: i2400m: fix 'msg_skb' kernel-doc warning in i2400m_msg_to_dev() 2020-09-08 20:04:27 -07:00
wireguard Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-09-22 16:45:34 -07:00
wireless wireless-drivers-next patches for v5.10 2020-09-25 13:16:29 -07:00
xen-netback treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
bareudp.c tunnels: PMTU discovery support for directly bridged IP packets 2020-08-04 13:01:45 -07:00
dummy.c
eql.c
geneve.c geneve: add transport ports in route lookup for geneve 2020-09-16 17:41:38 -07:00
gtp.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-09-04 21:28:59 -07:00
ifb.c
Kconfig net: mdio: Move MDIO drivers into a new subdirectory 2020-08-27 06:55:50 -07:00
LICENSE.SRC
loopback.c
macsec.c netlink: consistently use NLA_POLICY_MIN_LEN() 2020-08-18 12:28:45 -07:00
macvlan.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
macvtap.c
Makefile net: mdio: Move MDIO drivers into a new subdirectory 2020-08-27 06:55:50 -07:00
mdio.c
mii.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
net_failover.c net_failover: fixed rollback in net_failover_open() 2020-06-02 15:35:53 -07:00
netconsole.c
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
Space.c
sungem_phy.c
tap.c
thunderbolt.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-08-05 20:13:21 -07:00
tun.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-09-04 21:28:59 -07:00
veth.c net: remove napi_hash_del() from driver-facing API 2020-09-10 13:08:46 -07:00
virtio_net.c net: remove napi_hash_del() from driver-facing API 2020-09-10 13:08:46 -07:00
vrf.c vrf: Handle CONFIG_SYSCTL not set 2020-07-23 17:51:04 -07:00
vsockmon.c
vxlan.c Revert "vxlan: move encapsulation warning" 2020-09-26 12:34:47 -07:00
xen-netfront.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00