diff mbox

Fw: [Bug 11633] Kernel panic after patch f3994eceebf64cf356a82ffb2718ef538eb8d4f4

Message ID 20080925023622.GA15800@gondor.apana.org.au
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Herbert Xu Sept. 25, 2008, 2:36 a.m. UTC
On Thu, Sep 25, 2008 at 09:21:05AM +0800, Herbert Xu wrote:
> On Thu, Sep 25, 2008 at 09:10:35AM +0800, Herbert Xu wrote:
> > 
> > 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 f5184d267c1aedb9b7a8cc44e08ff6b8d382c3b5
> Author: Johannes Berg <johannes@sipsolutions.net>
> Date:   Mon May 12 20:48:31 2008 -0700
> 
>     net: Allow netdevices to specify needed head/tailroom
> 
> diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
> index 09cd9c0..3f964db 100644
> --- a/net/xfrm/xfrm_output.c
> +++ b/net/xfrm/xfrm_output.c
> @@ -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);
> 
> 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.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>


Thanks,

Comments

David Miller Sept. 25, 2008, 2:49 a.m. UTC | #1
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Thu, 25 Sep 2008 10:36:22 +0800

> 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.
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Thanks a lot for diagnosing this and writing the patch Herbert.

I'll integrate this when I next get a chance.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
index ac25b4c..dc50f1e 100644
--- a/net/xfrm/xfrm_output.c
+++ b/net/xfrm/xfrm_output.c
@@ -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)