From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Gao feng <gaofeng@cn.fujitsu.com>
Cc: netfilter-devel@vger.kernel.org, netdev@vger.kernel.org,
canqunzhang@gmail.com, kaber@trash.net, ebiederm@xmission.com
Subject: Re: [PATCH 19/19] netfilter: gre: fix resource leak when unregister gre proto
Date: Sat, 5 Jan 2013 04:50:48 +0100 [thread overview]
Message-ID: <20130105035048.GA20027@1984> (raw)
In-Reply-To: <1356662206-2260-20-git-send-email-gaofeng@cn.fujitsu.com>
[-- Attachment #1: Type: text/plain, Size: 429 bytes --]
Hi Gao,
On Fri, Dec 28, 2012 at 10:36:46AM +0800, Gao feng wrote:
> Currectly we unregister proto before all conntrack entries of
> this proto being destroyed. so in function destroy_conntrack
> we can't find proper l4proto to call l4proto->destroy.
> this will cause resource leak.
Good catch.
But better to remove the entries before unregistering the protocol
tracker, so l4proto->destroy is always called.
Patch attached.
[-- Attachment #2: 0001-netfilter-nf_conntrack-fix-memory-leak-during-unregi.patch --]
[-- Type: text/x-diff, Size: 1523 bytes --]
>From 1c082b3ef4c9bf8bfd0159142ce6ffc49aa7bab2 Mon Sep 17 00:00:00 2001
From: Pablo Neira Ayuso <pablo@netfilter.org>
Date: Fri, 4 Jan 2013 22:09:44 +0100
Subject: [PATCH] netfilter: nf_conntrack: fix memory leak during
unregistration with GRE entries
Protocol trackers are unregistered before conntrack entries of that
type are removed. For that reason, l4proto->destroy is never called
and that results in leaking the keymap.
Fix this by releasing entries before unregistering protocols.
Reported-by: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_proto.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
index 51e928d..29cd353 100644
--- a/net/netfilter/nf_conntrack_proto.c
+++ b/net/netfilter/nf_conntrack_proto.c
@@ -488,6 +488,9 @@ void nf_conntrack_l4proto_unregister(struct net *net,
{
struct nf_proto_net *pn = NULL;
+ /* Remove all contrack entries before unregistration */
+ nf_ct_iterate_cleanup(net, kill_l4proto, l4proto);
+
if (net == &init_net)
nf_conntrack_l4proto_unregister_net(l4proto);
@@ -497,9 +500,6 @@ void nf_conntrack_l4proto_unregister(struct net *net,
pn->users--;
nf_ct_l4proto_unregister_sysctl(net, pn, l4proto);
-
- /* Remove all contrack entries for this protocol */
- nf_ct_iterate_cleanup(net, kill_l4proto, l4proto);
}
EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_unregister);
--
1.7.10.4
next prev parent reply other threads:[~2013-01-05 3:50 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-28 2:36 [PATCH 01/19] netfilter: move nf_conntrack initialize out of pernet operations Gao feng
2012-12-28 2:36 ` [PATCH 02/19] netfilter: expect: move initial codes out of pernet_operations Gao feng
2012-12-28 2:36 ` [PATCH 03/19] netfilter: acct: " Gao feng
2012-12-28 2:36 ` [PATCH 04/19] netfilter: tstamp: " Gao feng
2012-12-28 2:36 ` [PATCH 05/19] netfilter: ecache: " Gao feng
2012-12-28 2:36 ` [PATCH 06/19] netfilter: timeout: " Gao feng
2012-12-28 2:36 ` [PATCH 07/19] netfilter: helper: " Gao feng
2012-12-28 2:36 ` [PATCH 08/19] netfilter: proto: " Gao feng
2012-12-28 2:36 ` [PATCH 09/19] netfilter: l3proto: prepare reworking l3proto support for netns Gao feng
2012-12-28 2:36 ` [PATCH 10/19] netfilter: ipv4: register ipv4 in module_init Gao feng
2012-12-28 2:36 ` [PATCH 10/19] netfilter: ipv4: register l3proto " Gao feng
2012-12-28 2:36 ` [PATCH 11/19] netfilter: ipv6: register l3proto ipv6 " Gao feng
2012-12-28 2:36 ` [PATCH 12/19] netfilter: l4proto: prepare reworking l4proto support for netns Gao feng
2012-12-28 2:36 ` [PATCH 13/19] netfilter: ipv4: move registration codes out of pernet_operations Gao feng
2012-12-28 2:36 ` [PATCH 14/19] netfilter: ipv6: " Gao feng
2012-12-28 2:36 ` [PATCH 15/19] netfilter: sctp: " Gao feng
2012-12-28 2:36 ` [PATCH 16/19] netfilter: udplite: " Gao feng
2012-12-28 2:36 ` [PATCH 17/19] netfilter: dccp: " Gao feng
2012-12-28 2:36 ` [PATCH 18/19] netfilter: gre: " Gao feng
2012-12-28 2:36 ` [PATCH 19/19] netfilter: gre: fix resource leak when unregister gre proto Gao feng
2013-01-05 3:50 ` Pablo Neira Ayuso [this message]
2013-01-07 1:27 ` Gao feng
2013-01-07 2:15 ` Pablo Neira Ayuso
2013-01-07 2:38 ` Pablo Neira Ayuso
2013-01-07 2:59 ` Gao feng
2013-01-07 3:05 ` Gao feng
2013-01-07 3:27 ` Pablo Neira Ayuso
2013-01-07 3:43 ` Gao feng
2012-12-28 3:52 ` [PATCH 01/19] netfilter: move nf_conntrack initialize out of pernet operations canqun zhang
2012-12-28 4:48 ` Eric W. Biederman
2012-12-28 5:32 ` canqun zhang
2012-12-28 6:00 ` Eric W. Biederman
2012-12-28 11:58 ` Pablo Neira Ayuso
2012-12-28 7:16 ` Gao feng
2012-12-28 8:48 ` canqun zhang
2013-01-10 1:03 ` Gao feng
2013-01-10 16:41 ` Pablo Neira Ayuso
2013-01-11 1:01 ` Gao feng
2013-01-13 15:07 ` Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130105035048.GA20027@1984 \
--to=pablo@netfilter.org \
--cc=canqunzhang@gmail.com \
--cc=ebiederm@xmission.com \
--cc=gaofeng@cn.fujitsu.com \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.