team: call RCU read lock when walking the port_list
Subsystems (3)
PATCH 1/1 team: call RCU read lock when walking the port_list
Before reading the team port list, we need to acquire the RCU read lock. Also change list_for_each_entry() to list_for_each_entry_rcu().
--- drivers/net/team/team.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/team/team.c +4 -1
@@ -2066,7 +2066,8 @@ static int team_ethtool_get_link_ksettings(struct net_device *dev, cmd->base.duplex =DUPLEX_UNKNOWN ; cmd->base.port =PORT_OTHER ; -list_for_each_entry (port, &team->port_list, list) { +rcu_read_lock (); +list_for_each_entry_rcu (port, &team->port_list, list) {if (team_port_txable (port)) {if (port->state.speed !=SPEED_UNKNOWN ) speed += port->state.speed;
@@ -2075,6 +2076,8 @@ static int team_ethtool_get_link_ksettings(struct net_device *dev, cmd->base.duplex = port->state.duplex; } } +rcu_read_unlock (); + cmd->base.speed = speed ? :SPEED_UNKNOWN ;return 0 ;
Signature · 1 line
2.19.2
Quoted 7 lines · Tue, Oct 08, 2019 at 03:56:14PM CEST, [email protected] wrote:
Before reading the team port list, we need to acquire the RCU read lock. Also change
list_for_each_entry()tolist_for_each_entry_rcu().Fixes 9ed68ca0d90b ("team: add ethtool get_link_ksettings")Reported-by Paolo Abeni <[email protected]>Signed-off-by Hangbin Liu <[email protected]>Acked-by Paolo Abeni <[email protected]>
It is not strictly needed a since rtnl is taken, but similar list iteration in team is designed to work without rtnl dependency.
Thanks!
Quoted 30 lines
---
drivers/net/team/team.c| 5 ++++-1 file changed, 4 insertions(+), 1 deletion(-)drivers/net/team/team.c +4
-1@@ -2066,7 +2066,8 @@ static int team_ethtool_get_link_ksettings(struct net_device *dev, cmd->base.duplex =DUPLEX_UNKNOWN ; cmd->base.port =PORT_OTHER ; -list_for_each_entry (port, &team->port_list, list) { +rcu_read_lock (); +list_for_each_entry_rcu (port, &team->port_list, list) {if (team_port_txable (port)) {if (port->state.speed !=SPEED_UNKNOWN ) speed += port->state.speed;@@ -2075,6 +2076,8 @@ static int team_ethtool_get_link_ksettings(struct net_device *dev, cmd->base.duplex = port->state.duplex; } } +rcu_read_unlock (); + cmd->base.speed = speed ? :SPEED_UNKNOWN ;return 0 ;Signature · 1 line
2.19.2
Quoted 9 lines · Jiri Pirko
Quoted 7 lines · Tue, Oct 08, 2019 at 03:56:14PM CEST, [email protected] wrote:
Before reading the team port list, we need to acquire the RCU read lock. Also change
list_for_each_entry()tolist_for_each_entry_rcu().Fixes 9ed68ca0d90b ("team: add ethtool get_link_ksettings")Reported-by Paolo Abeni <[email protected]>Signed-off-by Hangbin Liu <[email protected]>Acked-by Paolo Abeni <[email protected]>
Quoted 4 lines
It is not strictly needed a since rtnl is taken, but similar list iteration in team is designed to work without rtnl dependency.
Acked-by Jiri Pirko <[email protected]>
IIUC this is a cosmetic change and non-RCU iteration seems to be used in a few places in team.c. Can we get this reposted for net-next, and without the Fixes tag? Please keep Jiri's Ack.
PATCH v2 1/1 team: call RCU read lock when walking the port_list
In reply to Hangbin LiuBefore reading the team port list, we need to acquire the RCU read lock. Also change list_for_each_entry() to list_for_each_entry_rcu().
v2:
repost the patch to net-next and remove fixes flag as this is a cosmetic change.
--- drivers/net/team/team.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/team/team.c +4 -1
@@ -2066,7 +2066,8 @@ static int team_ethtool_get_link_ksettings(struct net_device *dev, cmd->base.duplex =DUPLEX_UNKNOWN ; cmd->base.port =PORT_OTHER ; -list_for_each_entry (port, &team->port_list, list) { +rcu_read_lock (); +list_for_each_entry_rcu (port, &team->port_list, list) {if (team_port_txable (port)) {if (port->state.speed !=SPEED_UNKNOWN ) speed += port->state.speed;
@@ -2075,6 +2076,8 @@ static int team_ethtool_get_link_ksettings(struct net_device *dev, cmd->base.duplex = port->state.duplex; } } +rcu_read_unlock (); + cmd->base.speed = speed ? :SPEED_UNKNOWN ;return 0 ;
Signature · 1 line
2.19.2
Jakub Kicinski
AppliedQuoted 11 lines · Hangbin Liu
Before reading the team port list, we need to acquire the RCU read lock. Also change
list_for_each_entry()tolist_for_each_entry_rcu().v2:
repost the patch to net-next and remove fixes flag as this is a cosmetic change.Suggested-by Paolo Abeni <[email protected]>Signed-off-by Hangbin Liu <[email protected]>Acked-by Paolo Abeni <[email protected]>Acked-by Jiri Pirko <[email protected]>
Thank you! Applied