ipmr: dont corrupt lists
authorEric Dumazet <eric.dumazet@gmail.com>
Sun, 6 Jun 2010 23:48:40 +0000 (23:48 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 7 Jun 2010 09:57:14 +0000 (02:57 -0700)
ipmr_rules_exit() and ip6mr_rules_exit() free a list of items, but
forget to properly remove these items from list. List head is not
changed and still points to freed memory.

This can trigger a fault later when icmpv6_sk_exit() is called.

Fix is to either reinit list, or use list_del() to properly remove items
from list before freeing them.

bugzilla report : https://bugzilla.kernel.org/show_bug.cgi?id=16120

Introduced by commit d1db275dd3f6e4 (ipv6: ip6mr: support multiple
tables) and commit f0ad0860d01e (ipv4: ipmr: support multiple tables)

Reported-by: Alex Zhavnerchik <alex.vizor@gmail.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ipmr.c
net/ipv6/ip6mr.c

index 856123fe32f98c97e3364a322fe9899d4b8d1359..757f25eb9b4b2404ebebc6c4422b4ad1693ea227 100644 (file)
@@ -267,8 +267,10 @@ static void __net_exit ipmr_rules_exit(struct net *net)
 {
        struct mr_table *mrt, *next;
 
-       list_for_each_entry_safe(mrt, next, &net->ipv4.mr_tables, list)
+       list_for_each_entry_safe(mrt, next, &net->ipv4.mr_tables, list) {
+               list_del(&mrt->list);
                kfree(mrt);
+       }
        fib_rules_unregister(net->ipv4.mr_rules_ops);
 }
 #else
index 89c0b077c7aa7e2beb0b075bbacf8bc75e8dd03f..66078dad7fe8c353bd4de83115dc4eee73ba978f 100644 (file)
@@ -254,8 +254,10 @@ static void __net_exit ip6mr_rules_exit(struct net *net)
 {
        struct mr6_table *mrt, *next;
 
-       list_for_each_entry_safe(mrt, next, &net->ipv6.mr6_tables, list)
+       list_for_each_entry_safe(mrt, next, &net->ipv6.mr6_tables, list) {
+               list_del(&mrt->list);
                ip6mr_free_table(mrt);
+       }
        fib_rules_unregister(net->ipv6.mr6_rules_ops);
 }
 #else