Skip to contentSkip to conversation

net dst: fix percpu_counter list corruption and poison overwritten

PATCH Applied Xiaotian Feng 3 participants 4 messages Nov 3, 2010 – Nov 4, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net dst: fix percpu_counter list corruption and poison overwritten

There're some percpu_counter list corruption and poison overwritten warnings in recent kernel, which is resulted by fc66f95c.

commit fc66f95c switches to use percpu_counter, in ip6_route_net_init, kernel init the percpu_counter for dst entries, but, the percpu_counter is never destroyed in ip6_route_net_exit. So if the related data is freed by kernel, the freed percpu_counter is still on the list, then if we insert/remove other percpu_counter, list corruption resulted. Also, if the insert/remove option modifies the ->prev,->next pointer of the freed value, the poison overwritten is resulted then.

With the following patch, the percpu_counter list corruption and poison overwritten warnings disappeared.

Cc "David S. Miller" <[email protected]>
Cc Alexey Kuznetsov <[email protected]>
Cc "Pekka Savola (ipv6)" <[email protected]>
Cc James Morris <[email protected]>
Cc Hideaki YOSHIFUJI <[email protected]>
Cc Patrick McHardy <[email protected]>
---
 net/ipv6/route.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
net/ipv6/route.c +2 -0
index 25661f9..fc32833 100644
@@ -2741,6 +2741,7 @@ static void __net_exit ip6_route_net_exit(struct net *net)
 	kfree(net->ipv6.ip6_prohibit_entry);
 	kfree(net->ipv6.ip6_blk_hole_entry);
 #endif
+	dst_entries_destroy(&net->ipv6.ip6_dst_ops);
 }
 
 static struct pernet_operations ip6_route_net_ops = {
@@ -2832,5 +2833,6 @@ void ip6_route_cleanup(void)
 	xfrm6_fini();
 	fib6_gc_cleanup();
 	unregister_pernet_subsys(&ip6_route_net_ops);
+	dst_entries_destroy(&ip6_dst_blackhole_ops);
 	kmem_cache_destroy(ip6_dst_ops_template.kmem_cachep);
 }
Signature · 1 line
1.7.3.2
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · Xiaotian Feng

There're some percpu_counter list corruption and poison overwritten warnings in recent kernel, which is resulted by fc66f95c.

commit fc66f95c switches to use percpu_counter, in ip6_route_net_init, kernel init the percpu_counter for dst entries, but, the percpu_counter is never destroyed in ip6_route_net_exit. So if the related data is freed by kernel, the freed percpu_counter is still on the list, then if we insert/remove other percpu_counter, list corruption resulted. Also, if the insert/remove option modifies the ->prev,->next pointer of the freed value, the poison overwritten is resulted then.

With the following patch, the percpu_counter list corruption and poison overwritten warnings disappeared.

Quoted 8 lines
Cc "David S. Miller" <[email protected]>
Cc Alexey Kuznetsov <[email protected]>
Cc "Pekka Savola (ipv6)" <[email protected]>
Cc James Morris <[email protected]>
Cc Hideaki YOSHIFUJI <[email protected]>
Cc Patrick McHardy <[email protected]>

---

Good catch, thanks !

Any reason you didnt Cc me (the author of the patch) ?

#2 lore raw
Quoted 23 lines · Eric Dumazet
Quoted 13 lines · Xiaotian Feng

There're some percpu_counter list corruption and poison overwritten warnings in recent kernel, which is resulted by fc66f95c.

commit fc66f95c switches to use percpu_counter, in ip6_route_net_init, kernel init the percpu_counter for dst entries, but, the percpu_counter is never destroyed in ip6_route_net_exit. So if the related data is freed by kernel, the freed percpu_counter is still on the list, then if we insert/remove other percpu_counter, list corruption resulted. Also, if the insert/remove option modifies the ->prev,->next pointer of the freed value, the poison overwritten is resulted then.

With the following patch, the percpu_counter list corruption and poison overwritten warnings disappeared.

Quoted 8 lines
Cc "David S. Miller"<[email protected]>
Cc Alexey Kuznetsov<[email protected]>
Cc "Pekka Savola (ipv6)"<[email protected]>
Cc James Morris<[email protected]>
Cc Hideaki YOSHIFUJI<[email protected]>
Cc Patrick McHardy<[email protected]>

---

Quoted 3 lines

Good catch, thanks !

Any reason you didnt Cc me (the author of the patch) ?

Sorry, I just used get_maintainer.pl to get the cc list...

Quoted 6 lines
maintainer Applied
#3 lore raw
In reply to Eric Dumazet

From: Eric Dumazet <[email protected]>
Date: Wed, 03 Nov 2010 06:22:53 +0100

Quoted 15 lines · Xiaotian Feng
Quoted 14 lines

There're some percpu_counter list corruption and poison overwritten warnings in recent kernel, which is resulted by fc66f95c.

commit fc66f95c switches to use percpu_counter, in ip6_route_net_init, kernel init the percpu_counter for dst entries, but, the percpu_counter is never destroyed in ip6_route_net_exit. So if the related data is freed by kernel, the freed percpu_counter is still on the list, then if we insert/remove other percpu_counter, list corruption resulted. Also, if the insert/remove option modifies the ->prev,->next pointer of the freed value, the poison overwritten is resulted then.

With the following patch, the percpu_counter list corruption and poison overwritten warnings disappeared.

...

Quoted 1 line

Applied, thanks!