1 From foo@baz Tue 30 Apr 2019 11:47:03 AM CEST
2 From: Hangbin Liu <liuhangbin@gmail.com>
3 Date: Fri, 19 Apr 2019 14:31:00 +0800
4 Subject: team: fix possible recursive locking when add slaves
6 From: Hangbin Liu <liuhangbin@gmail.com>
8 [ Upstream commit 925b0c841e066b488cc3a60272472b2c56300704 ]
10 If we add a bond device which is already the master of the team interface,
11 we will hold the team->lock in team_add_slave() first and then request the
12 lock in team_set_mac_address() again. The functions are called like:
17 - team_modeop_port_enter()
18 - __set_port_dev_addr()
19 - dev_set_mac_address()
20 - bond_set_mac_address()
21 - dev_set_mac_address()
22 - team_set_mac_address
24 Although team_upper_dev_link() would check the upper devices but it is
25 called too late. Fix it by adding a checking before processing the slave.
27 v2: Do not split the string in netdev_err()
29 Fixes: 3d249d4ca7d0 ("net: introduce ethernet teaming device")
30 Acked-by: Jiri Pirko <jiri@mellanox.com>
31 Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
32 Signed-off-by: David S. Miller <davem@davemloft.net>
33 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
35 drivers/net/team/team.c | 6 ++++++
36 1 file changed, 6 insertions(+)
38 --- a/drivers/net/team/team.c
39 +++ b/drivers/net/team/team.c
40 @@ -1136,6 +1136,12 @@ static int team_port_add(struct team *te
44 + if (netdev_has_upper_dev(dev, port_dev)) {
45 + netdev_err(dev, "Device %s is already an upper device of the team interface\n",
50 if (port_dev->features & NETIF_F_VLAN_CHALLENGED &&
52 netdev_err(dev, "Device %s is VLAN challenged and team device has VLAN set up\n",