lkml.org 
[lkml]   [2010]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Regression, bisected: reference leak with IPSec since ~2.6.31
On Tue, Sep 21, 2010 at 01:58:30PM +0200, Eric Dumazet wrote:
> Le mardi 21 septembre 2010 ?? 10:48 +0000, Jarek Poplawski a écrit :
>
> > But if you were honest about caches there is no reason to be smart
> > no more. ;-)
> >
> > Below is your patch mostly as an example only that I didn't mean
> > nothing complex (ipv4 only, not compiled).
> >
> > Jarek P.
> > ---
> >
> > diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
> > index 04b6989..049d61f 100644
> > --- a/net/ipv4/ip_output.c
> > +++ b/net/ipv4/ip_output.c
> > @@ -490,7 +490,6 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
> > if (skb_has_frags(skb)) {
> > struct sk_buff *frag;
> > int first_len = skb_pagelen(skb);
> > - int truesizes = 0;
> >
> > if (first_len - hlen > mtu ||
> > ((first_len - hlen) & 7) ||
> > @@ -503,18 +502,18 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
> > if (frag->len > mtu ||
> > ((frag->len & 7) && frag->next) ||
> > skb_headroom(frag) < hlen)
> > - goto slow_path;
> > + goto slow_path_clean;
> >
> > /* Partially cloned skb? */
> > if (skb_shared(frag))
> > - goto slow_path;
> > + goto slow_path_clean;
> >
> > BUG_ON(frag->sk);
> > if (skb->sk) {
> > frag->sk = skb->sk;
> > frag->destructor = sock_wfree;
> > + skb->truesize -= frag->truesize;
> > }
> > - truesizes += frag->truesize;
> > }
> >
> > /* Everything is OK. Generate! */
> > @@ -524,7 +523,6 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
> > frag = skb_shinfo(skb)->frag_list;
> > skb_frag_list_init(skb);
> > skb->data_len = first_len - skb_headlen(skb);
> > - skb->truesize -= truesizes;
> > skb->len = first_len;
> > iph->tot_len = htons(first_len);
> > iph->frag_off = htons(IP_MF);
> > @@ -576,6 +574,17 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
> > }
> > IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS);
> > return err;
> > +
> > +slow_path_clean:
> > + if (skb->sk) {
> > + skb_walk_frags(skb, frag) {
> > + if (!frag->sk)
> > + break;
> > + frag->sk = NULL;
> > + frag->destructor = NULL;
> > + skb->truesize += frag->truesize;
> > + }
> > + }
> > }
> >
> > slow_path:
>
> Nice try, but this adds a bug unfortunately, or if you prefer makes the
> "BUG_ON(frag->sk);" being not fully covered.
>
> If we hit slow path, and one or more frags had frag->sk set, we silently
> unset it, instead of a nice BUG_ON().

Which exactly BUG_ON() on the slow path do you mean?

>
> If you really want to have a slow_path_clean, you should use a different
> frag2 iterator :
>
> slow_path_clean:
> if (skb->sk) {
> skb_walk_frags(skb, frag2) {
> if (frag2 == frag)
> break;
> frag2->sk = NULL;
> frag2->destructor = NULL;
> skb->truesize += frag2->truesize;
> }
> }
>
> Face it, this is too complex for net-2.6, could we just fix the bug, and
> 'optimize' later ?

I thought it's clear I didn't intend to change anything with this
example, but in any case I admit it: I'm 100% OK with your patch.

Jarek P.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2010-09-21 14:43    [W:0.065 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site