From: Eric Dumazet Date: Fri, 17 May 2013 04:53:13 +0000 (+0000) Subject: ipv6: fix possible crashes in ip6_cork_release() X-Git-Tag: v3.10-rc3~18^2~31 X-Git-Url: http://pileus.org/git/?a=commitdiff_plain;ds=sidebyside;h=284041ef21fdf2e0d216ab6b787bc9072b4eb58a;p=~andy%2Flinux ipv6: fix possible crashes in ip6_cork_release() commit 0178b695fd6b4 ("ipv6: Copy cork options in ip6_append_data") added some code duplication and bad error recovery, leading to potential crash in ip6_cork_release() as kfree() could be called with garbage. use kzalloc() to make sure this wont happen. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Cc: Herbert Xu Cc: Hideaki YOSHIFUJI Cc: Neal Cardwell --- diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index d2eedf19233..dae1949019d 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -1147,7 +1147,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, if (WARN_ON(np->cork.opt)) return -EINVAL; - np->cork.opt = kmalloc(opt->tot_len, sk->sk_allocation); + np->cork.opt = kzalloc(opt->tot_len, sk->sk_allocation); if (unlikely(np->cork.opt == NULL)) return -ENOBUFS;