net: ipv6: fix use after free of struct seg6_pernet_data
Subsystems (3)
PATCH 1/1 net: ipv6: fix use after free of struct seg6_pernet_data
sdata->tun_src should be freed before sdata is freed because sdata->tun_src is allocated after sdata allocation. So, kfree(sdata) and kfree(rcu_dereference_raw(sdata->tun_src)) are changed code order.
---
commit f04ed7d277e8
("net: ipv6: check return value of rhashtable_init") is not yet merged into net branch,
so this patch is committed to net-next.
net/ipv6/seg6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/seg6.c +1 -1
@@ -375,8 +375,8 @@ static int __net_init seg6_net_init(struct net *net)#ifdef CONFIG_IPV6_SEG6_HMAC if (seg6_hmac_net_init (net)) { -kfree (sdata);kfree (rcu_dereference_raw (sdata->tun_src)); +kfree (sdata);return -ENOMEM ; };#endif
Signature · 1 line
2.25.1
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Sat, 2 Oct 2021 22:33:32 +0000 you wrote:
sdata->tun_srcshould be freed before sdata is freed becausesdata->tun_srcis allocated after sdata allocation. So, kfree(sdata) and kfree(rcu_dereference_raw(sdata->tun_src)) are changed code order.Fixes f04ed7d277e8 ("net: ipv6: check return value of rhashtable_init")[...]
Here is the summary with links:
- [net-next] net: ipv6: fix use after free of struct seg6_pernet_data
https://git.kernel.org/netdev/net-next/c/23b08260481c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html