Skip to content

Commit

Permalink
ipsec: Fix pskb_expand_head corruption in xfrm_state_check_space
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Herbert Xu authored and David S. Miller committed Sep 30, 2008
1 parent 94aca1d commit d01dbeb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions net/xfrm/xfrm_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d01dbeb

Please sign in to comment.