]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ipsec: Fix pskb_expand_head corruption in xfrm_state_check_space
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 30 Sep 2008 09:03:19 +0000 (02:03 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 9 Oct 2008 03:23:08 +0000 (20:23 -0700)
[ Upstream commit d01dbeb6af7a0848063033f73c3d146fec7451f3 ]

We're never supposed to shrink the headroom or tailroom.  In fact,
shrinking the headroom is a fatal action.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/xfrm/xfrm_output.c

index 3f964db908a71466e77949568d6ea672c63f281c..5360c86e95e0f9ba1052ec02b8b6d2fd87ca171d 100644 (file)
@@ -27,10 +27,14 @@ static int xfrm_state_check_space(struct xfrm_state *x, struct sk_buff *skb)
                - skb_headroom(skb);
        int ntail = dst->dev->needed_tailroom - skb_tailroom(skb);
 
-       if (nhead > 0 || ntail > 0)
-               return pskb_expand_head(skb, nhead, ntail, GFP_ATOMIC);
-
-       return 0;
+       if (nhead <= 0) {
+               if (ntail <= 0)
+                       return 0;
+               nhead = 0;
+       } else if (ntail < 0)
+               ntail = 0;
+
+       return pskb_expand_head(skb, nhead, ntail, GFP_ATOMIC);
 }
 
 static int xfrm_output_one(struct sk_buff *skb, int err)