Received: by 10.192.165.148 with SMTP id m20csp576461imm; Wed, 25 Apr 2018 04:33:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx49LhBVZgS7gWTixl+oaxo1dhBE1+SpGqT8d4Osesmq6fSlswx/SwonHGf88pCYFsOTp+NQF X-Received: by 10.99.181.30 with SMTP id y30mr21370138pge.279.1524656015216; Wed, 25 Apr 2018 04:33:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524656015; cv=none; d=google.com; s=arc-20160816; b=JN7ZPApeisBASIF3TNljj/fozuHOkjemqn0mHJYfFlsBnvof1Wme6PnOby9OHmRGar be/RkC751csAdCe/UeshHo+yJvkJ7HcopDzlLmUvf6xKDXogQYKLed//grvIdywYlBnB K6GM1ZCRPw543vjurqJipIQW/j4/VhAOLud+K0leEYfmmgASFolrTK48bpk6ijde8tLq jUbTT+NeQ7mHDhvHCV4cZWtjrcT7YWx42B0QhkV7NMc90vZ3Vt72H30C64fsfbsFZzE+ VG8rFgh78IemFOA7k5r9fPmXDP4jTPOhrReYFbZOcLf/Hsjx+d18QDub364H2FHlFWfw 2S4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ZXOnOkuPAbAsbNAj5f9XueNVQhDdzeQ6GSzIW5HZH1Y=; b=Cxor32j/DLCoWN2WaVU5KSNnSNwfiH2cjT5n4KhRn/4bVeYhISReCpsLPpzCBicb// c4OwCnv4u1S+2r6sNvwMANKNp5mIq8JJh5S3mtTLw5bsNluEKVCHweaim7tAKV2sBI1N NhLXTFOr9Bbh73aMHwNNhxcNNulHKzBFLeAhrwTsbmgAR/QySb0jXCJJKlnyKEFHktUh 4b+4hjQlxa2c/1sKU8zwZQ50sl1qz2Mk/jKLEqorjr4NxWDwrEyfpt7B7lRO23a0QV3i sIovdB0eKnRLgSrr+fNHowNvCnjuqbNYcsC/91jp8pST3WZD8aZxW6vZwdudUiUyvPde vC+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m7si3464437pfh.92.2018.04.25.04.33.20; Wed, 25 Apr 2018 04:33:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753350AbeDYKh4 (ORCPT + 99 others); Wed, 25 Apr 2018 06:37:56 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51204 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751451AbeDYKht (ORCPT ); Wed, 25 Apr 2018 06:37:49 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 29DAB49B; Wed, 25 Apr 2018 10:37:48 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Subash Abhinov Kasiviswanathan , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.14 025/183] netfilter: ipv6: nf_defrag: Pass on packets to stack per RFC2460 Date: Wed, 25 Apr 2018 12:34:05 +0200 Message-Id: <20180425103243.611683060@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Subash Abhinov Kasiviswanathan [ Upstream commit 83f1999caeb14e15df205e80d210699951733287 ] 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 Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/ipv6/netfilter/nf_conntrack_reasm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -230,7 +230,7 @@ static int nf_ct_frag6_queue(struct frag if ((unsigned int)end > IPV6_MAXPLEN) { pr_debug("offset is too large.\n"); - return -1; + return -EINVAL; } ecn = ip6_frag_ecn(ipv6_hdr(skb)); @@ -263,7 +263,7 @@ static int nf_ct_frag6_queue(struct frag * this case. -DaveM */ pr_debug("end of fragment not rounded to 8 bytes.\n"); - return -1; + return -EPROTO; } if (end > fq->q.len) { /* Some bits beyond end -> corruption. */ @@ -357,7 +357,7 @@ found: discard_fq: inet_frag_kill(&fq->q, &nf_frags); err: - return -1; + return -EINVAL; } /* @@ -566,6 +566,7 @@ find_prev_fhdr(struct sk_buff *skb, u8 * int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user) { + u16 savethdr = skb->transport_header; struct net_device *dev = skb->dev; int fhoff, nhoff, ret; struct frag_hdr *fhdr; @@ -599,8 +600,12 @@ int nf_ct_frag6_gather(struct net *net, spin_lock_bh(&fq->q.lock); - if (nf_ct_frag6_queue(fq, skb, fhdr, nhoff) < 0) { - ret = -EINVAL; + ret = nf_ct_frag6_queue(fq, skb, fhdr, nhoff); + if (ret < 0) { + if (ret == -EPROTO) { + skb->transport_header = savethdr; + ret = 0; + } goto out_unlock; }