mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
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: 6d7b857d54 ("net: use lib/percpu_counter API for fragmentation mem accounting")
Signed-off-by: Eric Dumazet <[email protected]>
Reported-by: Dmitry Vyukov <[email protected]>
Cc: Hannes Frederic Sowa <[email protected]>
Cc: Jesper Dangaard Brouer <[email protected]>
Acked-by: Hannes Frederic Sowa <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
c451113291
commit
1d6119baf0
6 changed files with 44 additions and 24 deletions
|
|
@ -648,12 +648,18 @@ EXPORT_SYMBOL_GPL(nf_ct_frag6_consume_orig);
|
|||
|
||||
static int nf_ct_net_init(struct net *net)
|
||||
{
|
||||
int res;
|
||||
|
||||
net->nf_frag.frags.high_thresh = IPV6_FRAG_HIGH_THRESH;
|
||||
net->nf_frag.frags.low_thresh = IPV6_FRAG_LOW_THRESH;
|
||||
net->nf_frag.frags.timeout = IPV6_FRAG_TIMEOUT;
|
||||
inet_frags_init_net(&net->nf_frag.frags);
|
||||
|
||||
return nf_ct_frag6_sysctl_register(net);
|
||||
res = inet_frags_init_net(&net->nf_frag.frags);
|
||||
if (res)
|
||||
return res;
|
||||
res = nf_ct_frag6_sysctl_register(net);
|
||||
if (res)
|
||||
inet_frags_uninit_net(&net->nf_frag.frags);
|
||||
return res;
|
||||
}
|
||||
|
||||
static void nf_ct_net_exit(struct net *net)
|
||||
|
|
|
|||
|
|
@ -706,13 +706,19 @@ static void ip6_frags_sysctl_unregister(void)
|
|||
|
||||
static int __net_init ipv6_frags_init_net(struct net *net)
|
||||
{
|
||||
int res;
|
||||
|
||||
net->ipv6.frags.high_thresh = IPV6_FRAG_HIGH_THRESH;
|
||||
net->ipv6.frags.low_thresh = IPV6_FRAG_LOW_THRESH;
|
||||
net->ipv6.frags.timeout = IPV6_FRAG_TIMEOUT;
|
||||
|
||||
inet_frags_init_net(&net->ipv6.frags);
|
||||
|
||||
return ip6_frags_ns_sysctl_register(net);
|
||||
res = inet_frags_init_net(&net->ipv6.frags);
|
||||
if (res)
|
||||
return res;
|
||||
res = ip6_frags_ns_sysctl_register(net);
|
||||
if (res)
|
||||
inet_frags_uninit_net(&net->ipv6.frags);
|
||||
return res;
|
||||
}
|
||||
|
||||
static void __net_exit ipv6_frags_exit_net(struct net *net)
|
||||
|
|
|
|||
Loading…
Reference in a new issue