Re: Regression, bisected: reference leak with IPSec since ~2.6.31

From: Eric Dumazet
Date: Tue Sep 21 2010 - 06:07:53 EST


Le mardi 21 septembre 2010 Ã 11:55 +0200, Eric Dumazet a Ãcrit :
> Le mardi 21 septembre 2010 Ã 09:38 +0000, Jarek Poplawski a Ãcrit :
> > On Tue, Sep 21, 2010 at 11:21:00AM +0200, Eric Dumazet wrote:
>
> > I hope you're right with this.
> >
> > >
> > > I liked the :
> > >
> > > <check everything without changing state>
> > > if something wrong
> > > goto slow_path
> > > else
> > > <OK, lets do destructive things>
> > >
> >
> > But it's an optimization of the "unlikely" case btw. ;-)
> >
>
> This is a bug fix, in a complex function.
>
> in -next branch, we can try to be smart, adding more code in slow_path
> to revert what was done in the hope fast path would be taken.
> And pray we dont add another bug :)
>

My initial patch was somehing like :

<loop to check everything is ok>
compute truesizes = sum (frag->truesize)
not modifying frag->sk/frag->destructor

if problem -> goto slow_path
else {
skb->truesize -= truesizes;
send(skb)

for each frag
set frag->sk = original_sk
set frag->destructor = sock_wfree
send(frag)

Problem was if we got an error while sending skb or one frag :
It was leaking some truesize accounting.
(an extra loop was needed to set frag->sk/frag->destructor for remaining
frags before freeing them)

So I added the extra loop to :

for each frag {
set frag->sk = skb->sk
set frag->destructor = sock_wfree
skb->truesize -= frag->truesize
}

It removed the need to compute sum(frag->truesize) in a temp variable
(truesizes)


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