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: <20241009232728.107604-3-edumazet@google.com>
Date: Wed,  9 Oct 2024 23:27:27 +0000
From: Eric Dumazet <edumazet@...gle.com>
To: "David S . Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>, 
	Paolo Abeni <pabeni@...hat.com>
Cc: Kuniyuki Iwashima <kuniyu@...zon.com>, netdev@...r.kernel.org, eric.dumazet@...il.com, 
	Eric Dumazet <edumazet@...gle.com>
Subject: [PATCH net-next 2/2] netdev-genl: do not use rtnl in netdev_nl_napi_get_dumpit()

Both netdev_nl_napi_dump_one() and netdev_nl_napi_get_dumpit()
can use RCU instead of RTNL to dump napi related information,
after prior patch prepared netdev_nl_napi_fill_one().

Signed-off-by: Eric Dumazet <edumazet@...gle.com>
---
 net/core/netdev-genl.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
index 0dcfe3527c122884c5713e56d5e27d4e638d936f..22f766619630f3dc43e3b0ed1708fa9ef38a5451 100644
--- a/net/core/netdev-genl.c
+++ b/net/core/netdev-genl.c
@@ -245,10 +245,10 @@ netdev_nl_napi_dump_one(struct net_device *netdev, struct sk_buff *rsp,
 	struct napi_struct *napi;
 	int err = 0;
 
-	if (!(netdev->flags & IFF_UP))
+	if (!(READ_ONCE(netdev->flags) & IFF_UP))
 		return err;
 
-	list_for_each_entry(napi, &netdev->napi_list, dev_list) {
+	list_for_each_entry_rcu(napi, &netdev->napi_list, dev_list) {
 		if (ctx->napi_id && napi->napi_id >= ctx->napi_id)
 			continue;
 
@@ -272,9 +272,9 @@ int netdev_nl_napi_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
 	if (info->attrs[NETDEV_A_NAPI_IFINDEX])
 		ifindex = nla_get_u32(info->attrs[NETDEV_A_NAPI_IFINDEX]);
 
-	rtnl_lock();
+	rcu_read_lock();
 	if (ifindex) {
-		netdev = __dev_get_by_index(net, ifindex);
+		netdev = dev_get_by_index_rcu(net, ifindex);
 		if (netdev)
 			err = netdev_nl_napi_dump_one(netdev, skb, info, ctx);
 		else
@@ -287,7 +287,7 @@ int netdev_nl_napi_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
 			ctx->napi_id = 0;
 		}
 	}
-	rtnl_unlock();
+	rcu_read_unlock();
 
 	return err;
 }
-- 
2.47.0.rc0.187.ge670bccf7e-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ