Kernel panic after patch f3994eceebf64cf356a82ffb2718ef538eb8d4f4
Subsystems (3)
Herbert Xu
maintainerQuoted 29 lines · Herbert Xu
Quoted 4 lines · Herbert Xu
Perhaps something somewhere is creating an skb with the old way while someone else is assuming that it has the amount of space set out by needed_*room.
This changeset looks very suspicious:
commit
f5184d267c1aedb9b7a8cc44e08ff6b8d382c3b5Author: Johannes Berg <[email protected]> Date: Mon May 12 20:48:31 2008 -0700net: Allow netdevices to specify needed head/tailroom
net/xfrm/xfrm_output.c +3
-2@@ -25,11 +25,11 @@ static int xfrm_state_check_space(struct xfrm_state *x, struct sk_buff *skb)struct dst_entry *dst = skb->dst;int nhead = dst->header_len +LL_RESERVED_SPACE (dst->dev) -skb_headroom (skb); +int ntail = dst->dev->needed_tailroom -skb_tailroom (skb); -if (nhead >0 ) -return pskb_expand_head (skb, nhead,0 ,GFP_ATOMIC ); +if (nhead >0 || ntail >0 ) +return pskb_expand_head (skb, nhead, ntail,GFP_ATOMIC );
Quoted 1 line
If nhead < 0 and ntail > 0 we'll go boom...
Here's the fix.
ipsec: Fix pskb_expand_head corruption in xfrm_state_check_space
We're never supposed to shrink the headroom or tailroom. In fact, shrinking the headroom is a fatal action.
net/xfrm/xfrm_output.c +8 -4
@@ -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)
Thanks,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtDavid Miller
maintainerFrom: Herbert Xu <[email protected]>
Date: Thu, 25 Sep 2008 10:36:22 +0800
Quoted 8 lines
Here's the fix.
ipsec: Fix
pskb_expand_headcorruption inxfrm_state_check_spaceWe're never supposed to shrink the headroom or tailroom. In fact, shrinking the headroom is a fatal action.
Signed-off-by Herbert Xu <[email protected]>
Thanks a lot for diagnosing this and writing the patch Herbert.
I'll integrate this when I next get a chance.
Herbert Xu
maintainerQuoted 2 lines · David Miller
I'll integrate this when I next get a chance.
Thanks!
Oh and to make it more obvious in future:
net: BUG instead of corrupting memory in pskb_expand_head
If the caller of pskb_expand_head specifies a negative nhead we'll silently overwrite other people's memory. This patch makes it BUG instead.
net/core/skbuff.c +2 -0
@@ -701,6 +701,8 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,#endif long off; +BUG_ON (nhead <0 ); +if (skb_shared (skb))BUG ();
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtFrom: Herbert Xu <[email protected]>
Date: Thu, 25 Sep 2008 11:25:54 +0800
Quoted 7 lines
net: BUG instead of corrupting memory in
pskb_expand_headIf the caller of
pskb_expand_headspecifies a negative nhead we'll silently overwrite other people's memory. This patch makes it BUG instead.Signed-off-by Herbert Xu <[email protected]>
Applied to net-next-2.6, thanks!