Subject: Re: gre: fix a possible skb leak

From: Daniel Borkmann <[email-masked]>
Date: Mon, 24 Jun 2013 16:38:07 +0200

On 06/24/2013 04:03 PM, Veaceslav Falico wrote:
> On Mon, Jun 24, 2013 at 06:26:00AM -0700, Eric Dumazet wrote:
>> From: Eric Dumazet <[email-masked]>
...
> Maybe we can also use it here (build-tested only):

Yep, this clean-up looks good I think. But then -net needs to be merged into
-net-next first (also for the gre_offload patch).

> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 4850dc1..5776819 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -2924,10 +2924,7 @@ perform_csum_check:
>       return segs;
>
>   err:
> -    while ((skb = segs)) {
> -        segs = skb->next;
> -        kfree_skb(skb);
> -    }
> +    kfree_skb_list(segs);
>       return ERR_PTR(err);
>   }
>   EXPORT_SYMBOL_GPL(skb_segment);
> diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
> index 4bcabf3..27ba045 100644
> --- a/net/ipv4/ip_output.c
> +++ b/net/ipv4/ip_output.c
> @@ -575,11 +575,7 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
>               return 0;
>           }
>
> -        while (frag) {
> -            skb = frag->next;
> -            kfree_skb(frag);
> -            frag = skb;
> -        }
> +        kfree_skb_list(frag);
>           IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS);
>           return err;
>