diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c index 700f1861d8eb..01642900c0fa 100644 --- a/net/ipv6/ip6_offload.c +++ b/net/ipv6/ip6_offload.c @@ -26,6 +26,7 @@ static int ipv6_gro_pull_exthdrs(struct sk_buff *skb, int off, int proto) { const struct net_offload *ops = NULL; struct ipv6_opt_hdr *opth; + int exthdr_cnt = 0; for (;;) { int len; @@ -38,6 +39,13 @@ static int ipv6_gro_pull_exthdrs(struct sk_buff *skb, int off, int proto) if (!(ops->flags & INET6_PROTO_GSO_EXTHDR)) break; + /* Same limit as ip6_protocol_deliver_rcu(). + * @proto is left pointing to an extension header, + * so that the caller does not aggregate this packet. + */ + if (unlikely(exthdr_cnt++ >= IP6_MAX_EXT_HDRS_CNT)) + break; + opth = skb_gro_header(skb, off + sizeof(*opth), off); if (unlikely(!opth)) break;