ipv6: release fib6_null_entry on subtree failure
Subsystems (3)
PATCH 1/1 ipv6: release fib6_null_entry on subtree failure
When adding a source-specific route creates a new subtree, fib6_add() installs fib6_null_entry as the temporary leaf of the new subtree root and takes a fib6_info reference for that holder.
If adding the first source leaf fails, the code frees the just allocated subtree root but leaves that hold behind. fib6_null_entry is a per-netns sentinel and is freed directly at netns teardown, so this does not keep the object alive. However, it leaves its visible refcount permanently elevated and can eventually saturate the refcount on repeated failures.
Drop the null-entry reference before freeing the unlinked subtree root.
--- net/ipv6/ip6_fib.c | 1 + 1 file changed, 1 insertion(+)
net/ipv6/ip6_fib.c +1 -0
@@ -1494,6 +1494,7 @@ int fib6_add(struct fib6_node *root, struct fib6_info *rt,root, and then (in failure) stale node in main tree. */ +fib6_info_release (info->nl_net->ipv6.fib6_null_entry);node_free_immediate (info->nl_net, sfn); err =PTR_ERR (sn); goto failure;
Signature · 1 line
2.43.0
Quoted 10 lines · Shuangpeng Bai
When adding a source-specific route creates a new subtree,
fib6_add()installsfib6_null_entryas the temporary leaf of the new subtree root and takes afib6_inforeference for that holder.If adding the first source leaf fails, the code frees the just allocated subtree root but leaves that hold behind.
fib6_null_entryis a per-netns sentinel and is freed directly at netns teardown, so this does not keep the object alive. However, it leaves its visible refcount permanently elevated and can eventually saturate the refcount on repeated failures.
Quoted 3 lines
Drop the null-entry reference before freeing the unlinked subtree root.
Fixes 5ea715289af6 ("ipv6: broadly use fib6_info_hold() helper")
Should be:
Quoted 1 line
Signed-off-by Shuangpeng Bai <[email protected]>
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 11 lines · On Mon, 27 Jul 2026 14:53:39 -0400 you wrote:
When adding a source-specific route creates a new subtree,
fib6_add()installsfib6_null_entryas the temporary leaf of the new subtree root and takes afib6_inforeference for that holder.If adding the first source leaf fails, the code frees the just allocated subtree root but leaves that hold behind.
fib6_null_entryis a per-netns sentinel and is freed directly at netns teardown, so this does not keep the object alive. However, it leaves its visible refcount permanently elevated and can eventually saturate the refcount on repeated failures.[...]
Here is the summary with links:
- [net] ipv6: release fib6_null_entry on subtree failure
https://git.kernel.org/netdev/net/c/93cad1f6bd1e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html