Commit 72df935d authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

team: move add to port list before port enablement

team_port_enable() adds port to port_hashlist. Reader sees port
in team_get_port_by_index_rcu() and returns it, but
team_get_first_port_txable_rcu() tries to go through port_list, where the
port is not inserted yet -> NULL pointer dereference.
Fix this by reordering port_list and port_hashlist insertion.
Panic is easily triggeable when txing packets and adding/removing port
in a loop.

Introduced by commit 3d249d4c "net: introduce ethernet teaming device"
Signed-off-by: default avatarJiri Pirko <jiri@resnulli.us>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 76c455de
...@@ -1092,8 +1092,8 @@ static int team_port_add(struct team *team, struct net_device *port_dev) ...@@ -1092,8 +1092,8 @@ static int team_port_add(struct team *team, struct net_device *port_dev)
} }
port->index = -1; port->index = -1;
team_port_enable(team, port);
list_add_tail_rcu(&port->list, &team->port_list); list_add_tail_rcu(&port->list, &team->port_list);
team_port_enable(team, port);
__team_compute_features(team); __team_compute_features(team);
__team_port_change_port_added(port, !!netif_carrier_ok(port_dev)); __team_port_change_port_added(port, !!netif_carrier_ok(port_dev));
__team_options_change_check(team); __team_options_change_check(team);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment