netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] team: call RCU read lock when walking the port_list
@ 2019-10-08 13:56 Hangbin Liu
  2019-10-08 14:13 ` Jiri Pirko
  2019-10-09 12:18 ` [PATCHv2 net-next] " Hangbin Liu
  0 siblings, 2 replies; 5+ messages in thread
From: Hangbin Liu @ 2019-10-08 13:56 UTC (permalink / raw)
  To: netdev; +Cc: Jiri Pirko, David S . Miller, Paolo Abeni, Hangbin Liu

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().

Fixes: 9ed68ca0d90b ("team: add ethtool get_link_ksettings")
Reported-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/team/team.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index e8089def5a46..cb1d5fe60c31 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -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;
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net] team: call RCU read lock when walking the port_list
  2019-10-08 13:56 [PATCH net] team: call RCU read lock when walking the port_list Hangbin Liu
@ 2019-10-08 14:13 ` Jiri Pirko
  2019-10-09  2:28   ` Jakub Kicinski
  2019-10-09 12:18 ` [PATCHv2 net-next] " Hangbin Liu
  1 sibling, 1 reply; 5+ messages in thread
From: Jiri Pirko @ 2019-10-08 14:13 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: netdev, Jiri Pirko, David S . Miller, Paolo Abeni

Tue, Oct 08, 2019 at 03:56:14PM CEST, liuhangbin@gmail.com wrote:
>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().
>
>Fixes: 9ed68ca0d90b ("team: add ethtool get_link_ksettings")
>Reported-by: Paolo Abeni <pabeni@redhat.com>
>Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
>Acked-by: Paolo Abeni <pabeni@redhat.com>

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 <jiri@mellanox.com>

Thanks!


>---
> drivers/net/team/team.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
>index e8089def5a46..cb1d5fe60c31 100644
>--- a/drivers/net/team/team.c
>+++ b/drivers/net/team/team.c
>@@ -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;
>-- 
>2.19.2
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] team: call RCU read lock when walking the port_list
  2019-10-08 14:13 ` Jiri Pirko
@ 2019-10-09  2:28   ` Jakub Kicinski
  0 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2019-10-09  2:28 UTC (permalink / raw)
  To: Jiri Pirko, Hangbin Liu; +Cc: netdev, Jiri Pirko, David S . Miller, Paolo Abeni

On Tue, 8 Oct 2019 16:13:59 +0200, Jiri Pirko wrote:
> Tue, Oct 08, 2019 at 03:56:14PM CEST, liuhangbin@gmail.com wrote:
> >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().
> >
> >Fixes: 9ed68ca0d90b ("team: add ethtool get_link_ksettings")
> >Reported-by: Paolo Abeni <pabeni@redhat.com>
> >Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> >Acked-by: Paolo Abeni <pabeni@redhat.com>  
> 
> 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 <jiri@mellanox.com>

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCHv2 net-next] team: call RCU read lock when walking the port_list
  2019-10-08 13:56 [PATCH net] team: call RCU read lock when walking the port_list Hangbin Liu
  2019-10-08 14:13 ` Jiri Pirko
@ 2019-10-09 12:18 ` Hangbin Liu
  2019-10-10  4:15   ` Jakub Kicinski
  1 sibling, 1 reply; 5+ messages in thread
From: Hangbin Liu @ 2019-10-09 12:18 UTC (permalink / raw)
  To: netdev; +Cc: Jiri Pirko, Paolo Abeni, Jakub Kicinski, davem, Hangbin Liu

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().

v2:
repost the patch to net-next and remove fixes flag as this is a cosmetic
change.

Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
---
 drivers/net/team/team.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index e8089def5a46..cb1d5fe60c31 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -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;
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCHv2 net-next] team: call RCU read lock when walking the port_list
  2019-10-09 12:18 ` [PATCHv2 net-next] " Hangbin Liu
@ 2019-10-10  4:15   ` Jakub Kicinski
  0 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2019-10-10  4:15 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: netdev, Jiri Pirko, Paolo Abeni, davem

On Wed,  9 Oct 2019 20:18:28 +0800, Hangbin Liu wrote:
> 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().
> 
> v2:
> repost the patch to net-next and remove fixes flag as this is a cosmetic
> change.
> 
> Suggested-by: Paolo Abeni <pabeni@redhat.com>
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> Acked-by: Paolo Abeni <pabeni@redhat.com>
> Acked-by: Jiri Pirko <jiri@mellanox.com>

Thank you! Applied

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-10-10  4:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-08 13:56 [PATCH net] team: call RCU read lock when walking the port_list Hangbin Liu
2019-10-08 14:13 ` Jiri Pirko
2019-10-09  2:28   ` Jakub Kicinski
2019-10-09 12:18 ` [PATCHv2 net-next] " Hangbin Liu
2019-10-10  4:15   ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).