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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <202308041653414100323@zte.com.cn>
Date: Fri, 4 Aug 2023 16:53:41 +0800 (CST)
From: <yang.yang29@....com.cn>
To: <jmaloy@...hat.com>, <davem@...emloft.net>
Cc: <ying.xue@...driver.com>, <edumazet@...gle.com>, <kuba@...nel.org>,
        <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH] net: tipc: add net device refcount tracker for bearer

From: xu xin <xu.xin16@....com.cn>

Add net device refcount tracker to the struct tipc_bearer.

Signed-off-by: xu xin <xu.xin16@....com.cn>
Reviewed-by: Yang Yang <yang.yang.29@....com.cn>
Cc: Kuang Mingfu <kuang.mingfu@....com.cn>
---
 net/tipc/bearer.c | 10 +++++-----
 net/tipc/bearer.h |  1 +
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 2cde375477e3..01ffd1f2337a 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -426,15 +426,15 @@ int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b,
 	struct net_device *dev;

 	/* Find device with specified name */
-	dev = dev_get_by_name(net, dev_name);
+	dev = netdev_get_by_name(net, dev_name, &b->devtracker, GFP_KERNEL);
 	if (!dev)
 		return -ENODEV;
 	if (tipc_mtu_bad(dev)) {
-		dev_put(dev);
+		netdev_put(dev, &b->devtracker);
 		return -EINVAL;
 	}
 	if (dev == net->loopback_dev) {
-		dev_put(dev);
+		netdev_put(dev, &b->devtracker);
 		pr_info("Enabling <%s> not permitted\n", b->name);
 		return -EINVAL;
 	}
@@ -445,7 +445,7 @@ int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b,
 		tipc_net_init(net, node_id, 0);
 	}
 	if (!tipc_own_id(net)) {
-		dev_put(dev);
+		netdev_put(dev, &b->devtracker);
 		pr_warn("Failed to obtain node identity\n");
 		return -EINVAL;
 	}
@@ -479,7 +479,7 @@ void tipc_disable_l2_media(struct tipc_bearer *b)
 	dev_remove_pack(&b->pt);
 	RCU_INIT_POINTER(dev->tipc_ptr, NULL);
 	synchronize_net();
-	dev_put(dev);
+	netdev_put(dev, &b->devtracker);
 }

 /**
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h
index 41eac1ee0c09..1adeaf94aa62 100644
--- a/net/tipc/bearer.h
+++ b/net/tipc/bearer.h
@@ -174,6 +174,7 @@ struct tipc_bearer {
 	u16 encap_hlen;
 	unsigned long up;
 	refcount_t refcnt;
+	netdevice_tracker	devtracker;
 };

 struct tipc_bearer_names {
-- 
2.15.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ