aboutsummaryrefslogtreecommitdiffstats
path: root/net/ieee802154
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2015-11-02 12:03:11 -0500
committerDavid S. Miller <davem@davemloft.net>2015-11-02 22:47:14 -0500
commit1d6119baf0610f813eb9d9580eb4fd16de5b4ceb (patch)
tree0ea51e8f1fc3135c901acce5f49469b5e37f61b9 /net/ieee802154
parentc451113291c193d3bfbd0682011d2979d649010c (diff)
net: fix percpu memory leaks
This patch fixes following problems : 1) percpu_counter_init() can return an error, therefore init_frag_mem_limit() must propagate this error so that inet_frags_init_net() can do the same up to its callers. 2) If ip[46]_frags_ns_ctl_register() fail, we must unwind properly and free the percpu_counter. Without this fix, we leave freed object in percpu_counters global list (if CONFIG_HOTPLUG_CPU) leading to crashes. This bug was detected by KASAN and syzkaller tool (http://github.com/google/syzkaller) Fixes: 6d7b857d541e ("net: use lib/percpu_counter API for fragmentation mem accounting") Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: Dmitry Vyukov <dvyukov@google.com> Cc: Hannes Frederic Sowa <hannes@stressinduktion.org> Cc: Jesper Dangaard Brouer <brouer@redhat.com> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ieee802154')
-rw-r--r--net/ieee802154/6lowpan/reassembly.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
index 12e8cf4bda9f..6b437e8760d3 100644
--- a/net/ieee802154/6lowpan/reassembly.c
+++ b/net/ieee802154/6lowpan/reassembly.c
@@ -580,14 +580,19 @@ static int __net_init lowpan_frags_init_net(struct net *net)
580{ 580{
581 struct netns_ieee802154_lowpan *ieee802154_lowpan = 581 struct netns_ieee802154_lowpan *ieee802154_lowpan =
582 net_ieee802154_lowpan(net); 582 net_ieee802154_lowpan(net);
583 int res;
583 584
584 ieee802154_lowpan->frags.high_thresh = IPV6_FRAG_HIGH_THRESH; 585 ieee802154_lowpan->frags.high_thresh = IPV6_FRAG_HIGH_THRESH;
585 ieee802154_lowpan->frags.low_thresh = IPV6_FRAG_LOW_THRESH; 586 ieee802154_lowpan->frags.low_thresh = IPV6_FRAG_LOW_THRESH;
586 ieee802154_lowpan->frags.timeout = IPV6_FRAG_TIMEOUT; 587 ieee802154_lowpan->frags.timeout = IPV6_FRAG_TIMEOUT;
587 588
588 inet_frags_init_net(&ieee802154_lowpan->frags); 589 res = inet_frags_init_net(&ieee802154_lowpan->frags);
589 590 if (res)
590 return lowpan_frags_ns_sysctl_register(net); 591 return res;
592 res = lowpan_frags_ns_sysctl_register(net);
593 if (res)
594 inet_frags_uninit_net(&ieee802154_lowpan->frags);
595 return res;
591} 596}
592 597
593static void __net_exit lowpan_frags_exit_net(struct net *net) 598static void __net_exit lowpan_frags_exit_net(struct net *net)