Skip to content

Commit 5123ffd

Browse files
Florian Westphalgregkh
authored andcommitted
ipv6: defrag: drop non-last frags smaller than min mtu
don't bother with pathological cases, they only waste cycles. IPv6 requires a minimum MTU of 1280 so we should never see fragments smaller than this (except last frag). v3: don't use awkward "-offset + len" v2: drop IPv4 part, which added same check w. IPV4_MIN_MTU (68). There were concerns that there could be even smaller frags generated by intermediate nodes, e.g. on radio networks. Cc: Peter Oskolkov <posk@google.com> Cc: Eric Dumazet <edumazet@google.com> Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit 0ed4229) Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3bde783 commit 5123ffd

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

net/ipv6/netfilter/nf_conntrack_reasm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,10 @@ int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user)
565565
hdr = ipv6_hdr(skb);
566566
fhdr = (struct frag_hdr *)skb_transport_header(skb);
567567

568+
if (skb->len - skb_network_offset(skb) < IPV6_MIN_MTU &&
569+
fhdr->frag_off & htons(IP6_MF))
570+
return -EINVAL;
571+
568572
skb_orphan(skb);
569573
fq = fq_find(net, fhdr->identification, user, hdr,
570574
skb->dev ? skb->dev->ifindex : 0);

net/ipv6/reassembly.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,10 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
522522
return 1;
523523
}
524524

525+
if (skb->len - skb_network_offset(skb) < IPV6_MIN_MTU &&
526+
fhdr->frag_off & htons(IP6_MF))
527+
goto fail_hdr;
528+
525529
iif = skb->dev ? skb->dev->ifindex : 0;
526530
fq = fq_find(net, fhdr->identification, hdr, iif);
527531
if (fq) {

0 commit comments

Comments
 (0)