From patchwork Tue Jul 9 18:22:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 257853 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id CAD522C008A for ; Wed, 10 Jul 2013 04:49:30 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751942Ab3GISt2 (ORCPT ); Tue, 9 Jul 2013 14:49:28 -0400 Received: from mail.us.es ([193.147.175.20]:53670 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751197Ab3GISt1 (ORCPT ); Tue, 9 Jul 2013 14:49:27 -0400 Received: (qmail 24969 invoked from network); 9 Jul 2013 20:49:25 +0200 Received: from unknown (HELO us.es) (192.168.2.12) by us.es with SMTP; 9 Jul 2013 20:49:25 +0200 Received: (qmail 30327 invoked by uid 507); 9 Jul 2013 18:22:45 -0000 X-Qmail-Scanner-Diagnostics: from 127.0.0.1 by antivirus2 (envelope-from , uid 501) with qmail-scanner-2.10 (clamdscan: 0.97.8/17476. spamassassin: 3.3.2. Clear:RC:1(127.0.0.1):SA:0(-99.7/7.5):. Processed in 1.797957 secs); 09 Jul 2013 18:22:45 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on antivirus2 X-Spam-Level: X-Spam-Status: No, score=-99.7 required=7.5 tests=BAYES_50, RP_MATCHES_RCVD, SPF_HELO_FAIL, USER_IN_WHITELIST autolearn=disabled version=3.3.2 X-Envelope-From: pneira@us.es Received: from unknown (HELO antivirus2) (127.0.0.1) by us.es with SMTP; 9 Jul 2013 18:22:43 -0000 Received: from 192.168.1.13 (192.168.1.13) by antivirus2 (F-Secure/fsigk_smtp/410/antivirus2); Tue, 09 Jul 2013 20:22:43 +0200 (CEST) X-Virus-Status: clean(F-Secure/fsigk_smtp/410/antivirus2) Received: (qmail 18356 invoked from network); 9 Jul 2013 20:22:39 +0200 Received: from 1984.lsi.us.es (HELO us.es) (1984lsi@150.214.188.80) by us.es with AES128-SHA encrypted SMTP; 9 Jul 2013 20:22:39 +0200 Date: Tue, 9 Jul 2013 20:22:23 +0200 From: Pablo Neira Ayuso To: Bill Fink Cc: netfilter@vger.kernel.org, netfilter-devel@vger.kernel.org, fw@strlen.de Subject: Re: conntrackd segfault on EPSV IPv6 ftp command when using ftp ExpectationSync Message-ID: <20130709182223.GA6266@localhost> References: <20130705020312.25783ccd.billfink@mindspring.com> <20130706132333.GA3279@localhost> <20130707030458.fbf22472.billfink@mindspring.com> <20130709013023.2fb1fef1.billfink@mindspring.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130709013023.2fb1fef1.billfink@mindspring.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org On Tue, Jul 09, 2013 at 01:30:23AM -0400, Bill Fink wrote: > On Sun, 7 Jul 2013, Bill Fink wrote: > > > I still have the remaining problem that the IPv6 expectation > > is not successfully synced from the primary firewall to the > > backup firewall. I see the following error in conntrackd.log > > on the backup firewall: > > > > [Sun Jul 7 01:56:38 2013] (pid=24763) [ERROR] inject-add2: Invalid argument > > Sun Jul 7 01:56:38 2013 300 proto=6 src=2001:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx dst=2001:yyyy:yyyy:yyyy:yyyy:yyyy:yyyy:yyyy sport=0 dport=39767 mask-src=ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff mask-dst=ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff sport=0 dport=65535 master-src=2001:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx master-dst=2001:yyyy:yyyy:yyyy:yyyy:yyyy:yyyy:yyyy sport=37484 dport=21 class=0 helper=ftp > > > > This exactly matches the IPv6 expectation on the primary firewall: > > > > [root@sen-fw1 ~]# conntrackd -i expect > > proto=6 src=2001:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx dst=2001:yyyy:yyyy:yyyy:yyyy:yyyy:yyyy:yyyy sport=0 dport=39767 mask-src=ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff mask-dst=ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff sport=0 dport=65535 master-src=2001:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx master-dst=2001:yyyy:yyyy:yyyy:yyyy:yyyy:yyyy:yyyy sport=37484 dport=21 class=0 helper=ftp [active since 9s] > > > > IPv4 expectations are working fine. > > > > I tried to track down the error, and followed the error path: > > > > external_inject_exp_new() -> > > nl_create_expect()-> > > nfexp_query() -> > > nfnl_query() -> > > nfnl_catch() -> > > nfnl_process() -> > > nfnl_step() -> > > nfnl_is_error() because > > nlh->nlmsg_type == NLMSG_ERROR > > > > but I wasn't sure how to proceed further. > > I made some more progress, but still haven't found the root > cause. I put some printks in the nf_conntrack_netlink and > nf_conntrack_ipv6 modules and tracked the error path there: > > ctnetlink_new_expect() -> > ctnetlink_create_expect() -> > ctnetlink_parse_expect_nat() -> > ctnetlink_parse_tuple() -> > ctnetlink_parse_tuple_ip() -> > l3proto->nlattr_to_tuple() -> > ipv6_nlattr_to_tuple() which fails > > because tb[CTA_IP_V6_SRC] and tb[CTA_IP_V6_DST] are null. > > But I'm currently stuck there. Where are tb[CTA_IP_V6_SRC] > and tb[CTA_IP_V6_DST] supposed to be set? Is it in conntrackd > during the build of the netlink message, or somewhere in one > of the conntrack kernel modules during processing of the > netlink message? Is there a map somewhere of the control > flow betwwen conntrackd and the conntrack kernel modules? > > I was also a little confused by the call to ctnetlink_parse_expect_nat() > since I'm not using NAT. That's a good clue, thanks. Please, give a try to the attached kernel patch. Regards. From 08fd3987afa49e092d3165a1b965a7a466cd3dc2 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 9 Jul 2013 20:16:39 +0200 Subject: [PATCH] netfilter: ctnetlink: fix incorrect NAT expectation dumping nf_ct_expect_alloc leaves unset the expectation NAT fields. However, ctnetlink_exp_dump_expect expects them to be zeroed in case they are not used, which may not be the case. This results in dumping the NAT tuple of the expectation when it should not. Fix it by zeroing the NAT fields of the expectation. Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_conntrack_expect.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c index c63b618..4fd1ca9 100644 --- a/net/netfilter/nf_conntrack_expect.c +++ b/net/netfilter/nf_conntrack_expect.c @@ -293,6 +293,11 @@ void nf_ct_expect_init(struct nf_conntrack_expect *exp, unsigned int class, sizeof(exp->tuple.dst.u3) - len); exp->tuple.dst.u.all = *dst; + +#ifdef CONFIG_NF_NAT_NEEDED + memset(&exp->saved_addr, 0, sizeof(exp->saved_addr)); + memset(&exp->saved_proto, 0, sizeof(exp->saved_proto)); +#endif } EXPORT_SYMBOL_GPL(nf_ct_expect_init); -- 1.7.10.4