mirror of https://gitee.com/openkylin/linux.git
[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 <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
54489c14c0
commit
c8884edd07
|
@ -1946,7 +1946,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features)
|
||||||
do {
|
do {
|
||||||
struct sk_buff *nskb;
|
struct sk_buff *nskb;
|
||||||
skb_frag_t *frag;
|
skb_frag_t *frag;
|
||||||
int hsize, nsize;
|
int hsize;
|
||||||
int k;
|
int k;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
|
@ -1957,11 +1957,10 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features)
|
||||||
hsize = skb_headlen(skb) - offset;
|
hsize = skb_headlen(skb) - offset;
|
||||||
if (hsize < 0)
|
if (hsize < 0)
|
||||||
hsize = 0;
|
hsize = 0;
|
||||||
nsize = hsize + doffset;
|
if (hsize > len || !sg)
|
||||||
if (nsize > len + doffset || !sg)
|
hsize = len;
|
||||||
nsize = len + doffset;
|
|
||||||
|
|
||||||
nskb = alloc_skb(nsize + headroom, GFP_ATOMIC);
|
nskb = alloc_skb(hsize + doffset + headroom, GFP_ATOMIC);
|
||||||
if (unlikely(!nskb))
|
if (unlikely(!nskb))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue