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: <174265455601.356712.15167286071046652613.stgit@pro.pro>
Date: Sat, 22 Mar 2025 17:42:36 +0300
From: Kirill Tkhai <tkhai@...ru>
To: netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: tkhai@...ru
Subject: [PATCH NET-PREV 38/51] failover: Link master and slave under nd_lock

We don't want to do this in failover_event(), since we
want to call netdevice notifiers with nd_lock already
locked in the future.

Also see comments in patch introducing schedule_delayed_event()

Signed-off-by: Kirill Tkhai <tkhai@...ru>
---
 net/core/failover.c |   24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/net/core/failover.c b/net/core/failover.c
index 2a140b3ea669..83be0d0ab99a 100644
--- a/net/core/failover.c
+++ b/net/core/failover.c
@@ -46,6 +46,7 @@ static struct net_device *failover_get_bymac(u8 *mac, struct failover_ops **ops)
 static int failover_slave_register(struct net_device *slave_dev)
 {
 	struct netdev_lag_upper_info lag_upper_info;
+	struct nd_lock *nd_lock, *nd_lock2;
 	struct net_device *failover_dev;
 	struct failover_ops *fops;
 	int err;
@@ -72,8 +73,14 @@ static int failover_slave_register(struct net_device *slave_dev)
 	}
 
 	lag_upper_info.tx_type = NETDEV_LAG_TX_TYPE_ACTIVEBACKUP;
+
+	double_lock_netdev(slave_dev, &nd_lock, failover_dev, &nd_lock2);
+	nd_lock_transfer_devices(&nd_lock, &nd_lock2);
+
 	err = netdev_master_upper_dev_link(slave_dev, failover_dev, NULL,
 					   &lag_upper_info, NULL);
+	double_unlock_netdev(nd_lock, nd_lock2);
+
 	if (err) {
 		netdev_err(slave_dev, "can not set failover device %s (err = %d)\n",
 			   failover_dev->name, err);
@@ -182,6 +189,18 @@ static int failover_slave_name_change(struct net_device *slave_dev)
 	return NOTIFY_DONE;
 }
 
+static void call_failover_slave_register(struct net_device *dev)
+{
+	rtnl_lock();
+	if (dev->reg_state == NETREG_REGISTERED) {
+		failover_slave_register(dev);
+		failover_slave_link_change(dev);
+		failover_slave_name_change(dev);
+
+	}
+	rtnl_unlock();
+}
+
 static int
 failover_event(struct notifier_block *this, unsigned long event, void *ptr)
 {
@@ -193,7 +212,10 @@ failover_event(struct notifier_block *this, unsigned long event, void *ptr)
 
 	switch (event) {
 	case NETDEV_REGISTER:
-		return failover_slave_register(event_dev);
+		if (netdev_is_rx_handler_busy(event_dev))
+			return NOTIFY_DONE;
+		return schedule_delayed_event(event_dev,
+					      call_failover_slave_register);
 	case NETDEV_UNREGISTER:
 		return failover_slave_unregister(event_dev);
 	case NETDEV_UP:


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ