[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211002223332.548350-1-shjy180909@gmail.com>
Date: Sat, 2 Oct 2021 22:33:32 +0000
From: MichelleJin <shjy180909@...il.com>
To: davem@...emloft.net, dsahern@...nel.org, kuba@...nel.org
Cc: netdev@...r.kernel.org
Subject: [PATCH net-next] 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.
Fixes: f04ed7d277e8 ("net: ipv6: check return value of rhashtable_init")
Signed-off-by: MichelleJin <shjy180909@...il.com>
---
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(-)
diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c
index 65744f2d38da..5daa1c3ed83b 100644
--- a/net/ipv6/seg6.c
+++ b/net/ipv6/seg6.c
@@ -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
--
2.25.1
Powered by blists - more mailing lists