]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/team-fix-possible-recursive-locking-when-add-slaves.patch
4.4-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.4 / team-fix-possible-recursive-locking-when-add-slaves.patch
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
5
6 From: Hangbin Liu <liuhangbin@gmail.com>
7
8 [ Upstream commit 925b0c841e066b488cc3a60272472b2c56300704 ]
9
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:
13
14 - team_add_slave()
15 - team_port_add()
16 - team_port_enter()
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
23
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.
26
27 v2: Do not split the string in netdev_err()
28
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>
34 ---
35 drivers/net/team/team.c | 6 ++++++
36 1 file changed, 6 insertions(+)
37
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
41 return -EINVAL;
42 }
43
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",
46 + portname);
47 + return -EBUSY;
48 + }
49 +
50 if (port_dev->features & NETIF_F_VLAN_CHALLENGED &&
51 vlan_uses_dev(dev)) {
52 netdev_err(dev, "Device %s is VLAN challenged and team device has VLAN set up\n",