Skip to content

Commit 61aaa1a

Browse files
committed
Merge branch 'catch-all-devices'
Hristo Venev says: ==================== net: Fix two use-after-free bugs The two patches fix two use-after-free bugs related to cleaning up network namespaces, one in sit and one in ip6_tunnel. They are easy to trigger if the user has the ability to create network namespaces. The bugs can be used to trigger null pointer dereferences. I am not sure if they can be exploited further, but I would guess that they can. I am not sending them to the mailing list without confirmation that doing so would be OK. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents ccb39c6 + 941ea91 commit 61aaa1a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

net/ipv6/ip6_tunnel.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,6 +2244,16 @@ static void __net_exit ip6_tnl_destroy_tunnels(struct net *net, struct list_head
22442244
t = rtnl_dereference(t->next);
22452245
}
22462246
}
2247+
2248+
t = rtnl_dereference(ip6n->tnls_wc[0]);
2249+
while (t) {
2250+
/* If dev is in the same netns, it has already
2251+
* been added to the list by the previous loop.
2252+
*/
2253+
if (!net_eq(dev_net(t->dev), net))
2254+
unregister_netdevice_queue(t->dev, list);
2255+
t = rtnl_dereference(t->next);
2256+
}
22472257
}
22482258

22492259
static int __net_init ip6_tnl_init_net(struct net *net)

net/ipv6/sit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,9 +1867,9 @@ static void __net_exit sit_destroy_tunnels(struct net *net,
18671867
if (dev->rtnl_link_ops == &sit_link_ops)
18681868
unregister_netdevice_queue(dev, head);
18691869

1870-
for (prio = 1; prio < 4; prio++) {
1870+
for (prio = 0; prio < 4; prio++) {
18711871
int h;
1872-
for (h = 0; h < IP6_SIT_HASH_SIZE; h++) {
1872+
for (h = 0; h < (prio ? IP6_SIT_HASH_SIZE : 1); h++) {
18731873
struct ip_tunnel *t;
18741874

18751875
t = rtnl_dereference(sitn->tunnels[prio][h]);

0 commit comments

Comments
 (0)