Skip to contentSkip to conversation

netdev-genl: Hold rcu_read_lock in napi_get

PATCH Applied Joe Damato 2 participants 2 messages Nov 14, 2024 – Nov 15, 2024

Subsystems (3)
lore
Share & tools
lore

Joe Damato

author
#0 lore raw

PATCH v3 1/1 netdev-genl: Hold rcu_read_lock in napi_get

Hold rcu_read_lock in netdev_nl_napi_get_doit, which calls napi_by_id and is required to be called under rcu_read_lock.

Fixes 27f91aaf49b3 ("netdev-genl: Add netlink framework functions for napi")

---
v3:
- Separate the patches that were a series in v2 (and earlier) as they target different trees.

v2:
- Simplified by removing the helper and calling rcu_read_lock / unlock directly instead.

 net/core/netdev-genl.c | 2 ++
 1 file changed, 2 insertions(+)
net/core/netdev-genl.c +2 -0
index 1cb954f2d39e..d2baa1af9df0 100644
@@ -215,6 +215,7 @@ int netdev_nl_napi_get_doit(struct sk_buff *skb, struct genl_info *info)
 		return -ENOMEM;
 
 	rtnl_lock();
+	rcu_read_lock();
 
 	napi = napi_by_id(napi_id);
 	if (napi) {
@@ -224,6 +225,7 @@ int netdev_nl_napi_get_doit(struct sk_buff *skb, struct genl_info *info)
 		err = -ENOENT;
 	}
 
+	rcu_read_unlock();
 	rtnl_unlock();
 
 	if (err)

base-commit: 5b366eae71937ae7412365340b431064625f9617

Signature · 1 line
2.25.1
#1 lore raw
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Thu, 14 Nov 2024 17:51:56 +0000 you wrote:

Hold rcu_read_lock in netdev_nl_napi_get_doit, which calls napi_by_id and is required to be called under rcu_read_lock.

Fixes 27f91aaf49b3 ("netdev-genl: Add netlink framework functions for napi")

[...]

Here is the summary with links:
- [net,v3] netdev-genl: Hold rcu_read_lock in napi_get

    https://git.kernel.org/netdev/net/c/c53bf100f686

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html