From: Herbert Xu Date: Mon, 30 Oct 2006 00:11:38 +0000 (-0800) Subject: [PATCH] NET: Fix skb_segment() handling of fully linear SKBs X-Git-Tag: v2.6.18.2~24 X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=5565a6be17231fdcbaa65e2ef41e4f67bf709a81;p=unionfs-2.6.39.y.git [PATCH] NET: Fix skb_segment() handling of fully linear SKBs [NET]: Fix segmentation of linear packets skb_segment fails to segment linear packets correctly because it tries to write all linear parts of the original skb into each segment. This will always panic as each segment only contains enough space for one MSS. This was not detected earlier because linear packets should be rare for GSO. In fact it still remains to be seen what exactly created the linear packets that triggered this bug. Basically the only time this should happen is if someone enables GSO emulation on an interface that does not support SG. Signed-off-by: Herbert Xu Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Signed-off-by: Chris Wright --- diff --git a/net/core/skbuff.c b/net/core/skbuff.c index c54f3664bce..7de98574e39 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -1945,7 +1945,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features) do { struct sk_buff *nskb; skb_frag_t *frag; - int hsize, nsize; + int hsize; int k; int size; @@ -1956,11 +1956,10 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features) hsize = skb_headlen(skb) - offset; if (hsize < 0) hsize = 0; - nsize = hsize + doffset; - if (nsize > len + doffset || !sg) - nsize = len + doffset; + if (hsize > len || !sg) + hsize = len; - nskb = alloc_skb(nsize + headroom, GFP_ATOMIC); + nskb = alloc_skb(hsize + doffset + headroom, GFP_ATOMIC); if (unlikely(!nskb)) goto err;