All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: sched: act_ct: fix possible refcount leak in tcf_ct_init()
@ 2022-09-21  9:06 Hangyu Hua
  2022-09-22 14:14 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Hangyu Hua @ 2022-09-21  9:06 UTC (permalink / raw)
  To: jhs, xiyou.wangcong, jiri, davem, edumazet, kuba, pabeni, paulb
  Cc: netdev, linux-kernel, Hangyu Hua

nf_ct_put need to be called to put the refcount got by tcf_ct_fill_params
to avoid possible refcount leak when tcf_ct_flow_table_get fails.

Fixes: c34b961a2492 ("net/sched: act_ct: Create nf flow table per zone")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
---
 net/sched/act_ct.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
index d55afb8d14be..3646956fc717 100644
--- a/net/sched/act_ct.c
+++ b/net/sched/act_ct.c
@@ -1412,6 +1412,8 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla,
 cleanup:
 	if (goto_ch)
 		tcf_chain_put_by_act(goto_ch);
+	if (params->tmpl)
+		nf_ct_put(params->tmpl);
 	kfree(params);
 	tcf_idr_release(*a, bind);
 	return err;
-- 
2.34.1


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

* Re: [PATCH] net: sched: act_ct: fix possible refcount leak in tcf_ct_init()
  2022-09-21  9:06 [PATCH] net: sched: act_ct: fix possible refcount leak in tcf_ct_init() Hangyu Hua
@ 2022-09-22 14:14 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2022-09-22 14:14 UTC (permalink / raw)
  To: Hangyu Hua
  Cc: jhs, xiyou.wangcong, jiri, davem, edumazet, pabeni, paulb,
	netdev, linux-kernel

On Wed, 21 Sep 2022 17:06:00 +0800 Hangyu Hua wrote:
> Subject: [PATCH] net: sched: act_ct: fix possible refcount leak in tcf_ct_init()

[PATCH net] please

> nf_ct_put need to be called to put the refcount got by tcf_ct_fill_params
> to avoid possible refcount leak when tcf_ct_flow_table_get fails.
> 
> Fixes: c34b961a2492 ("net/sched: act_ct: Create nf flow table per zone")
> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
> ---
>  net/sched/act_ct.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
> index d55afb8d14be..3646956fc717 100644
> --- a/net/sched/act_ct.c
> +++ b/net/sched/act_ct.c
> @@ -1412,6 +1412,8 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla,
>  cleanup:
>  	if (goto_ch)
>  		tcf_chain_put_by_act(goto_ch);
> +	if (params->tmpl)
> +		nf_ct_put(params->tmpl);

This is buggy, params could be NULL here. Please add a new label above
cleanup (cleanup_params for example) and make the
tcf_ct_flow_table_get() failure path jump there instead.

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

end of thread, other threads:[~2022-09-22 14:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21  9:06 [PATCH] net: sched: act_ct: fix possible refcount leak in tcf_ct_init() Hangyu Hua
2022-09-22 14:14 ` Jakub Kicinski

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.