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: <174265437292.356712.256272850273766538.stgit@pro.pro>
Date: Sat, 22 Mar 2025 17:39:32 +0300
From: Kirill Tkhai <tkhai@...ru>
To: netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: tkhai@...ru
Subject: [PATCH NET-PREV 13/51] infiniband_ipoib: Use __register_netdevice in .newlink

The objective is to conform .newlink with its callers,
which already assign nd_lock (and matches master nd_lock
if there is one).

Here are two path to __register_netdevice().
One is from .newlink, other is from store method.

Also, use __unregister_netdevice() since we know
there is held lock in that path.

Signed-off-by: Kirill Tkhai <tkhai@...ru>
---
 drivers/infiniband/ulp/ipoib/ipoib_netlink.c |    2 +-
 drivers/infiniband/ulp/ipoib/ipoib_vlan.c    |   12 ++++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
index 2dd3231df36c..b8add59c6c69 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
@@ -140,7 +140,7 @@ static int ipoib_new_child_link(struct net *src_net, struct net_device *dev,
 	if (data) {
 		err = ipoib_changelink(dev, tb, data, extack);
 		if (err) {
-			unregister_netdevice(dev);
+			__unregister_netdevice(dev);
 			return err;
 		}
 	}
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
index 562df2b3ef18..970f344260df 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
@@ -128,7 +128,7 @@ int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv,
 		goto out_early;
 	}
 
-	result = register_netdevice(ndev);
+	result = __register_netdevice(ndev);
 	if (result) {
 		ipoib_warn(priv, "failed to initialize; error %i", result);
 
@@ -155,7 +155,7 @@ int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv,
 	return 0;
 
 sysfs_failed:
-	unregister_netdevice(priv->dev);
+	__unregister_netdevice(priv->dev);
 	return -ENOMEM;
 
 out_early:
@@ -169,6 +169,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
 	struct ipoib_dev_priv *ppriv, *priv;
 	char intf_name[IFNAMSIZ];
 	struct net_device *ndev;
+	struct nd_lock *nd_lock;
 	int result;
 
 	if (!capable(CAP_NET_ADMIN))
@@ -200,8 +201,15 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
 
 	ndev->rtnl_link_ops = ipoib_get_link_ops();
 
+	lock_netdev(pdev, &nd_lock);
+	attach_nd_lock(ndev, nd_lock);
+
 	result = __ipoib_vlan_add(ppriv, priv, pkey, IPOIB_LEGACY_CHILD);
 
+	if (result)
+		detach_nd_lock(ndev);
+	unlock_netdev(nd_lock);
+
 	if (result && ndev->reg_state == NETREG_UNINITIALIZED)
 		free_netdev(ndev);
 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ