* [PATCH 0/8] Netfilter/IPVS fixes for net
@ 2013-12-28 22:02 Pablo Neira Ayuso
2013-12-29 5:29 ` David Miller
0 siblings, 1 reply; 13+ messages in thread
From: Pablo Neira Ayuso @ 2013-12-28 22:02 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
Hi David,
This patchset contains four nf_tables fixes, one IPVS fix due to
missing updates in the interaction with the new sedadj conntrack
extension that was added to support the netfilter synproxy code,
and a couple of one-liners to fix netnamespace netfilter issues.
More specifically, they are:
* Fix ipv6_find_hdr() call without offset being explicitly initialized
in nft_exthdr, as required by that function, from Daniel Borkmann.
* Fix oops in nfnetlink_log when using netns and unloading the kernel
module, from Gao feng.
* Fix BUG_ON in nf_ct_timestamp extension after netns is destroyed,
from Helmut Schaa.
* Fix crash in IPVS due to missing sequence adjustment extension being
allocated in the conntrack, from Jesper Dangaard Brouer.
* Add bugtrap to spot a warning in case you deference sequence adjustment
conntrack area when not available, this should help to catch similar
invalid dereferences in the Netfilter tree, also from Jesper.
* Fix incomple dumping of sets in nf_tables when retrieving by family,
from me.
* Fix oops when updating the table state (dormant <-> active) and having
user (not base ) chains, from me.
* Fix wrong validation in set element data that results in returning
-EINVAL when using the nf_tables dictionary feature with mappings,
also from me.
We don't usually have this amount of fixes by this time (as we're already
in -rc5 of the development cycle), although half of them are related to
nf_tables which is a relatively new thing, and I also belive that holidays
have also delayed the flight of bugfixes to mainstream a bit.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git master
Thanks!
P.S: Have a nice entrance to new year.
----------------------------------------------------------------
The following changes since commit a7c12639bdf571a09578aed626875848d209d24f:
Merge branch 'qlcnic' (2013-12-17 16:25:24 -0500)
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 2ee0d3c80fdb7974cfa1c7e25b5048e9fcaf69b6:
netfilter: nf_tables: fix wrong datatype in nft_validate_data_load() (2013-12-28 22:32:28 +0100)
----------------------------------------------------------------
Daniel Borkmann (1):
netfilter: nft_exthdr: call ipv6_find_hdr() with explicitly initialized offset
Gao feng (1):
netfilter: nfnetlink_log: unset nf_loggers for netns when unloading module
Helmut Schaa (1):
netfilter: nf_ct_timestamp: Fix BUG_ON after netns deletion
Jesper Dangaard Brouer (2):
netfilter: WARN about wrong usage of sequence number adjustments
ipvs: correct usage/allocation of seqadj ext in ipvs
Pablo Neira Ayuso (3):
netfilter: nf_tables: fix dumping with large number of sets
netfilter: nf_tables: fix oops when updating table with user chains
netfilter: nf_tables: fix wrong datatype in nft_validate_data_load()
net/netfilter/ipvs/ip_vs_nfct.c | 6 ++++++
net/netfilter/nf_conntrack_seqadj.c | 5 +++++
net/netfilter/nf_conntrack_timestamp.c | 1 -
net/netfilter/nf_tables_api.c | 26 ++++++++++++++++++++------
net/netfilter/nfnetlink_log.c | 1 +
net/netfilter/nft_exthdr.c | 2 +-
6 files changed, 33 insertions(+), 8 deletions(-)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/8] Netfilter/IPVS fixes for net
2013-12-28 22:02 Pablo Neira Ayuso
@ 2013-12-29 5:29 ` David Miller
0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2013-12-29 5:29 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel, netdev
From: Pablo Neira Ayuso <pablo@netfilter.org>
Date: Sat, 28 Dec 2013 23:02:59 +0100
> This patchset contains four nf_tables fixes, one IPVS fix due to
> missing updates in the interaction with the new sedadj conntrack
> extension that was added to support the netfilter synproxy code,
> and a couple of one-liners to fix netnamespace netfilter issues.
> More specifically, they are:
...
> We don't usually have this amount of fixes by this time (as we're already
> in -rc5 of the development cycle), although half of them are related to
> nf_tables which is a relatively new thing, and I also belive that holidays
> have also delayed the flight of bugfixes to mainstream a bit.
>
> You can pull these changes from:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git master
Pulled, thanks Pablo.
> P.S: Have a nice entrance to new year.
Same to you. :)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 0/8] Netfilter/IPVS fixes for net
@ 2014-11-14 16:58 Pablo Neira Ayuso
2014-11-14 16:58 ` Pablo Neira Ayuso
` (9 more replies)
0 siblings, 10 replies; 13+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-14 16:58 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
Hi David,
The following patchset contains Netfilter updates for your net tree,
they are:
1) Fix missing initialization of the range structure (allocated in the
stack) in nft_masq_{ipv4, ipv6}_eval, from Daniel Borkmann.
2) Make sure the data we receive from userspace contains the req_version
structure, otherwise return an error incomplete on truncated input.
From Dan Carpenter.
3) Fix handling og skb->sk which may cause incorrect handling
of connections from a local process. Via Simon Horman, patch from
Calvin Owens.
4) Fix wrong netns in nft_compat when setting target and match params
structure.
5) Relax chain type validation in nft_compat that was recently included,
this broke the matches that need to be run from the route chain type.
Now iptables-test.py automated regression tests report success again
and we avoid the only possible problematic case, which is the use of
nat targets out of nat chain type.
6) Use match->table to validate the tablename, instead of the match->name.
Again patch for nft_compat.
7) Restore the synchronous release of objects from the commit and abort
path in nf_tables. This is causing two major problems: splats when using
nft_compat, given that matches and targets may sleep and call_rcu is
invoked from softirq context. Moreover Patrick reported possible event
notification reordering when rules refer to anonymous sets.
8) Fix race condition in between packets that are being confirmed by
conntrack and the ctnetlink flush operation. This happens since the
removal of the central spinlock. Thanks to Jesper D. Brouer to looking
into this.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thanks!
----------------------------------------------------------------
The following changes since commit d52fdbb735c36a209f36a628d40ca9185b349ba7:
smc91x: retrieve IRQ and trigger flags in a modern way (2014-11-01 17:04:20 -0400)
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 5195c14c8b27cc0b18220ddbf0e5ad3328a04187:
netfilter: conntrack: fix race in __nf_conntrack_confirm against get_next_corpse (2014-11-14 17:43:05 +0100)
----------------------------------------------------------------
Calvin Owens (1):
ipvs: Keep skb->sk when allocating headroom on tunnel xmit
Dan Carpenter (1):
netfilter: ipset: small potential read beyond the end of buffer
Daniel Borkmann (1):
netfilter: nft_masq: fix uninitialized range in nft_masq_{ipv4, ipv6}_eval
Pablo Neira Ayuso (4):
netfilter: nft_compat: use current net namespace
netfilter: nft_compat: relax chain type validation
netfilter: nft_compat: use the match->table to validate dependencies
netfilter: nf_tables: restore synchronous object release from commit/abort
bill bonaparte (1):
netfilter: conntrack: fix race in __nf_conntrack_confirm against get_next_corpse
include/net/netfilter/nf_tables.h | 2 --
net/ipv4/netfilter/nft_masq_ipv4.c | 1 +
net/ipv6/netfilter/nft_masq_ipv6.c | 1 +
net/netfilter/ipset/ip_set_core.c | 6 ++++++
net/netfilter/ipvs/ip_vs_xmit.c | 2 ++
net/netfilter/nf_conntrack_core.c | 14 +++++++------
net/netfilter/nf_tables_api.c | 24 ++++++++--------------
net/netfilter/nft_compat.c | 40 ++++++------------------------------
8 files changed, 32 insertions(+), 58 deletions(-)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 0/8] Netfilter/IPVS fixes for net
2014-11-14 16:58 [PATCH 0/8] Netfilter/IPVS fixes for net Pablo Neira Ayuso
@ 2014-11-14 16:58 ` Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 1/8] netfilter: nft_masq: fix uninitialized range in nft_masq_{ipv4, ipv6}_eval Pablo Neira Ayuso
` (8 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-14 16:58 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
Hi David,
The following patchset contains Netfilter updates for your net tree,
they are:
1) Fix missing initialization of the range structure (allocated in the
stack) in nft_masq_{ipv4, ipv6}_eval, from Daniel Borkmann.
2) Make sure the data we receive from userspace contains the req_version
structure, otherwise return an error incomplete on truncated input.
From Dan Carpenter.
3) Fix handling og skb->sk which may cause incorrect handling
of connections from a local process. Via Simon Horman, patch from
Calvin Owens.
4) Fix wrong netns in nft_compat when setting target and match params
structure.
5) Relax chain type validation in nft_compat that was recently included,
this broke the matches that need to be run from the route chain type.
Now iptables-test.py automated regression tests report success again
and we avoid the only possible problematic case, which is the use of
nat targets out of nat chain type.
6) Use match->table to validate the tablename, instead of the match->name.
Again patch for nft_compat.
7) Restore the synchronous release of objects from the commit and abort
path in nf_tables. This is causing two major problems: splats when using
nft_compat, given that matches and targets may sleep and call_rcu is
invoked from softirq context. Moreover Patrick reported possible event
notification reordering when rules refer to anonymous sets.
8) Fix race condition in between packets that are being confirmed by
conntrack and the ctnetlink flush operation. This happens since the
removal of the central spinlock. Thanks to Jesper D. Brouer to looking
into this.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thanks!
----------------------------------------------------------------
The following changes since commit d52fdbb735c36a209f36a628d40ca9185b349ba7:
smc91x: retrieve IRQ and trigger flags in a modern way (2014-11-01 17:04:20 -0400)
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 5195c14c8b27cc0b18220ddbf0e5ad3328a04187:
netfilter: conntrack: fix race in __nf_conntrack_confirm against get_next_corpse (2014-11-14 17:43:05 +0100)
----------------------------------------------------------------
Calvin Owens (1):
ipvs: Keep skb->sk when allocating headroom on tunnel xmit
Dan Carpenter (1):
netfilter: ipset: small potential read beyond the end of buffer
Daniel Borkmann (1):
netfilter: nft_masq: fix uninitialized range in nft_masq_{ipv4, ipv6}_eval
Pablo Neira Ayuso (4):
netfilter: nft_compat: use current net namespace
netfilter: nft_compat: relax chain type validation
netfilter: nft_compat: use the match->table to validate dependencies
netfilter: nf_tables: restore synchronous object release from commit/abort
bill bonaparte (1):
netfilter: conntrack: fix race in __nf_conntrack_confirm against get_next_corpse
include/net/netfilter/nf_tables.h | 2 --
net/ipv4/netfilter/nft_masq_ipv4.c | 1 +
net/ipv6/netfilter/nft_masq_ipv6.c | 1 +
net/netfilter/ipset/ip_set_core.c | 6 ++++++
net/netfilter/ipvs/ip_vs_xmit.c | 2 ++
net/netfilter/nf_conntrack_core.c | 14 +++++++------
net/netfilter/nf_tables_api.c | 24 ++++++++--------------
net/netfilter/nft_compat.c | 40 ++++++------------------------------
8 files changed, 32 insertions(+), 58 deletions(-)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/8] netfilter: nft_masq: fix uninitialized range in nft_masq_{ipv4, ipv6}_eval
2014-11-14 16:58 [PATCH 0/8] Netfilter/IPVS fixes for net Pablo Neira Ayuso
2014-11-14 16:58 ` Pablo Neira Ayuso
@ 2014-11-14 16:58 ` Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 2/8] netfilter: ipset: small potential read beyond the end of buffer Pablo Neira Ayuso
` (7 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-14 16:58 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
From: Daniel Borkmann <dborkman@redhat.com>
When transferring from the original range in nf_nat_masquerade_{ipv4,ipv6}()
we copy over values from stack in from min_proto/max_proto due to uninitialized
range variable in both, nft_masq_{ipv4,ipv6}_eval. As we only initialize
flags at this time from nft_masq struct, just zero out the rest.
Fixes: 9ba1f726bec09 ("netfilter: nf_tables: add new nft_masq expression")
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Acked-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/ipv4/netfilter/nft_masq_ipv4.c | 1 +
net/ipv6/netfilter/nft_masq_ipv6.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/net/ipv4/netfilter/nft_masq_ipv4.c b/net/ipv4/netfilter/nft_masq_ipv4.c
index c1023c4..665de06 100644
--- a/net/ipv4/netfilter/nft_masq_ipv4.c
+++ b/net/ipv4/netfilter/nft_masq_ipv4.c
@@ -24,6 +24,7 @@ static void nft_masq_ipv4_eval(const struct nft_expr *expr,
struct nf_nat_range range;
unsigned int verdict;
+ memset(&range, 0, sizeof(range));
range.flags = priv->flags;
verdict = nf_nat_masquerade_ipv4(pkt->skb, pkt->ops->hooknum,
diff --git a/net/ipv6/netfilter/nft_masq_ipv6.c b/net/ipv6/netfilter/nft_masq_ipv6.c
index 8a7ac68..529c119 100644
--- a/net/ipv6/netfilter/nft_masq_ipv6.c
+++ b/net/ipv6/netfilter/nft_masq_ipv6.c
@@ -25,6 +25,7 @@ static void nft_masq_ipv6_eval(const struct nft_expr *expr,
struct nf_nat_range range;
unsigned int verdict;
+ memset(&range, 0, sizeof(range));
range.flags = priv->flags;
verdict = nf_nat_masquerade_ipv6(pkt->skb, &range, pkt->out);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/8] netfilter: ipset: small potential read beyond the end of buffer
2014-11-14 16:58 [PATCH 0/8] Netfilter/IPVS fixes for net Pablo Neira Ayuso
2014-11-14 16:58 ` Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 1/8] netfilter: nft_masq: fix uninitialized range in nft_masq_{ipv4, ipv6}_eval Pablo Neira Ayuso
@ 2014-11-14 16:58 ` Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 3/8] ipvs: Keep skb->sk when allocating headroom on tunnel xmit Pablo Neira Ayuso
` (6 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-14 16:58 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
From: Dan Carpenter <dan.carpenter@oracle.com>
We could be reading 8 bytes into a 4 byte buffer here. It seems
harmless but adding a check is the right thing to do and it silences a
static checker warning.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/ipset/ip_set_core.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index 86f9d76..d259da3 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -1863,6 +1863,12 @@ ip_set_sockfn_get(struct sock *sk, int optval, void __user *user, int *len)
if (*op < IP_SET_OP_VERSION) {
/* Check the version at the beginning of operations */
struct ip_set_req_version *req_version = data;
+
+ if (*len < sizeof(struct ip_set_req_version)) {
+ ret = -EINVAL;
+ goto done;
+ }
+
if (req_version->version != IPSET_PROTOCOL) {
ret = -EPROTO;
goto done;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/8] ipvs: Keep skb->sk when allocating headroom on tunnel xmit
2014-11-14 16:58 [PATCH 0/8] Netfilter/IPVS fixes for net Pablo Neira Ayuso
` (2 preceding siblings ...)
2014-11-14 16:58 ` [PATCH 2/8] netfilter: ipset: small potential read beyond the end of buffer Pablo Neira Ayuso
@ 2014-11-14 16:58 ` Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 4/8] netfilter: nft_compat: use current net namespace Pablo Neira Ayuso
` (5 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-14 16:58 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
From: Calvin Owens <calvinowens@fb.com>
ip_vs_prepare_tunneled_skb() ignores ->sk when allocating a new
skb, either unconditionally setting ->sk to NULL or allowing
the uninitialized ->sk from a newly allocated skb to leak through
to the caller.
This patch properly copies ->sk and increments its reference count.
Signed-off-by: Calvin Owens <calvinowens@fb.com>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
net/netfilter/ipvs/ip_vs_xmit.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index 437a366..bd90bf8 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -846,6 +846,8 @@ ip_vs_prepare_tunneled_skb(struct sk_buff *skb, int skb_af,
new_skb = skb_realloc_headroom(skb, max_headroom);
if (!new_skb)
goto error;
+ if (skb->sk)
+ skb_set_owner_w(new_skb, skb->sk);
consume_skb(skb);
skb = new_skb;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/8] netfilter: nft_compat: use current net namespace
2014-11-14 16:58 [PATCH 0/8] Netfilter/IPVS fixes for net Pablo Neira Ayuso
` (3 preceding siblings ...)
2014-11-14 16:58 ` [PATCH 3/8] ipvs: Keep skb->sk when allocating headroom on tunnel xmit Pablo Neira Ayuso
@ 2014-11-14 16:58 ` Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 5/8] netfilter: nft_compat: relax chain type validation Pablo Neira Ayuso
` (4 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-14 16:58 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
Instead of init_net when using xtables over nftables compat.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nft_compat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index 9d6d6f6..b92f129 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -117,7 +117,7 @@ nft_target_set_tgchk_param(struct xt_tgchk_param *par,
struct xt_target *target, void *info,
union nft_entry *entry, u8 proto, bool inv)
{
- par->net = &init_net;
+ par->net = ctx->net;
par->table = ctx->table->name;
switch (ctx->afi->family) {
case AF_INET:
@@ -324,7 +324,7 @@ nft_match_set_mtchk_param(struct xt_mtchk_param *par, const struct nft_ctx *ctx,
struct xt_match *match, void *info,
union nft_entry *entry, u8 proto, bool inv)
{
- par->net = &init_net;
+ par->net = ctx->net;
par->table = ctx->table->name;
switch (ctx->afi->family) {
case AF_INET:
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 5/8] netfilter: nft_compat: relax chain type validation
2014-11-14 16:58 [PATCH 0/8] Netfilter/IPVS fixes for net Pablo Neira Ayuso
` (4 preceding siblings ...)
2014-11-14 16:58 ` [PATCH 4/8] netfilter: nft_compat: use current net namespace Pablo Neira Ayuso
@ 2014-11-14 16:58 ` Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 6/8] netfilter: nft_compat: use the match->table to validate dependencies Pablo Neira Ayuso
` (3 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-14 16:58 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
Check for nat chain dependency only, which is the one that can
actually crash the kernel. Don't care if mangle, filter and security
specific match and targets are used out of their scope, they are
harmless.
This restores iptables-compat with mangle specific match/target when
used out of the OUTPUT chain, that are actually emulated through filter
chains, which broke when performing strict validation.
Fixes: f3f5dde ("netfilter: nft_compat: validate chain type in match/target")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nft_compat.c | 32 ++------------------------------
1 file changed, 2 insertions(+), 30 deletions(-)
diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index b92f129..70dc965 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -21,45 +21,17 @@
#include <linux/netfilter_ipv6/ip6_tables.h>
#include <net/netfilter/nf_tables.h>
-static const struct {
- const char *name;
- u8 type;
-} table_to_chaintype[] = {
- { "filter", NFT_CHAIN_T_DEFAULT },
- { "raw", NFT_CHAIN_T_DEFAULT },
- { "security", NFT_CHAIN_T_DEFAULT },
- { "mangle", NFT_CHAIN_T_ROUTE },
- { "nat", NFT_CHAIN_T_NAT },
- { },
-};
-
-static int nft_compat_table_to_chaintype(const char *table)
-{
- int i;
-
- for (i = 0; table_to_chaintype[i].name != NULL; i++) {
- if (strcmp(table_to_chaintype[i].name, table) == 0)
- return table_to_chaintype[i].type;
- }
-
- return -1;
-}
-
static int nft_compat_chain_validate_dependency(const char *tablename,
const struct nft_chain *chain)
{
- enum nft_chain_type type;
const struct nft_base_chain *basechain;
if (!tablename || !(chain->flags & NFT_BASE_CHAIN))
return 0;
- type = nft_compat_table_to_chaintype(tablename);
- if (type < 0)
- return -EINVAL;
-
basechain = nft_base_chain(chain);
- if (basechain->type->type != type)
+ if (strcmp(tablename, "nat") == 0 &&
+ basechain->type->type != NFT_CHAIN_T_NAT)
return -EINVAL;
return 0;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 6/8] netfilter: nft_compat: use the match->table to validate dependencies
2014-11-14 16:58 [PATCH 0/8] Netfilter/IPVS fixes for net Pablo Neira Ayuso
` (5 preceding siblings ...)
2014-11-14 16:58 ` [PATCH 5/8] netfilter: nft_compat: relax chain type validation Pablo Neira Ayuso
@ 2014-11-14 16:58 ` Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 7/8] netfilter: nf_tables: restore synchronous object release from commit/abort Pablo Neira Ayuso
` (2 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-14 16:58 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
Instead of the match->name, which is of course not relevant.
Fixes: f3f5dde ("netfilter: nft_compat: validate chain type in match/target")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nft_compat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index 70dc965..265e190 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -346,7 +346,7 @@ nft_match_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
union nft_entry e = {};
int ret;
- ret = nft_compat_chain_validate_dependency(match->name, ctx->chain);
+ ret = nft_compat_chain_validate_dependency(match->table, ctx->chain);
if (ret < 0)
goto err;
@@ -420,7 +420,7 @@ static int nft_match_validate(const struct nft_ctx *ctx,
if (!(hook_mask & match->hooks))
return -EINVAL;
- ret = nft_compat_chain_validate_dependency(match->name,
+ ret = nft_compat_chain_validate_dependency(match->table,
ctx->chain);
if (ret < 0)
return ret;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 7/8] netfilter: nf_tables: restore synchronous object release from commit/abort
2014-11-14 16:58 [PATCH 0/8] Netfilter/IPVS fixes for net Pablo Neira Ayuso
` (6 preceding siblings ...)
2014-11-14 16:58 ` [PATCH 6/8] netfilter: nft_compat: use the match->table to validate dependencies Pablo Neira Ayuso
@ 2014-11-14 16:58 ` Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 8/8] netfilter: conntrack: fix race in __nf_conntrack_confirm against get_next_corpse Pablo Neira Ayuso
2014-11-16 19:24 ` [PATCH 0/8] Netfilter/IPVS fixes for net David Miller
9 siblings, 0 replies; 13+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-14 16:58 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
The existing xtables matches and targets, when used from nft_compat, may
sleep from the destroy path, ie. when removing rules. Since the objects
are released via call_rcu from softirq context, this results in lockdep
splats and possible lockups that may be hard to reproduce.
Patrick also indicated that delayed object release via call_rcu can
cause us problems in the ordering of event notifications when anonymous
sets are in place.
So, this patch restores the synchronous object release from the commit
and abort paths. This includes a call to synchronize_rcu() to make sure
that no packets are walking on the objects that are going to be
released. This is slowier though, but it's simple and it resolves the
aforementioned problems.
This is a partial revert of c7c32e7 ("netfilter: nf_tables: defer all
object release via rcu") that was introduced in 3.16 to speed up
interaction with userspace.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
include/net/netfilter/nf_tables.h | 2 --
net/netfilter/nf_tables_api.c | 24 ++++++++----------------
2 files changed, 8 insertions(+), 18 deletions(-)
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 845c596..3ae969e 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -396,14 +396,12 @@ struct nft_rule {
/**
* struct nft_trans - nf_tables object update in transaction
*
- * @rcu_head: rcu head to defer release of transaction data
* @list: used internally
* @msg_type: message type
* @ctx: transaction context
* @data: internal information related to the transaction
*/
struct nft_trans {
- struct rcu_head rcu_head;
struct list_head list;
int msg_type;
struct nft_ctx ctx;
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 11ab4b0..66e8425 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -3484,13 +3484,8 @@ static void nft_chain_commit_update(struct nft_trans *trans)
}
}
-/* Schedule objects for release via rcu to make sure no packets are accesing
- * removed rules.
- */
-static void nf_tables_commit_release_rcu(struct rcu_head *rt)
+static void nf_tables_commit_release(struct nft_trans *trans)
{
- struct nft_trans *trans = container_of(rt, struct nft_trans, rcu_head);
-
switch (trans->msg_type) {
case NFT_MSG_DELTABLE:
nf_tables_table_destroy(&trans->ctx);
@@ -3612,10 +3607,11 @@ static int nf_tables_commit(struct sk_buff *skb)
}
}
+ synchronize_rcu();
+
list_for_each_entry_safe(trans, next, &net->nft.commit_list, list) {
list_del(&trans->list);
- trans->ctx.nla = NULL;
- call_rcu(&trans->rcu_head, nf_tables_commit_release_rcu);
+ nf_tables_commit_release(trans);
}
nf_tables_gen_notify(net, skb, NFT_MSG_NEWGEN);
@@ -3623,13 +3619,8 @@ static int nf_tables_commit(struct sk_buff *skb)
return 0;
}
-/* Schedule objects for release via rcu to make sure no packets are accesing
- * aborted rules.
- */
-static void nf_tables_abort_release_rcu(struct rcu_head *rt)
+static void nf_tables_abort_release(struct nft_trans *trans)
{
- struct nft_trans *trans = container_of(rt, struct nft_trans, rcu_head);
-
switch (trans->msg_type) {
case NFT_MSG_NEWTABLE:
nf_tables_table_destroy(&trans->ctx);
@@ -3725,11 +3716,12 @@ static int nf_tables_abort(struct sk_buff *skb)
}
}
+ synchronize_rcu();
+
list_for_each_entry_safe_reverse(trans, next,
&net->nft.commit_list, list) {
list_del(&trans->list);
- trans->ctx.nla = NULL;
- call_rcu(&trans->rcu_head, nf_tables_abort_release_rcu);
+ nf_tables_abort_release(trans);
}
return 0;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 8/8] netfilter: conntrack: fix race in __nf_conntrack_confirm against get_next_corpse
2014-11-14 16:58 [PATCH 0/8] Netfilter/IPVS fixes for net Pablo Neira Ayuso
` (7 preceding siblings ...)
2014-11-14 16:58 ` [PATCH 7/8] netfilter: nf_tables: restore synchronous object release from commit/abort Pablo Neira Ayuso
@ 2014-11-14 16:58 ` Pablo Neira Ayuso
2014-11-16 19:24 ` [PATCH 0/8] Netfilter/IPVS fixes for net David Miller
9 siblings, 0 replies; 13+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-14 16:58 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev
From: bill bonaparte <programme110@gmail.com>
After removal of the central spinlock nf_conntrack_lock, in
commit 93bb0ceb75be2 ("netfilter: conntrack: remove central
spinlock nf_conntrack_lock"), it is possible to race against
get_next_corpse().
The race is against the get_next_corpse() cleanup on
the "unconfirmed" list (a per-cpu list with seperate locking),
which set the DYING bit.
Fix this race, in __nf_conntrack_confirm(), by removing the CT
from unconfirmed list before checking the DYING bit. In case
race occured, re-add the CT to the dying list.
While at this, fix coding style of the comment that has been
updated.
Fixes: 93bb0ceb75be2 ("netfilter: conntrack: remove central spinlock nf_conntrack_lock")
Reported-by: bill bonaparte <programme110@gmail.com>
Signed-off-by: bill bonaparte <programme110@gmail.com>
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_core.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 5016a69..2c69975 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -611,12 +611,16 @@ __nf_conntrack_confirm(struct sk_buff *skb)
*/
NF_CT_ASSERT(!nf_ct_is_confirmed(ct));
pr_debug("Confirming conntrack %p\n", ct);
- /* We have to check the DYING flag inside the lock to prevent
- a race against nf_ct_get_next_corpse() possibly called from
- user context, else we insert an already 'dead' hash, blocking
- further use of that particular connection -JM */
+
+ /* We have to check the DYING flag after unlink to prevent
+ * a race against nf_ct_get_next_corpse() possibly called from
+ * user context, else we insert an already 'dead' hash, blocking
+ * further use of that particular connection -JM.
+ */
+ nf_ct_del_from_dying_or_unconfirmed_list(ct);
if (unlikely(nf_ct_is_dying(ct))) {
+ nf_ct_add_to_dying_list(ct);
nf_conntrack_double_unlock(hash, reply_hash);
local_bh_enable();
return NF_ACCEPT;
@@ -636,8 +640,6 @@ __nf_conntrack_confirm(struct sk_buff *skb)
zone == nf_ct_zone(nf_ct_tuplehash_to_ctrack(h)))
goto out;
- nf_ct_del_from_dying_or_unconfirmed_list(ct);
-
/* Timer relative to confirmation time, not original
setting time, otherwise we'd get timer wrap in
weird delay cases. */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 0/8] Netfilter/IPVS fixes for net
2014-11-14 16:58 [PATCH 0/8] Netfilter/IPVS fixes for net Pablo Neira Ayuso
` (8 preceding siblings ...)
2014-11-14 16:58 ` [PATCH 8/8] netfilter: conntrack: fix race in __nf_conntrack_confirm against get_next_corpse Pablo Neira Ayuso
@ 2014-11-16 19:24 ` David Miller
9 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2014-11-16 19:24 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel, netdev
From: Pablo Neira Ayuso <pablo@netfilter.org>
Date: Fri, 14 Nov 2014 17:58:40 +0100
> The following patchset contains Netfilter updates for your net tree,
> they are:
...
> You can pull these changes from:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Pulled, thanks a lot Pablo!
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2014-11-16 19:24 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-14 16:58 [PATCH 0/8] Netfilter/IPVS fixes for net Pablo Neira Ayuso
2014-11-14 16:58 ` Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 1/8] netfilter: nft_masq: fix uninitialized range in nft_masq_{ipv4, ipv6}_eval Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 2/8] netfilter: ipset: small potential read beyond the end of buffer Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 3/8] ipvs: Keep skb->sk when allocating headroom on tunnel xmit Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 4/8] netfilter: nft_compat: use current net namespace Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 5/8] netfilter: nft_compat: relax chain type validation Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 6/8] netfilter: nft_compat: use the match->table to validate dependencies Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 7/8] netfilter: nf_tables: restore synchronous object release from commit/abort Pablo Neira Ayuso
2014-11-14 16:58 ` [PATCH 8/8] netfilter: conntrack: fix race in __nf_conntrack_confirm against get_next_corpse Pablo Neira Ayuso
2014-11-16 19:24 ` [PATCH 0/8] Netfilter/IPVS fixes for net David Miller
-- strict thread matches above, loose matches on Subject: below --
2013-12-28 22:02 Pablo Neira Ayuso
2013-12-29 5:29 ` David Miller
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).