* [PATCH net-next v2] netfilter: ipv6: nf_defrag: Pass on packets to stack per RFC2460
@ 2018-01-13 0:36 Subash Abhinov Kasiviswanathan
2018-01-16 0:47 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Subash Abhinov Kasiviswanathan @ 2018-01-13 0:36 UTC (permalink / raw)
To: pablo, netfilter-devel, fw; +Cc: Subash Abhinov Kasiviswanathan
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>
---
net/ipv6/netfilter/nf_conntrack_reasm.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 977d890..ce53dcf 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,
if ((unsigned int)end > IPV6_MAXPLEN) {
pr_debug("offset is too large.\n");
- return -1;
+ return -EINVAL;
}
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,
* 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. */
@@ -358,7 +358,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb,
discard_fq:
inet_frag_kill(&fq->q, &nf_frags);
err:
- return -1;
+ return -EINVAL;
}
/*
@@ -567,6 +567,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb,
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;
@@ -600,8 +601,12 @@ int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user)
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;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next v2] netfilter: ipv6: nf_defrag: Pass on packets to stack per RFC2460
2018-01-13 0:36 [PATCH net-next v2] netfilter: ipv6: nf_defrag: Pass on packets to stack per RFC2460 Subash Abhinov Kasiviswanathan
@ 2018-01-16 0:47 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2018-01-16 0:47 UTC (permalink / raw)
To: Subash Abhinov Kasiviswanathan; +Cc: netfilter-devel, fw
On Fri, Jan 12, 2018 at 05:36:27PM -0700, Subash Abhinov Kasiviswanathan wrote:
> 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.
Applied, thanks Subash.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-16 0:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-13 0:36 [PATCH net-next v2] netfilter: ipv6: nf_defrag: Pass on packets to stack per RFC2460 Subash Abhinov Kasiviswanathan
2018-01-16 0:47 ` Pablo Neira Ayuso
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).