From patchwork Sun Dec 8 16:52:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick McHardy X-Patchwork-Id: 298848 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 542FD2C00CA for ; Mon, 9 Dec 2013 03:52:49 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754899Ab3LHQwg (ORCPT ); Sun, 8 Dec 2013 11:52:36 -0500 Received: from stinky.trash.net ([213.144.137.162]:65231 "EHLO stinky.trash.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754768Ab3LHQwf (ORCPT ); Sun, 8 Dec 2013 11:52:35 -0500 Received: from macbook.localnet (unknown [127.0.0.1]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by stinky.trash.net (Postfix) with ESMTPS id 83CF29D2DC; Sun, 8 Dec 2013 17:52:33 +0100 (MET) Date: Sun, 8 Dec 2013 16:52:31 +0000 From: Patrick McHardy To: Pablo Neira Ayuso Cc: "Nicki P." , netfilter-devel@vger.kernel.org Subject: Re: ipt_SYNPROXY: kernel panic caused by nullpointer dereference Message-ID: <20131208165231.GA1564@macbook.localnet> References: <20131208100146.GA3840@localhost> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20131208100146.GA3840@localhost> 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 Sun, Dec 08, 2013 at 11:01:46AM +0100, Pablo Neira Ayuso wrote: > On Sun, Dec 08, 2013 at 08:16:00AM +0100, Nicki P. wrote: > > hi, > > > > when activating ipt_SYNPROXY with: > > iptables -t raw -A PREROUTING -p tcp -d 1.2.3.4 --dport 80 --tcp-flags > > SYN,ACK,RST,FIN SYN -j SYNPROXY > > > > and sending a SYN packet to port 80: > > hping3 -S -d 64 1.2.3.4 -p 80 > > > > I get kernel panic: > > http://goo.gl/L6dCz6 > > > > I'm using kernel v3.12.2 and iptables v1.4.21. Am I doing something wrong, > > or is it a bug? > > You have to run this from the INPUT/FORWARD chain, SYNPROXY needs the > routing information to work. Let's fix that: From e5b31e75df3c3f9629900016a95336c04165d13f Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Sun, 8 Dec 2013 16:49:36 +0000 Subject: [PATCH] netfilter: SYNPROXY target: restrict to INPUT/FORWARD Fix a crash in synproxy_send_tcp() when using the SYNPROXY target in the PREROUTING chain caused by missing routing information. Reported-by: Nicki P. Signed-off-by: Patrick McHardy --- net/ipv4/netfilter/ipt_SYNPROXY.c | 1 + net/ipv6/netfilter/ip6t_SYNPROXY.c | 1 + 2 files changed, 2 insertions(+) diff --git a/net/ipv4/netfilter/ipt_SYNPROXY.c b/net/ipv4/netfilter/ipt_SYNPROXY.c index f13bd91..a313c3f 100644 --- a/net/ipv4/netfilter/ipt_SYNPROXY.c +++ b/net/ipv4/netfilter/ipt_SYNPROXY.c @@ -423,6 +423,7 @@ static void synproxy_tg4_destroy(const struct xt_tgdtor_param *par) static struct xt_target synproxy_tg4_reg __read_mostly = { .name = "SYNPROXY", .family = NFPROTO_IPV4, + .hooks = (1 << NF_INET_LOCAL_IN) | (1 << NF_INET_FORWARD), .target = synproxy_tg4, .targetsize = sizeof(struct xt_synproxy_info), .checkentry = synproxy_tg4_check, diff --git a/net/ipv6/netfilter/ip6t_SYNPROXY.c b/net/ipv6/netfilter/ip6t_SYNPROXY.c index f78f41a..a0d1727 100644 --- a/net/ipv6/netfilter/ip6t_SYNPROXY.c +++ b/net/ipv6/netfilter/ip6t_SYNPROXY.c @@ -446,6 +446,7 @@ static void synproxy_tg6_destroy(const struct xt_tgdtor_param *par) static struct xt_target synproxy_tg6_reg __read_mostly = { .name = "SYNPROXY", .family = NFPROTO_IPV6, + .hooks = (1 << NF_INET_LOCAL_IN) | (1 << NF_INET_FORWARD), .target = synproxy_tg6, .targetsize = sizeof(struct xt_synproxy_info), .checkentry = synproxy_tg6_check,