netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nf] netfilter: xt_CT: fix cthelper module's refcnt leak
@ 2017-04-08  3:38 Liping Zhang
  2017-04-13 22:30 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 4+ messages in thread
From: Liping Zhang @ 2017-04-08  3:38 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel, Liping Zhang

From: Liping Zhang <zlpnobody@gmail.com>

We should call module_put when the time policy is not found. Otherwise,
the related cthelper module cannot be removed anymore.

It is easy to reproduce by typing the following command:
  # iptables -t raw -A OUTPUT -p tcp -j CT --helper ftp --timeout xxx

Signed-off-by: Liping Zhang <zlpnobody@gmail.com>
---
 net/netfilter/xt_CT.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/xt_CT.c b/net/netfilter/xt_CT.c
index b008db0..841cfba 100644
--- a/net/netfilter/xt_CT.c
+++ b/net/netfilter/xt_CT.c
@@ -200,6 +200,7 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par,
 			  struct xt_ct_target_info_v1 *info)
 {
 	struct nf_conntrack_zone zone;
+	struct nf_conn_help *help;
 	struct nf_conn *ct;
 	int ret = -EOPNOTSUPP;
 
@@ -248,7 +249,7 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par,
 	if (info->timeout[0]) {
 		ret = xt_ct_set_timeout(ct, par, info->timeout);
 		if (ret < 0)
-			goto err3;
+			goto err4;
 	}
 	__set_bit(IPS_CONFIRMED_BIT, &ct->status);
 	nf_conntrack_get(&ct->ct_general);
@@ -256,6 +257,10 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par,
 	info->ct = ct;
 	return 0;
 
+err4:
+	help = nfct_help(ct);
+	if (help)
+		module_put(help->helper->me);
 err3:
 	nf_ct_tmpl_free(ct);
 err2:
-- 
2.5.5



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH nf] netfilter: xt_CT: fix cthelper module's refcnt leak
  2017-04-08  3:38 [PATCH nf] netfilter: xt_CT: fix cthelper module's refcnt leak Liping Zhang
@ 2017-04-13 22:30 ` Pablo Neira Ayuso
  2017-04-13 23:09   ` Liping Zhang
  0 siblings, 1 reply; 4+ messages in thread
From: Pablo Neira Ayuso @ 2017-04-13 22:30 UTC (permalink / raw)
  To: Liping Zhang; +Cc: netfilter-devel, Liping Zhang

On Sat, Apr 08, 2017 at 11:38:48AM +0800, Liping Zhang wrote:
> From: Liping Zhang <zlpnobody@gmail.com>
> 
> We should call module_put when the time policy is not found. Otherwise,
> the related cthelper module cannot be removed anymore.
> 
> It is easy to reproduce by typing the following command:
>   # iptables -t raw -A OUTPUT -p tcp -j CT --helper ftp --timeout xxx

Can we fix all leaks in the error path in one single patch for xt_CT?

Feng sent me a patch to fix another issue there, so if either you or
him send me one single patch to fix all xt_CT refcount leaks in one
go, I'd appreciate.

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH nf] netfilter: xt_CT: fix cthelper module's refcnt leak
  2017-04-13 22:30 ` Pablo Neira Ayuso
@ 2017-04-13 23:09   ` Liping Zhang
  2017-04-14  0:49     ` Gao Feng
  0 siblings, 1 reply; 4+ messages in thread
From: Liping Zhang @ 2017-04-13 23:09 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Gao Feng
  Cc: Liping Zhang, Netfilter Developer Mailing List

Hi Pablo,

2017-04-14 6:30 GMT+08:00 Pablo Neira Ayuso <pablo@netfilter.org>:
>> We should call module_put when the time policy is not found. Otherwise,
>> the related cthelper module cannot be removed anymore.
>>
>> It is easy to reproduce by typing the following command:
>>   # iptables -t raw -A OUTPUT -p tcp -j CT --helper ftp --timeout xxx
>
> Can we fix all leaks in the error path in one single patch for xt_CT?

Right.

> Feng sent me a patch to fix another issue there, so if either you or
> him send me one single patch to fix all xt_CT refcount leaks in one
> go, I'd appreciate.

Feng, since you spotted this issue earlier, can you send a new patch to do this?
With a new patch name: "netfilter: xt_CT: fix refcnt leak on error path".

Also you can add my:
Signed-off-by: Liping Zhang <zlpnobody@gmail.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH nf] netfilter: xt_CT: fix cthelper module's refcnt leak
  2017-04-13 23:09   ` Liping Zhang
@ 2017-04-14  0:49     ` Gao Feng
  0 siblings, 0 replies; 4+ messages in thread
From: Gao Feng @ 2017-04-14  0:49 UTC (permalink / raw)
  To: 'Liping Zhang', 'Pablo Neira Ayuso'
  Cc: 'Liping Zhang',
	'Netfilter Developer Mailing List'

> -----Original Message-----
> From: Liping Zhang [mailto:zlpnobody@gmail.com]
> Hi Pablo,
> 
> 2017-04-14 6:30 GMT+08:00 Pablo Neira Ayuso <pablo@netfilter.org>:
> >> We should call module_put when the time policy is not found.
> >> Otherwise, the related cthelper module cannot be removed anymore.
> >>
> >> It is easy to reproduce by typing the following command:
> >>   # iptables -t raw -A OUTPUT -p tcp -j CT --helper ftp --timeout xxx
> >
> > Can we fix all leaks in the error path in one single patch for xt_CT?
> 
> Right.
> 
> > Feng sent me a patch to fix another issue there, so if either you or
> > him send me one single patch to fix all xt_CT refcount leaks in one
> > go, I'd appreciate.
> 
> Feng, since you spotted this issue earlier, can you send a new patch to do this?
> With a new patch name: "netfilter: xt_CT: fix refcnt leak on error path".

Thanks.

> 
> Also you can add my:
> Signed-off-by: Liping Zhang <zlpnobody@gmail.com>

No problem.

Regards
Feng




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-04-14  0:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-08  3:38 [PATCH nf] netfilter: xt_CT: fix cthelper module's refcnt leak Liping Zhang
2017-04-13 22:30 ` Pablo Neira Ayuso
2017-04-13 23:09   ` Liping Zhang
2017-04-14  0:49     ` Gao Feng

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).