From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, gregkh@linuxfoundation.org,
stable@vger.kernel.org, edumazet@google.com,
sthemmin@microsoft.com, Florian Westphal <fw@strlen.de>,
Peter Oskolkov <posk@google.com>
Subject: [PATCH stable 4.9 v2 22/29] ipv6: defrag: drop non-last frags smaller than min mtu
Date: Wed, 10 Oct 2018 12:30:10 -0700 [thread overview]
Message-ID: <20181010193017.25221-23-f.fainelli@gmail.com> (raw)
In-Reply-To: <20181010193017.25221-1-f.fainelli@gmail.com>
From: Florian Westphal <fw@strlen.de>
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 0ed4229b08c13c84a3c301a08defdc9e7f4467e6)
---
net/ipv6/netfilter/nf_conntrack_reasm.c | 4 ++++
net/ipv6/reassembly.c | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index ff49d1f2c8cb..b81541701346 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -564,6 +564,10 @@ int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user)
hdr = ipv6_hdr(skb);
fhdr = (struct frag_hdr *)skb_transport_header(skb);
+ if (skb->len - skb_network_offset(skb) < IPV6_MIN_MTU &&
+ fhdr->frag_off & htons(IP6_MF))
+ return -EINVAL;
+
skb_orphan(skb);
fq = fq_find(net, fhdr->identification, user, hdr,
skb->dev ? skb->dev->ifindex : 0);
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index dbe726c9a2ae..78656bbe50e7 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -516,6 +516,10 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
return 1;
}
+ if (skb->len - skb_network_offset(skb) < IPV6_MIN_MTU &&
+ fhdr->frag_off & htons(IP6_MF))
+ goto fail_hdr;
+
iif = skb->dev ? skb->dev->ifindex : 0;
fq = fq_find(net, fhdr->identification, hdr, iif);
if (fq) {
--
2.17.1
next prev parent reply other threads:[~2018-10-11 2:54 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-10 19:29 [PATCH stable 4.9 v2 00/29] backport of IP fragmentation fixes Florian Fainelli
2018-10-10 19:29 ` [PATCH stable 4.9 v2 01/29] inet: frags: change inet_frags_init_net() return value Florian Fainelli
2018-10-10 19:29 ` [PATCH stable 4.9 v2 02/29] inet: frags: add a pointer to struct netns_frags Florian Fainelli
2018-10-10 19:29 ` [PATCH stable 4.9 v2 03/29] inet: frags: refactor ipfrag_init() Florian Fainelli
2018-10-10 19:29 ` [PATCH stable 4.9 v2 04/29] inet: frags: refactor ipv6_frag_init() Florian Fainelli
2018-10-10 19:29 ` [PATCH stable 4.9 v2 05/29] inet: frags: refactor lowpan_net_frag_init() Florian Fainelli
2018-10-10 19:29 ` [PATCH stable 4.9 v2 06/29] ipv6: export ip6 fragments sysctl to unprivileged users Florian Fainelli
2018-10-10 19:29 ` [PATCH stable 4.9 v2 07/29] rhashtable: add schedule points Florian Fainelli
2018-10-10 19:29 ` [PATCH stable 4.9 v2 08/29] inet: frags: use rhashtables for reassembly units Florian Fainelli
2018-10-10 19:29 ` [PATCH stable 4.9 v2 09/29] inet: frags: remove some helpers Florian Fainelli
2018-10-10 19:29 ` [PATCH stable 4.9 v2 10/29] inet: frags: get rif of inet_frag_evicting() Florian Fainelli
2018-10-10 19:29 ` [PATCH stable 4.9 v2 11/29] inet: frags: remove inet_frag_maybe_warn_overflow() Florian Fainelli
2018-10-10 19:30 ` [PATCH stable 4.9 v2 12/29] inet: frags: break the 2GB limit for frags storage Florian Fainelli
2018-10-10 19:30 ` [PATCH stable 4.9 v2 13/29] inet: frags: do not clone skb in ip_expire() Florian Fainelli
2018-10-10 19:30 ` [PATCH stable 4.9 v2 14/29] ipv6: frags: rewrite ip6_expire_frag_queue() Florian Fainelli
2018-10-10 19:30 ` [PATCH stable 4.9 v2 15/29] rhashtable: reorganize struct rhashtable layout Florian Fainelli
2018-10-10 19:30 ` [PATCH stable 4.9 v2 16/29] inet: frags: reorganize struct netns_frags Florian Fainelli
2018-10-10 19:30 ` [PATCH stable 4.9 v2 17/29] inet: frags: get rid of ipfrag_skb_cb/FRAG_CB Florian Fainelli
2018-10-10 19:30 ` [PATCH stable 4.9 v2 18/29] inet: frags: fix ip6frag_low_thresh boundary Florian Fainelli
2018-10-10 19:30 ` [PATCH stable 4.9 v2 19/29] ip: discard IPv4 datagrams with overlapping segments Florian Fainelli
2018-10-10 19:30 ` [PATCH stable 4.9 v2 20/29] net: speed up skb_rbtree_purge() Florian Fainelli
2018-10-10 19:30 ` [PATCH stable 4.9 v2 21/29] net: modify skb_rbtree_purge to return the truesize of all purged skbs Florian Fainelli
2018-10-10 19:30 ` Florian Fainelli [this message]
2018-10-10 19:30 ` [PATCH stable 4.9 v2 23/29] net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends Florian Fainelli
2018-10-10 19:30 ` [PATCH stable 4.9 v2 24/29] net: add rb_to_skb() and other rb tree helpers Florian Fainelli
2018-10-10 19:30 ` [PATCH stable 4.9 v2 25/29] ip: use rb trees for IP frag queue Florian Fainelli
2018-10-10 19:30 ` [PATCH stable 4.9 v2 26/29] ip: add helpers to process in-order fragments faster Florian Fainelli
2018-10-10 19:30 ` [PATCH stable 4.9 v2 27/29] ip: process in-order fragments efficiently Florian Fainelli
2018-10-10 19:30 ` [PATCH stable 4.9 v2 28/29] ip: frags: fix crash in ip_do_fragment() Florian Fainelli
2018-10-10 19:30 ` [PATCH stable 4.9 v2 29/29] ipv4: frags: precedence bug in ip_expire() Florian Fainelli
2018-10-15 17:47 ` [PATCH stable 4.9 v2 00/29] backport of IP fragmentation fixes Florian Fainelli
2018-10-15 17:53 ` Eric Dumazet
2018-10-16 16:15 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181010193017.25221-23-f.fainelli@gmail.com \
--to=f.fainelli@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=gregkh@linuxfoundation.org \
--cc=netdev@vger.kernel.org \
--cc=posk@google.com \
--cc=stable@vger.kernel.org \
--cc=sthemmin@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).