netfilter fixes for net
Subsystems (4)
Pablo Neira Ayuso
maintainercover netfilter fixes for net
Hi David!
The following patchset contains fixes for your net tree, they are:
* Remove extra quote from connlimit configuration in Kconfig, from Randy Dunlap.
* Fix missing mss option in syn packets sent to the backend in our new synproxy target, from Martin Topholm.
* Use window scale announced by client when sending the forged syn to the backend, from Martin Topholm.
* Fix IPv6 address comparison in ebtables, from Luís Fernando Cornachioni Estrozi.
* Fix wrong endianess in sequence adjustment which breaks helpers in NAT configurations, from Phil Oester.
* Fix the error path handling of nft_compat, from me.
* Make sure the global conntrack counter is decremented after the object has been released, also from me.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git master
Thanks!
----------------------------------------------------------------
The following changes since commit 42a2d923cc349583ebf6fdd52a7d35e1c2f7e6bd:
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next (2013-11-13 17:40:34 +0900)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git master
for you to fetch changes up to acab78b99633f12aa2b697474562e19c5718a1ca:
netfilter: ebt_ip6: fix source and destination matching (2013-11-19 15:33:29 +0100)
----------------------------------------------------------------
Luís Fernando Cornachioni Estrozi (1):
netfilter: ebt_ip6: fix source and destination matching
Martin Topholm (2):
netfilter: synproxy: send mss option to backend
netfilter: synproxy: correct wscale option passing
Pablo Neira Ayuso (2):
netfilter: nft_compat: fix error path in nft_parse_compat()
netfilter: nf_conntrack: decrement global counter after object release
Phil Oester (1):
netfilter: fix wrong byte order in nf_ct_seqadj_set internal information
Randy Dunlap (1):
netfilter: fix connlimit Kconfig prompt string
net/bridge/netfilter/ebt_ip6.c | 8 +++++--- net/ipv4/netfilter/ipt_SYNPROXY.c | 1 + net/ipv6/netfilter/ip6t_SYNPROXY.c | 1 + net/netfilter/Kconfig | 2 +- net/netfilter/nf_conntrack_core.c | 3 ++- net/netfilter/nf_conntrack_seqadj.c | 4 ++-- net/netfilter/nf_synproxy_core.c | 7 ++++--- net/netfilter/nft_compat.c | 19 +++++++++++++------ 8 files changed, 29 insertions(+), 16 deletions(-)
Pablo Neira Ayuso
maintainerPATCH 1/7 netfilter: fix connlimit Kconfig prompt string
From: Randy Dunlap <[email protected]>
Under Core Netfilter Configuration, connlimit match support has an extra double quote at the end of it.
Fixes a portion of kernel bugzilla #52671:
https://bugzilla.kernel.org/show_bug.cgi?id=52671
--- net/netfilter/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/Kconfig +1 -1
@@ -909,7 +909,7 @@ config NETFILTER_XT_MATCH_CONNLABEL connection simultaneously. config NETFILTER_XT_MATCH_CONNLIMIT - tristate '"connlimit" match support"' + tristate '"connlimit" match support' depends on NF_CONNTRACK depends on NETFILTER_ADVANCED ---help---
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 2/7 netfilter: synproxy: send mss option to backend
In reply to Pablo Neira AyusoFrom: Martin Topholm <[email protected]>
When the synproxy_parse_options is called on the client ack the mss option will not be present. Consequently mss wont be included in the backend syn packet, which falls back to 536 bytes mss.
Therefore XT_SYNPROXY_OPT_MSS is explicitly flagged when recovering mss value from cookie.
--- net/ipv4/netfilter/ipt_SYNPROXY.c | 1 + net/ipv6/netfilter/ip6t_SYNPROXY.c | 1 + 2 files changed, 2 insertions(+)
net/ipv4/netfilter/ipt_SYNPROXY.c +1 -0
@@ -244,6 +244,7 @@ synproxy_recv_client_ack(const struct synproxy_net *snet,this_cpu_inc (snet->stats->cookie_valid); opts->mss = mss; + opts->options |=XT_SYNPROXY_OPT_MSS ;if (opts->options &XT_SYNPROXY_OPT_TIMESTAMP )synproxy_check_timestamp_cookie (opts);
net/ipv6/netfilter/ip6t_SYNPROXY.c +1 -0
@@ -259,6 +259,7 @@ synproxy_recv_client_ack(const struct synproxy_net *snet,this_cpu_inc (snet->stats->cookie_valid); opts->mss = mss; + opts->options |=XT_SYNPROXY_OPT_MSS ;if (opts->options &XT_SYNPROXY_OPT_TIMESTAMP )synproxy_check_timestamp_cookie (opts);
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 3/7 netfilter: synproxy: correct wscale option passing
In reply to Pablo Neira AyusoFrom: Martin Topholm <[email protected]>
Timestamp are used to store additional syncookie parameters such as sack, ecn, and wscale. The wscale value we need to encode is the client's wscale, since we can't recover that later in the session. Next overwrite the wscale option so the later synproxy_send_client_synack will send the backend's wscale to the client.
--- net/netfilter/nf_synproxy_core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/netfilter/nf_synproxy_core.c +4 -3
@@ -151,9 +151,10 @@ void synproxy_init_timestamp_cookie(const struct xt_synproxy_info *info, opts->tsecr = opts->tsval; opts->tsval = tcp_time_stamp & ~0x3f ; -if (opts->options &XT_SYNPROXY_OPT_WSCALE ) - opts->tsval |= info->wscale; -else +if (opts->options &XT_SYNPROXY_OPT_WSCALE ) { + opts->tsval |= opts->wscale; + opts->wscale = info->wscale; + }else opts->tsval |=0xf ;if (opts->options &XT_SYNPROXY_OPT_SACK_PERM )
Signature · 1 line
1.7.10.4
Re: [PATCH 3/7] netfilter: synproxy: correct wscale option passing
Hello.
Quoted 21 lines · Pablo Neira Ayuso
From: Martin Topholm <[email protected]>
Timestamp are used to store additional syncookie parameters such as sack, ecn, and wscale. The wscale value we need to encode is the client's wscale, since we can't recover that later in the session. Next overwrite the wscale option so the later
synproxy_send_client_synackwill send the backend's wscale to the client.Signed-off-by Martin Topholm <[email protected]>Reviewed-by Jesper Dangaard Brouer <[email protected]>Signed-off-by Pablo Neira Ayuso <[email protected]>--- net/netfilter/nf_synproxy_core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)net/netfilter/nf_synproxy_core.c +0
-0@@ -151,9 +151,10 @@ void synproxy_init_timestamp_cookie(const struct xt_synproxy_info *info, opts->tsecr = opts->tsval;
net/netfilter/nf_synproxy_core.c void synproxy_init_timestamp_cookie(const struct xt_synproxy_info *info, · line 158
Quoted 10 lines
net/netfilter/nf_synproxy_core.c +4
-3opts->tsval = tcp_time_stamp & ~0x3f ; -if (opts->options &XT_SYNPROXY_OPT_WSCALE ) - opts->tsval |= info->wscale; -else +if (opts->options &XT_SYNPROXY_OPT_WSCALE ) { + opts->tsval |= opts->wscale; + opts->wscale = info->wscale; + }else opts->tsval |=0xf ;
According to Documentation/CodingStyle, both arms of *if* statement should
have {} if one arm has it.
WBR, Sergei
Pablo Neira Ayuso
maintainerPATCH 4/7 netfilter: fix wrong byte order in nf_ct_seqadj_set internal information
In reply to Pablo Neira AyusoFrom: Phil Oester <[email protected]>
In commit 41d73ec053d2, sequence number adjustments were moved to a separate file. Unfortunately, the sequence numbers that are stored in the nf_ct_seqadj structure are expressed in host byte order. The necessary ntohl call was removed when the call to adjust_tcp_sequence was collapsed into nf_ct_seqadj_set. This broke the FTP NAT helper. Fix it by adding back the byte order conversions.
--- net/netfilter/nf_conntrack_seqadj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_seqadj.c +2 -2
@@ -41,8 +41,8 @@ int nf_ct_seqadj_set(struct nf_conn *ct, enum ip_conntrack_info ctinfo,spin_lock_bh (&ct->lock); this_way = &seqadj->seq[dir];if (this_way->offset_before == this_way->offset_after || -before (this_way->correction_pos, seq)) { - this_way->correction_pos = seq; +before (this_way->correction_pos,ntohl (seq))) { + this_way->correction_pos =ntohl (seq); this_way->offset_before = this_way->offset_after; this_way->offset_after += off; }
Signature · 1 line
1.7.10.4
Re: [PATCH 4/7] netfilter: fix wrong byte order in nf_ct_seqadj_set internal information
Hello.
Quoted 3 lines · Pablo Neira Ayuso
From: Phil Oester <[email protected]>
In commit
41d73ec053d2, sequence number adjustments were moved to a
Please also specify that commit's summary line in parens.
Quoted 9 lines
separate file. Unfortunately, the sequence numbers that are stored in the
nf_ct_seqadjstructure are expressed in host byte order. The necessary ntohl call was removed when the call toadjust_tcp_sequencewas collapsed intonf_ct_seqadj_set. This broke the FTP NAT helper. Fix it by adding back the byte order conversions.Reported-by Dawid Stawiarski <[email protected]>Signed-off-by Phil Oester <[email protected]>Signed-off-by Pablo Neira Ayuso <[email protected]>
WBR, Sergei
Pablo Neira Ayuso
maintainerPATCH 5/7 netfilter: nft_compat: fix error path in nft_parse_compat()
In reply to Pablo Neira AyusoThe patch 0ca743a55991: "netfilter: nf_tables: add compatibility layer for x_tables", leads to the following Smatch
warning: "net/netfilter/nft_compat.c:140 nft_parse_compat()
warn: signedness bug returning '(-34)'"
This nft_parse_compat function returns error codes but the return type is u8 so the error codes are transformed into small positive values. The callers don't check the return.
--- net/netfilter/nft_compat.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
net/netfilter/nft_compat.c +13 -6
@@ -128,7 +128,7 @@ static const struct nla_policy nft_rule_compat_policy[NFTA_RULE_COMPAT_MAX + 1] [NFTA_RULE_COMPAT_FLAGS] = { .type = NLA_U32 }, }; -static u8 nft_parse_compat (const struct nlattr *attr,bool *inv) +static int nft_parse_compat (const struct nlattr *attr,u8 *proto,bool *inv) {struct nlattr *tb[NFTA_RULE_COMPAT_MAX +1 ];u32 flags;
@@ -148,7 +148,8 @@ static u8 nft_parse_compat(const struct nlattr *attr, bool *inv)if (flags &NFT_RULE_COMPAT_F_INV ) *inv = true; -return ntohl (nla_get_be32 (tb[NFTA_RULE_COMPAT_PROTO ])); + *proto =ntohl (nla_get_be32 (tb[NFTA_RULE_COMPAT_PROTO ])); +return 0 ; } static int
@@ -166,8 +167,11 @@ nft_target_init(const struct nft_ctx *ctx, const struct nft_expr *expr,target_compat_from_user (target,nla_data (tb[NFTA_TARGET_INFO ]), info); -if (ctx->nla[NFTA_RULE_COMPAT ]) - proto =nft_parse_compat (ctx->nla[NFTA_RULE_COMPAT ], &inv); +if (ctx->nla[NFTA_RULE_COMPAT ]) { + ret =nft_parse_compat (ctx->nla[NFTA_RULE_COMPAT ], &proto, &inv); +if (ret <0 ) + goto err; + }nft_target_set_tgchk_param (&par, ctx, target, info, &e, proto, inv);
@@ -356,8 +360,11 @@ nft_match_init(const struct nft_ctx *ctx, const struct nft_expr *expr,match_compat_from_user (match,nla_data (tb[NFTA_MATCH_INFO ]), info); -if (ctx->nla[NFTA_RULE_COMPAT ]) - proto =nft_parse_compat (ctx->nla[NFTA_RULE_COMPAT ], &inv); +if (ctx->nla[NFTA_RULE_COMPAT ]) { + ret =nft_parse_compat (ctx->nla[NFTA_RULE_COMPAT ], &proto, &inv); +if (ret <0 ) + goto err; + }nft_match_set_mtchk_param (&par, ctx, match, info, &e, proto, inv);
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 6/7 netfilter: nf_conntrack: decrement global counter after object release
In reply to Pablo Neira Ayusonf_conntrack_free() decrements our counter (net->ct.count) before releasing the conntrack object. That counter is used in the nf_conntrack_cleanup_net_list path to check if it's time to kmem_cache_destroy our cache of conntrack objects. I think we have a race there that should be easier to trigger (although still hard) with CONFIG_DEBUG_OBJECTS_FREE as object releases become slowier according to the following splat:
[ 1136.321305] WARNING: CPU: 2 PID: 2483 at lib/debugobjects.c:260 debug_print_object+0x83/0xa0() [ 1136.321311] ODEBUG: free active (active state 0) object type: timer_list hint: delayed_work_timer_fn+0x0/0x20 ... [ 1136.321390] Call Trace: [ 1136.321398] [<ffffffff8160d4a2>] dump_stack+0x45/0x56 [ 1136.321405] [<ffffffff810514e8>] warn_slowpath_common+0x78/0xa0 [ 1136.321410] [<ffffffff81051557>] warn_slowpath_fmt+0x47/0x50 [ 1136.321414] [<ffffffff812f8883>] debug_print_object+0x83/0xa0 [ 1136.321420] [<ffffffff8106aa90>] ? execute_in_process_context+0x90/0x90 [ 1136.321424] [<ffffffff812f99fb>] debug_check_no_obj_freed+0x20b/0x250 [ 1136.321429] [<ffffffff8112e7f2>] ? kmem_cache_destroy+0x92/0x100 [ 1136.321433] [<ffffffff8115d945>] kmem_cache_free+0x125/0x210 [ 1136.321436] [<ffffffff8112e7f2>] kmem_cache_destroy+0x92/0x100 [ 1136.321443] [<ffffffffa046b806>] nf_conntrack_cleanup_net_list+0x126/0x160 [nf_conntrack] [ 1136.321449] [<ffffffffa046c43d>] nf_conntrack_pernet_exit+0x6d/0x80 [nf_conntrack] [ 1136.321453] [<ffffffff81511cc3>] ops_exit_list.isra.3+0x53/0x60 [ 1136.321457] [<ffffffff815124f0>] cleanup_net+0x100/0x1b0 [ 1136.321460] [<ffffffff8106b31e>] process_one_work+0x18e/0x430 [ 1136.321463] [<ffffffff8106bf49>] worker_thread+0x119/0x390 [ 1136.321467] [<ffffffff8106be30>] ? manage_workers.isra.23+0x2a0/0x2a0 [ 1136.321470] [<ffffffff8107210b>] kthread+0xbb/0xc0 [ 1136.321472] [<ffffffff81072050>] ? kthread_create_on_node+0x110/0x110 [ 1136.321477] [<ffffffff8161b8fc>] ret_from_fork+0x7c/0xb0 [ 1136.321479] [<ffffffff81072050>] ? kthread_create_on_node+0x110/0x110 [ 1136.321481] ---[ end trace 25f53c192da70825 ]---
--- net/netfilter/nf_conntrack_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/netfilter/nf_conntrack_core.c +2 -1
@@ -764,9 +764,10 @@ void nf_conntrack_free(struct nf_conn *ct)struct net *net =nf_ct_net (ct);nf_ct_ext_destroy (ct); -atomic_dec (&net->ct.count);nf_ct_ext_free (ct);kmem_cache_free (net->ct.nf_conntrack_cachep, ct); +smp_mb__before_atomic_dec (); +atomic_dec (&net->ct.count); }EXPORT_SYMBOL_GPL (nf_conntrack_free);
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 7/7 netfilter: ebt_ip6: fix source and destination matching
In reply to Pablo Neira AyusoFrom: Luís Fernando Cornachioni Estrozi <[email protected]>
This bug was introduced on commit 0898f99a2. This just recovers two checks that existed before as suggested by Bart De Schuymer.
--- net/bridge/netfilter/ebt_ip6.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/bridge/netfilter/ebt_ip6.c +5 -3
@@ -48,10 +48,12 @@ ebt_ip6_mt(const struct sk_buff *skb, struct xt_action_param *par)if (info->bitmask &EBT_IP6_TCLASS &&FWINV (info->tclass !=ipv6_get_dsfield (ih6),EBT_IP6_TCLASS ))return false; -if (FWINV (ipv6_masked_addr_cmp (&ih6->saddr, &info->smsk, - &info->saddr),EBT_IP6_SOURCE ) || +if ((info->bitmask &EBT_IP6_SOURCE && +FWINV (ipv6_masked_addr_cmp (&ih6->saddr, &info->smsk, + &info->saddr),EBT_IP6_SOURCE )) || + (info->bitmask &EBT_IP6_DEST &&FWINV (ipv6_masked_addr_cmp (&ih6->daddr, &info->dmsk, - &info->daddr),EBT_IP6_DEST )) + &info->daddr),EBT_IP6_DEST )))return false;if (info->bitmask &EBT_IP6_PROTO ) {uint8_t nexthdr = ih6->nexthdr;
Signature · 6 lines
1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
David Miller
maintainerFrom: Pablo Neira Ayuso <[email protected]>
Date: Thu, 21 Nov 2013 10:05:21 +0100
Quoted 14 lines
The following patchset contains fixes for your net tree, they are:
* Remove extra quote from connlimit configuration in
Kconfig, from Randy Dunlap.* Fix missing mss option in syn packets sent to the backend in our new synproxy target, from Martin Topholm.
* Use window scale announced by client when sending the forged syn to the backend, from Martin Topholm.
* Fix IPv6 address comparison in ebtables, from Luís Fernando Cornachioni Estrozi.
Quoted 7 lines
* Fix wrong endianess in sequence adjustment which breaks helpers in NAT configurations, from Phil Oester.
* Fix the error path handling of
nft_compat, from me.* Make sure the global conntrack counter is decremented after the object has been released, also from me.
Pulled, thanks a lot Pablo.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html