linux-stable/drivers/net
Taehee Yoo 1c30fbc76b team: fix hang in team_mode_get()
When team mode is changed or set, the team_mode_get() is called to check
whether the mode module is inserted or not. If the mode module is not
inserted, it calls the request_module().
In the request_module(), it creates a child process, which is
the "modprobe" process and waits for the done of the child process.
At this point, the following locks were used.
down_read(&cb_lock()); by genl_rcv()
    genl_lock(); by genl_rcv_msc()
        rtnl_lock(); by team_nl_cmd_options_set()
            mutex_lock(&team->lock); by team_nl_team_get()

Concurrently, the team module could be removed by rmmod or "modprobe -r"
The __exit function of team module is team_module_exit(), which calls
team_nl_fini() and it tries to acquire following locks.
down_write(&cb_lock);
    genl_lock();
Because of the genl_lock() and cb_lock, this process can't be finished
earlier than request_module() routine.

The problem secenario.
CPU0                                     CPU1
team_mode_get
    request_module()
                                         modprobe -r team_mode_roundrobin
                                                     team <--(B)
        modprobe team <--(A)
            team_mode_roundrobin

By request_module(), the "modprobe team_mode_roundrobin" command
will be executed. At this point, the modprobe process will decide
that the team module should be inserted before team_mode_roundrobin.
Because the team module is being removed.

By the module infrastructure, the same module insert/remove operations
can't be executed concurrently.
So, (A) waits for (B) but (B) also waits for (A) because of locks.
So that the hang occurs at this point.

Test commands:
    while :
    do
        teamd -d &
	killall teamd &
	modprobe -rv team_mode_roundrobin &
    done

The approach of this patch is to hold the reference count of the team
module if the team module is compiled as a module. If the reference count
of the team module is not zero while request_module() is being called,
the team module will not be removed at that moment.
So that the above scenario could not occur.

Fixes: 3d249d4ca7 ("net: introduce ethernet teaming device")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-20 13:03:44 -07:00
..
appletalk
arcnet
bonding
caif virtio: fixes, vdpa 2020-04-08 10:51:53 -07:00
can slcan: Don't transmit uninitialized stack data in padding 2020-04-01 11:22:35 -07:00
dsa net: dsa: mt7530: fix tagged frames pass-through in VLAN-unaware mode 2020-04-16 13:32:05 -07:00
ethernet cxgb4: fix large delays in PTP synchronization 2020-04-20 12:54:30 -07:00
fddi
fjes
hamradio
hippi
hyperv hv_netvsc: Remove unnecessary round_up for recv_completion_cnt 2020-03-30 19:43:42 -07:00
ieee802154
ipa soc: qcom: ipa: Add a missing '\n' in a log message 2020-04-12 11:44:18 -07:00
ipvlan
netdevsim netdevsim: dev: Fix memory leak in nsim_dev_take_snapshot_write 2020-03-30 20:14:22 -07:00
phy net: marvell10g: soft-reset the PHY when coming out of low power 2020-04-14 16:48:09 -07:00
plip
ppp
slip
team team: fix hang in team_mode_get() 2020-04-20 13:03:44 -07:00
usb pegasus: Remove pegasus' own workqueue 2020-04-02 17:58:25 -07:00
vmxnet3
wan SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
wimax wimax/i2400m: Fix potential urb refcnt leak 2020-04-18 15:00:22 -07:00
wireguard net: Fix CONFIG_NET_CLS_ACT=n and CONFIG_NFT_FWD_NETDEV={y, m} build 2020-03-25 12:24:33 -07:00
wireless A couple of fixes: 2020-04-15 11:27:23 -07:00
xen-netback
bareudp.c
dummy.c
eql.c
geneve.c
gtp.c
ifb.c net: Fix CONFIG_NET_CLS_ACT=n and CONFIG_NFT_FWD_NETDEV={y, m} build 2020-03-25 12:24:33 -07:00
Kconfig Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-03-25 18:58:11 -07:00
LICENSE.SRC
loopback.c
macsec.c net: macsec: fix using wrong structure in macsec_changelink() 2020-04-09 10:16:00 -07:00
macvlan.c
macvtap.c
Makefile
mdio.c
mii.c
net_failover.c
netconsole.c
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
Space.c
sungem_phy.c
tap.c
thunderbolt.c
tun.c net: tun: record RX queue in skb before do_xdp_generic() 2020-04-12 20:58:24 -07:00
veth.c veth: rely on peer veth_rq for ndo_xdp_xmit accounting 2020-03-26 19:35:13 -07:00
virtio_net.c
vrf.c Remove DST_HOST 2020-03-23 21:57:44 -07:00
vsockmon.c
vxlan.c
xen-netfront.c