From: Jakub Kicinski Date: Wed, 3 Jun 2026 01:28:35 +0000 (-0700) Subject: net: team: don't recurse on the port's netdev ops lock X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6882c1583262d5bd86a798198820842e6d32b62;p=thirdparty%2Flinux.git net: team: don't recurse on the port's netdev ops lock __team_port_change_send() calls __ethtool_get_link_ksettings() on the port, which will soon take the port's ops lock. The notifier caller already holds it while the slave-add/del callers do not, so the function would either deadlock or run unprotected depending on the path. Make __team_port_change_send() expect the port's ops lock held and switch to netif_get_link_ksettings(). team_device_event()'s NETDEV_UP / NETDEV_CHANGE already arrive with the port's ops lock held. team_port_add() now take it explicitly. Note that NETDEV_DOWN and team_port_del() will pass false as @linkup so they will not execute netif_get_link_ksettings(). This is fortunate as NETDEV_DOWN has somewhat mixed locking right now. Link: https://patch.msgid.link/20260603012840.2254293-7-kuba@kernel.org Signed-off-by: Jakub Kicinski --- diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c index f51388d50307f..feaa75fbf8fc2 100644 --- a/drivers/net/team/team_core.c +++ b/drivers/net/team/team_core.c @@ -1375,7 +1375,9 @@ static int team_port_add(struct team *team, struct net_device *port_dev, list_add_tail_rcu(&port->list, &team->port_list); team_port_enable(team, port); netdev_compute_master_upper_features(dev, true); + netdev_lock_ops(port_dev); __team_port_change_port_added(port, !!netif_oper_up(port_dev)); + netdev_unlock_ops(port_dev); __team_options_change_check(team); netdev_info(dev, "Port device %s added\n", portname); @@ -3090,7 +3092,7 @@ static void __team_port_change_send(struct team_port *port, bool linkup) if (linkup) { struct ethtool_link_ksettings ecmd; - err = __ethtool_get_link_ksettings(port->dev, &ecmd); + err = netif_get_link_ksettings(port->dev, &ecmd); if (!err) { port->state.speed = ecmd.base.speed; port->state.duplex = ecmd.base.duplex;