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: <20250325213056.332902-6-sdf@fomichev.me>
Date: Tue, 25 Mar 2025 14:30:52 -0700
From: Stanislav Fomichev <sdf@...ichev.me>
To: netdev@...r.kernel.org
Cc: davem@...emloft.net,
	edumazet@...gle.com,
	kuba@...nel.org,
	pabeni@...hat.com,
	Taehee Yoo <ap420073@...il.com>
Subject: [PATCH net-next 5/9] net: release instance lock during NETDEV_UNREGISTER for bond/team

Running NETDEV_UNREGISTER under instance lock might be problematic for
teaming/bonding [0] because they take their own lock and the ordering
is reverse in the notifiers path. Release the instance lock in the notifiers
and let the existing code paths take the lock in the correct
order.

0: https://lore.kernel.org/netdev/CAMArcTW+5Lk0EWCaHOsUhf+p31S8yAZyQvi3C8zeRF3TxnC9Fg@mail.gmail.com/

Reported-by: Taehee Yoo <ap420073@...il.com>
Signed-off-by: Stanislav Fomichev <sdf@...ichev.me>
---
 drivers/net/bonding/bond_main.c | 2 ++
 drivers/net/team/team_core.c    | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index e7f576d52311..7a1b160c5f23 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4022,10 +4022,12 @@ static int bond_slave_netdev_event(unsigned long event,
 
 	switch (event) {
 	case NETDEV_UNREGISTER:
+		netdev_unlock_ops(slave_dev);
 		if (bond_dev->type != ARPHRD_ETHER)
 			bond_release_and_destroy(bond_dev, slave_dev);
 		else
 			__bond_release_one(bond_dev, slave_dev, false, true);
+		netdev_lock_ops(slave_dev);
 		break;
 	case NETDEV_UP:
 	case NETDEV_CHANGE:
diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c
index d8fc0c79745d..4a1815f50015 100644
--- a/drivers/net/team/team_core.c
+++ b/drivers/net/team/team_core.c
@@ -2997,7 +2997,9 @@ static int team_device_event(struct notifier_block *unused,
 					       !!netif_oper_up(port->dev));
 		break;
 	case NETDEV_UNREGISTER:
+		netdev_unlock_ops(dev);
 		team_del_slave(port->team->dev, dev);
+		netdev_lock_ops(dev);
 		break;
 	case NETDEV_FEAT_CHANGE:
 		if (!port->team->notifier_ctx) {
-- 
2.48.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ