lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 8 Oct 2019 16:13:59 +0200
From:   Jiri Pirko <jiri@...nulli.us>
To:     Hangbin Liu <liuhangbin@...il.com>
Cc:     netdev@...r.kernel.org, Jiri Pirko <jiri@...lanox.com>,
        "David S . Miller" <davem@...emloft.net>,
        Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH net] team: call RCU read lock when walking the port_list

Tue, Oct 08, 2019 at 03:56:14PM CEST, liuhangbin@...il.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@...hat.com>
>Signed-off-by: Hangbin Liu <liuhangbin@...il.com>
>Acked-by: Paolo Abeni <pabeni@...hat.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@...lanox.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
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ