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]
Message-ID: <20230911170222.hip2pcyzbfu3olau@skbuf>
Date: Mon, 11 Sep 2023 20:02:22 +0300
From: Vladimir Oltean <olteanv@...il.com>
To: Lukasz Majewski <lukma@...x.de>
Cc: Tristram.Ha@...rochip.com, Eric Dumazet <edumazet@...gle.com>,
	Andrew Lunn <andrew@...n.ch>, davem@...emloft.net,
	Woojung Huh <woojung.huh@...rochip.com>,
	Oleksij Rempel <o.rempel@...gutronix.de>,
	Florian Fainelli <f.fainelli@...il.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	UNGLinuxDriver@...rochip.com,
	Oleksij Rempel <linux@...pel-privat.de>, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [[RFC PATCH v4 net-next] 0/2] net: dsa: hsr: Enable HSR HW
 offloading for KSZ9477

On Mon, Sep 11, 2023 at 07:05:01PM +0300, Vladimir Oltean wrote:
> Actually, the reason why I haven't yet said anything is because it made
> me realize that there is a pre-existing bug in net/dsa/slave.c where we
> have this pattern:
> 
> 	if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
> 		dev_uc_add(master, dev->dev_addr);
> 
> but there is no replay of the dev_uc_add() call when the master->dev_addr
> changes. This really results in RX packet loss, as I have tested. I don't
> know what is the best way to solve it.

Hi @Jakub, I remember you fixed some issues with the dev->dev_addr writes,
after dev_addr_lists.c was changed to a rbtree. Is it easy for you to
tell if the change below is safe from an API perspective?

Is the answer "yes, because dev_uc_add() uses an addr_type of NETDEV_HW_ADDR_T_UNICAST,
and dev->dev_addr uses NETDEV_HW_ADDR_T_LAN, so they never share a struct netdev_hw_addr
for the same MAC address, and thus, they never collide"?

The DSA and 8021q drivers currently have this pattern, from around 2008.
But 8021q also tracks NETDEV_CHANGEADDR events on the real_dev, which is
absent in DSA. If the change below is safe, it would be a simpler solution.

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 48db91b33390..e40474e13660 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -374,11 +374,9 @@ static int dsa_slave_open(struct net_device *dev)
 			goto out;
 	}

-	if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) {
-		err = dev_uc_add(master, dev->dev_addr);
-		if (err < 0)
-			goto del_host_addr;
-	}
+	err = dev_uc_add(master, dev->dev_addr);
+	if (err < 0)
+		goto del_host_addr;

 	err = dsa_port_enable_rt(dp, dev->phydev);
 	if (err)
@@ -387,8 +385,7 @@ static int dsa_slave_open(struct net_device *dev)
 	return 0;

 del_unicast:
-	if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
-		dev_uc_del(master, dev->dev_addr);
+	dev_uc_del(master, dev->dev_addr);
 del_host_addr:
 	if (dsa_switch_supports_uc_filtering(ds))
 		dsa_port_standalone_host_fdb_del(dp, dev->dev_addr, 0);
@@ -404,8 +401,7 @@ static int dsa_slave_close(struct net_device *dev)

 	dsa_port_disable_rt(dp);

-	if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
-		dev_uc_del(master, dev->dev_addr);
+	dev_uc_del(master, dev->dev_addr);

 	if (dsa_switch_supports_uc_filtering(ds))
 		dsa_port_standalone_host_fdb_del(dp, dev->dev_addr, 0);
@@ -469,14 +465,11 @@ static int dsa_slave_set_mac_address(struct net_device *dev, void *a)
 			return err;
 	}

-	if (!ether_addr_equal(addr->sa_data, master->dev_addr)) {
-		err = dev_uc_add(master, addr->sa_data);
-		if (err < 0)
-			goto del_unicast;
-	}
+	err = dev_uc_add(master, addr->sa_data);
+	if (err < 0)
+		goto del_unicast;

-	if (!ether_addr_equal(dev->dev_addr, master->dev_addr))
-		dev_uc_del(master, dev->dev_addr);
+	dev_uc_del(master, dev->dev_addr);

 	if (dsa_switch_supports_uc_filtering(ds))
 		dsa_port_standalone_host_fdb_del(dp, dev->dev_addr, 0);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ