ip: fix truesize mismatch in ip fragmentation
commitf75c81af1527ad2a4d413ee03c55afdc681e4392
authorEric Dumazet <eric.dumazet@gmail.com>
Tue, 21 Sep 2010 08:47:45 +0000 (21 08:47 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 22 Nov 2010 19:00:06 +0000 (22 11:00 -0800)
treea1e0e967714a9ea917a0249df6c84f8db10492ba
parent4d7fa13e13b6d9cf4d2ed085d8c093dc6c6b549e
ip: fix truesize mismatch in ip fragmentation

[ Upstream commit 3d13008e7345fa7a79d8f6438150dc15d6ba6e9d ]

Special care should be taken when slow path is hit in ip_fragment() :

When walking through frags, we transfert truesize ownership from skb to
frags. Then if we hit a slow_path condition, we must undo this or risk
uncharging frags->truesize twice, and in the end, having negative socket
sk_wmem_alloc counter, or even freeing socket sooner than expected.

Many thanks to Nick Bowler, who provided a very clean bug report and
test program.

Thanks to Jarek for reviewing my first patch and providing a V2

While Nick bisection pointed to commit 2b85a34e911 (net: No more
expensive sock_hold()/sock_put() on each tx), underlying bug is older
(2.6.12-rc5)

A side effect is to extend work done in commit b2722b1c3a893e
(ip_fragment: also adjust skb->truesize for packets not owned by a
socket) to ipv6 as well.

Reported-and-bisected-by: Nick Bowler <nbowler@elliptictech.com>
Tested-by: Nick Bowler <nbowler@elliptictech.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Jarek Poplawski <jarkao2@gmail.com>
CC: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/ipv4/ip_output.c
net/ipv6/ip6_output.c