Skip to contentSkip to conversation

rtnetlink: fix netns leak with rtnl_setlink()

PATCH Applied Nicolas Dichtel 3 participants 3 messages Feb 5, 2025 – Feb 7, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtnetlink: fix netns leak with rtnl_setlink()

A call to rtnl_nets_destroy() is needed to release references taken on netns put in rtnl_nets.

Fixes 636af13f213b ("rtnetlink: Register rtnl_dellink() and rtnl_setlink() with RTNL_FLAG_DOIT_PERNET_WIP.")
---
 net/core/rtnetlink.c | 1 +
 1 file changed, 1 insertion(+)
net/core/rtnetlink.c +1 -0
index 1f4d4b5570ab..d1e559fce918 100644
@@ -3432,6 +3432,7 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh,
 		err = -ENODEV;
 
 	rtnl_nets_unlock(&rtnl_nets);
+	rtnl_nets_destroy(&rtnl_nets);
 errout:
 	return err;
 }
Signature · 1 line
2.47.1
Reviewed-by on v1 1/1
#1 lore raw

From: Nicolas Dichtel <[email protected]>
Date: Wed, 5 Feb 2025 23:10:37 +0100

Quoted 6 lines

A call to rtnl_nets_destroy() is needed to release references taken on netns put in rtnl_nets.

Fixes 636af13f213b ("rtnetlink: Register rtnl_dellink() and rtnl_setlink() with RTNL_FLAG_DOIT_PERNET_WIP.")

Thanks!

Quoted 19 lines
---
 net/core/rtnetlink.c | 1 +
 1 file changed, 1 insertion(+)
net/core/rtnetlink.c +1 -0
index 1f4d4b5570ab..d1e559fce918 100644
@@ -3432,6 +3432,7 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh,
 		err = -ENODEV;
 
 	rtnl_nets_unlock(&rtnl_nets);
+	rtnl_nets_destroy(&rtnl_nets);
 errout:
 	return err;
 }
Signature · 1 line
2.47.1
#2 lore raw
In reply to Nicolas Dichtel
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 Wed, 5 Feb 2025 23:10:37 +0100 you wrote:

A call to rtnl_nets_destroy() is needed to release references taken on netns put in rtnl_nets.

Fixes 636af13f213b ("rtnetlink: Register rtnl_dellink() and rtnl_setlink() with RTNL_FLAG_DOIT_PERNET_WIP.")

[...]

Here is the summary with links:
- [net] rtnetlink: fix netns leak with rtnl_setlink()

    https://git.kernel.org/netdev/net/c/1438f5d07b9a

You are awesome, thank you!

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