aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSubash Abhinov Kasiviswanathan <subashab@codeaurora.org>2018-01-12 19:36:27 -0500
committerPablo Neira Ayuso <pablo@netfilter.org>2018-01-15 19:52:06 -0500
commit83f1999caeb14e15df205e80d210699951733287 (patch)
tree77facde53b8e8a83903512c092765c8ddb16c191
parente3eeacbac4ad34fac93f82a7cf15402bba83d22e (diff)
netfilter: ipv6: nf_defrag: Pass on packets to stack per RFC2460
ipv6_defrag pulls network headers before fragment header. In case of an error, the netfilter layer is currently dropping these packets. This results in failure of some IPv6 standards tests which passed on older kernels due to the netfilter framework using cloning. The test case run here is a check for ICMPv6 error message replies when some invalid IPv6 fragments are sent. This specific test case is listed in https://www.ipv6ready.org/docs/Core_Conformance_Latest.pdf in the Extension Header Processing Order section. A packet with unrecognized option Type 11 is sent and the test expects an ICMP error in line with RFC2460 section 4.2 - 11 - discard the packet and, only if the packet's Destination Address was not a multicast address, send an ICMP Parameter Problem, Code 2, message to the packet's Source Address, pointing to the unrecognized Option Type. Since netfilter layer now drops all invalid IPv6 frag packets, we no longer see the ICMP error message and fail the test case. To fix this, save the transport header. If defrag is unable to process the packet due to RFC2460, restore the transport header and allow packet to be processed by stack. There is no change for other packet processing paths. Tested by confirming that stack sends an ICMP error when it receives these packets. Also tested that fragmented ICMP pings succeed. v1->v2: Instead of cloning always, save the transport_header and restore it in case of this specific error. Update the title and commit message accordingly. Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--net/ipv6/netfilter/nf_conntrack_reasm.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 977d8900cfd1..ce53dcfda88a 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -231,7 +231,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb,
231 231
232 if ((unsigned int)end > IPV6_MAXPLEN) { 232 if ((unsigned int)end > IPV6_MAXPLEN) {
233 pr_debug("offset is too large.\n"); 233 pr_debug("offset is too large.\n");
234 return -1; 234 return -EINVAL;
235 } 235 }
236 236
237 ecn = ip6_frag_ecn(ipv6_hdr(skb)); 237 ecn = ip6_frag_ecn(ipv6_hdr(skb));
@@ -264,7 +264,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb,
264 * this case. -DaveM 264 * this case. -DaveM
265 */ 265 */
266 pr_debug("end of fragment not rounded to 8 bytes.\n"); 266 pr_debug("end of fragment not rounded to 8 bytes.\n");
267 return -1; 267 return -EPROTO;
268 } 268 }
269 if (end > fq->q.len) { 269 if (end > fq->q.len) {
270 /* Some bits beyond end -> corruption. */ 270 /* Some bits beyond end -> corruption. */
@@ -358,7 +358,7 @@ found:
358discard_fq: 358discard_fq:
359 inet_frag_kill(&fq->q, &nf_frags); 359 inet_frag_kill(&fq->q, &nf_frags);
360err: 360err:
361 return -1; 361 return -EINVAL;
362} 362}
363 363
364/* 364/*
@@ -567,6 +567,7 @@ find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff)
567 567
568int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user) 568int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user)
569{ 569{
570 u16 savethdr = skb->transport_header;
570 struct net_device *dev = skb->dev; 571 struct net_device *dev = skb->dev;
571 int fhoff, nhoff, ret; 572 int fhoff, nhoff, ret;
572 struct frag_hdr *fhdr; 573 struct frag_hdr *fhdr;
@@ -600,8 +601,12 @@ int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user)
600 601
601 spin_lock_bh(&fq->q.lock); 602 spin_lock_bh(&fq->q.lock);
602 603
603 if (nf_ct_frag6_queue(fq, skb, fhdr, nhoff) < 0) { 604 ret = nf_ct_frag6_queue(fq, skb, fhdr, nhoff);
604 ret = -EINVAL; 605 if (ret < 0) {
606 if (ret == -EPROTO) {
607 skb->transport_header = savethdr;
608 ret = 0;
609 }
605 goto out_unlock; 610 goto out_unlock;
606 } 611 }
607 612