team: fix possible recursive locking when add slaves
authorHangbin Liu <liuhangbin@gmail.com>
Fri, 19 Apr 2019 06:31:00 +0000 (14:31 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 19 Apr 2019 21:57:35 +0000 (14:57 -0700)
commit925b0c841e066b488cc3a60272472b2c56300704
tree86e8cb96e31670283674bff438ac245ee13be905
parent30c04d796b693e22405c38e9b78e9a364e4c77e6
team: fix possible recursive locking when add slaves

If we add a bond device which is already the master of the team interface,
we will hold the team->lock in team_add_slave() first and then request the
lock in team_set_mac_address() again. The functions are called like:

- team_add_slave()
 - team_port_add()
   - team_port_enter()
     - team_modeop_port_enter()
       - __set_port_dev_addr()
         - dev_set_mac_address()
           - bond_set_mac_address()
             - dev_set_mac_address()
          - team_set_mac_address

Although team_upper_dev_link() would check the upper devices but it is
called too late. Fix it by adding a checking before processing the slave.

v2: Do not split the string in netdev_err()

Fixes: 3d249d4ca7d0 ("net: introduce ethernet teaming device")
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/team/team.c