aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/ipv4/udp_offload.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index d8776b2110c1..065334b41d57 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -352,6 +352,7 @@ static struct sk_buff *udp_gro_receive_segment(struct list_head *head,
352 struct sk_buff *pp = NULL; 352 struct sk_buff *pp = NULL;
353 struct udphdr *uh2; 353 struct udphdr *uh2;
354 struct sk_buff *p; 354 struct sk_buff *p;
355 unsigned int ulen;
355 356
356 /* requires non zero csum, for symmetry with GSO */ 357 /* requires non zero csum, for symmetry with GSO */
357 if (!uh->check) { 358 if (!uh->check) {
@@ -359,6 +360,12 @@ static struct sk_buff *udp_gro_receive_segment(struct list_head *head,
359 return NULL; 360 return NULL;
360 } 361 }
361 362
363 /* Do not deal with padded or malicious packets, sorry ! */
364 ulen = ntohs(uh->len);
365 if (ulen <= sizeof(*uh) || ulen != skb_gro_len(skb)) {
366 NAPI_GRO_CB(skb)->flush = 1;
367 return NULL;
368 }
362 /* pull encapsulating udp header */ 369 /* pull encapsulating udp header */
363 skb_gro_pull(skb, sizeof(struct udphdr)); 370 skb_gro_pull(skb, sizeof(struct udphdr));
364 skb_gro_postpull_rcsum(skb, uh, sizeof(struct udphdr)); 371 skb_gro_postpull_rcsum(skb, uh, sizeof(struct udphdr));
@@ -377,12 +384,12 @@ static struct sk_buff *udp_gro_receive_segment(struct list_head *head,
377 384
378 /* Terminate the flow on len mismatch or if it grow "too much". 385 /* Terminate the flow on len mismatch or if it grow "too much".
379 * Under small packet flood GRO count could elsewhere grow a lot 386 * Under small packet flood GRO count could elsewhere grow a lot
380 * leading to execessive truesize values. 387 * leading to excessive truesize values.
381 * On len mismatch merge the first packet shorter than gso_size, 388 * On len mismatch merge the first packet shorter than gso_size,
382 * otherwise complete the GRO packet. 389 * otherwise complete the GRO packet.
383 */ 390 */
384 if (uh->len > uh2->len || skb_gro_receive(p, skb) || 391 if (ulen > ntohs(uh2->len) || skb_gro_receive(p, skb) ||
385 uh->len != uh2->len || 392 ulen != ntohs(uh2->len) ||
386 NAPI_GRO_CB(p)->count >= UDP_GRO_CNT_MAX) 393 NAPI_GRO_CB(p)->count >= UDP_GRO_CNT_MAX)
387 pp = p; 394 pp = p;
388 395