From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-06-18 09:44:26
Hi David,
The following patchset contains netfilter updates for your net tree,
they are:
1) Fix refcount leak when dumping the dying/unconfirmed conntrack lists,
from Florian Westphal.
2) Fix crash in NAT when removing a netnamespace, also from Florian.
3) Fix a crash in IPVS when trying to remove an estimator out of the
sysctl scope, from Julian Anastasov.
4) Add zone attribute to the routing to calculate the message size in
ctnetlink events, from Ken-ichirou MATSUZAWA.
5) Another fix for the dying/unconfirmed list which was preventing to
dump more than one memory page of entries (~17 entries in x86_64).
6) Fix missing RCU-safe list insertion in the rule replacement code
in nf_tables.
7) Since the new transaction infrastructure is in place, we have to
upgrade the chain use counter from u16 to u32 to avoid overflow
after more than 2^16 rules are added.
8) Fix refcount leak when replacing rule in nf_tables. This problem
was also introduced in new transaction.
9) Call the ->destroy() callback when releasing nft-xt rules to fix
module refcount leaks.
10) Set the family in the netlink messages that contain set elements
in nf_tables to make it consistent with other object types.
11) Don't dump NAT port information if it is unset in nft_nat.
12) Update the MAINTAINERS file, I have merged the ebtables entry
into netfilter. While at it, also removed the netfilter users
mailing list, the development list should be enough.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thanks!
----------------------------------------------------------------
The following changes since commit 7171511eaec5bf23fb06078f59784a3a0626b38f:
Linux 3.16-rc1 (2014-06-15 17:45:28 -1000)
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 db9cf3a345d310bd459f369e8fa5f039076293f2:
MAINTAINERS: merge ebtables into netfilter entry (2014-06-18 11:27:03 +0200)
----------------------------------------------------------------
Florian Westphal (2):
netfilter: ctnetlink: fix refcnt leak in dying/unconfirmed list dumper
netfilter: nf_nat: fix oops on netns removal
Julian Anastasov (1):
ipvs: stop tot_stats estimator only under CONFIG_SYSCTL
Ken-ichirou MATSUZAWA (1):
netfilter: ctnetlink: add zone size to length
Pablo Neira Ayuso (10):
netfilter: ctnetlink: fix dumping of dying/unconfirmed conntracks
netfilter: nf_tables: use RCU-safe list insertion when replacing rules
netfilter: nf_tables: use u32 for chain use counter
netfilter: nf_tables: decrement chain use counter when replacing rules
netfilter: nf_tables: fix wrong type in transaction when replacing rules
netfilter: nft_compat: call {target, match}->destroy() to cleanup entry
netfilter: nf_tables: indicate family when dumping set elements
netfilter: nft_nat: don't dump port information if unset
Merge branch 'ipvs'
MAINTAINERS: merge ebtables into netfilter entry
MAINTAINERS | 11 +----------
include/net/netfilter/nf_tables.h | 6 +++---
net/netfilter/ipvs/ip_vs_ctl.c | 2 +-
net/netfilter/nf_conntrack_netlink.c | 20 ++++++++++++-------
net/netfilter/nf_nat_core.c | 35 +++++++++++++++++++++++++++++++++-
net/netfilter/nf_tables_api.c | 11 ++++++++---
net/netfilter/nft_compat.c | 18 +++++++++++++++++
net/netfilter/nft_nat.c | 14 ++++++++------
8 files changed, 86 insertions(+), 31 deletions(-)
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-06-18 09:44:31
Since 4fefee5 ("netfilter: nf_tables: allow to delete several objects
from a batch"), every new rule bumps the chain use counter. However,
this is limited to 16 bits, which means that it will overrun after
2^16 rules.
Use a u32 chain counter and check for overflows (just like we do for
table objects).
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
include/net/netfilter/nf_tables.h | 6 +++---
net/netfilter/nf_tables_api.c | 3 +++
2 files changed, 6 insertions(+), 3 deletions(-)
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-06-18 09:44:32
Thus, the chain use counter remains with the same value after the
rule replacement.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_tables_api.c | 2 ++
1 file changed, 2 insertions(+)
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-06-18 09:44:50
From: Julian Anastasov <ja@ssi.bg>
The tot_stats estimator is started only when CONFIG_SYSCTL
is defined. But it is stopped without checking CONFIG_SYSCTL.
Fix the crash by moving ip_vs_stop_estimator into
ip_vs_control_net_cleanup_sysctl.
The change is needed after commit 14e405461e664b
("IPVS: Add __ip_vs_control_{init,cleanup}_sysctl()") from 2.6.39.
Reported-by: Jet Chen <redacted>
Tested-by: Jet Chen <redacted>
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
net/netfilter/ipvs/ip_vs_ctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-06-18 09:44:51
The dumping prematurely stops, it seems the callback argument that
indicates that all entries have been dumped is set after iterating
on the first cpu list. The dumping also may stop before the entire
per-cpu list content is also dumped.
With this patch, conntrack -L dying now shows the dying list content
again.
Fixes: b7779d06 ("netfilter: conntrack: spinlock per cpu to protect special lists.")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_netlink.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-06-18 09:44:52
From: Florian Westphal <fw@strlen.de>
'last' keeps track of the ct that had its refcnt bumped during previous
dump cycle. Thus it must not be overwritten until end-of-function.
Another (unrelated, theoretical) issue: Don't attempt to bump refcnt of a conntrack
whose reference count is already 0. Such conntrack is being destroyed
right now, its memory is freed once we release the percpu dying spinlock.
Fixes: b7779d06 ('netfilter: conntrack: spinlock per cpu to protect special lists.')
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_netlink.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-06-18 09:44:52
The patch 5e94846 ("netfilter: nf_tables: add insert operation") did
not include RCU-safe list insertion when replacing rules.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_tables_api.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-06-18 09:44:55
In b380e5c ("netfilter: nf_tables: add message type to transactions"),
I used the wrong message type in the rule replacement case. The rule
that is replaced needs to be handled as a deleted rule.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_tables_api.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-06-18 09:44:56
Otherwise, the reference to external objects (eg. modules) are not
released when the rules are removed.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nft_compat.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-06-18 09:44:56
Set the nfnetlink header that indicates the family of this element.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_tables_api.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-06-18 09:44:57
Don't include port information attributes if they are unset.
Reported-by: Ana Rey <redacted>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nft_nat.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2014-06-18 09:44:59
From: Florian Westphal <fw@strlen.de>
Quoting Samu Kallio:
Basically what's happening is, during netns cleanup,
nf_nat_net_exit gets called before ipv4_net_exit. As I understand
it, nf_nat_net_exit is supposed to kill any conntrack entries which
have NAT context (through nf_ct_iterate_cleanup), but for some
reason this doesn't happen (perhaps something else is still holding
refs to those entries?).
When ipv4_net_exit is called, conntrack entries (including those
with NAT context) are cleaned up, but the
nat_bysource hashtable is long gone - freed in nf_nat_net_exit. The
bug happens when attempting to free a conntrack entry whose NAT hash
'prev' field points to a slot in the freed hash table (head for that
bin).
We ignore conntracks with null nat bindings. But this is wrong,
as these are in bysource hash table as well.
Restore nat-cleaning for the netns-is-being-removed case.
bug:
https://bugzilla.kernel.org/show_bug.cgi?id=65191
Fixes: c2d421e1718 ('netfilter: nf_nat: fix race when unloading protocol modules')
Reported-by: Samu Kallio <redacted>
Debugged-by: Samu Kallio [off-list ref]
Signed-off-by: Florian Westphal <fw@strlen.de>
Tested-by: Samu Kallio <redacted>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_nat_core.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
@@ -525,6 +525,39 @@ static int nf_nat_proto_remove(struct nf_conn *i, void *data)returni->status&IPS_NAT_MASK?1:0;}+staticintnf_nat_proto_clean(structnf_conn*ct,void*data)+{+structnf_conn_nat*nat=nfct_nat(ct);++if(nf_nat_proto_remove(ct,data))+return1;++if(!nat||!nat->ct)+return0;++/* This netns is being destroyed, and conntrack has nat null binding.+*Removeitfrombysourcehash,asthetablewillbefreedsoon.+*+*Else,whentheconntrackisdestoyed,nf_nat_cleanup_conntrack()+*willdeleteentryfromalready-freedtable.+*/+if(!del_timer(&ct->timeout))+return1;++spin_lock_bh(&nf_nat_lock);+hlist_del_rcu(&nat->bysource);+ct->status&=~IPS_NAT_DONE_MASK;+nat->ct=NULL;+spin_unlock_bh(&nf_nat_lock);++add_timer(&ct->timeout);++/* don't delete conntrack. Although that would make things a lot+*simpler,we'dendupflushingallconntracksonnatrmmod.+*/+return0;+}+staticvoidnf_nat_l4proto_clean(u8l3proto,u8l4proto){structnf_nat_proto_cleanclean={
@@ -795,7 +828,7 @@ static void __net_exit nf_nat_net_exit(struct net *net){structnf_nat_proto_cleanclean={};-nf_ct_iterate_cleanup(net,&nf_nat_proto_remove,&clean,0,0);+nf_ct_iterate_cleanup(net,nf_nat_proto_clean,&clean,0,0);synchronize_rcu();nf_ct_free_hashtable(net->ct.nat_bysource,net->ct.nat_htable_size);}