linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed
@ 2021-08-29 15:58 Xiyu Yang
  2021-08-30 18:05 ` Jakub Kicinski
  2021-08-31  3:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Xiyu Yang @ 2021-08-29 15:58 UTC (permalink / raw)
  To: Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller,
	Jakub Kicinski, netdev, linux-kernel
  Cc: Xiyu Yang

The reference counting issue happens in one exception handling path of
cbq_change_class(). When failing to get tcf_block, the function forgets
to decrease the refcount of "rtab" increased by qdisc_put_rtab(),
causing a refcount leak.

Fix this issue by jumping to "failure" label when get tcf_block failed.

Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
---
 net/sched/sch_cbq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
index b79a7e27bb31..38a3a8394bbd 100644
--- a/net/sched/sch_cbq.c
+++ b/net/sched/sch_cbq.c
@@ -1614,7 +1614,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t
 	err = tcf_block_get(&cl->block, &cl->filter_list, sch, extack);
 	if (err) {
 		kfree(cl);
-		return err;
+		goto failure;
 	}
 
 	if (tca[TCA_RATE]) {
-- 
2.7.4


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

* Re: [PATCH] net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed
  2021-08-29 15:58 [PATCH] net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed Xiyu Yang
@ 2021-08-30 18:05 ` Jakub Kicinski
  2021-08-31  1:18   ` Cong Wang
  2021-08-31  3:40 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2021-08-30 18:05 UTC (permalink / raw)
  To: Xiyu Yang
  Cc: Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller, netdev,
	linux-kernel

On Sun, 29 Aug 2021 23:58:01 +0800 Xiyu Yang wrote:
> The reference counting issue happens in one exception handling path of
> cbq_change_class(). When failing to get tcf_block, the function forgets
> to decrease the refcount of "rtab" increased by qdisc_put_rtab(),
> causing a refcount leak.
> 
> Fix this issue by jumping to "failure" label when get tcf_block failed.
> 
> Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>

Fixes: 6529eaba33f0 ("net: sched: introduce tcf block infractructure")

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

* Re: [PATCH] net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed
  2021-08-30 18:05 ` Jakub Kicinski
@ 2021-08-31  1:18   ` Cong Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Cong Wang @ 2021-08-31  1:18 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Xiyu Yang, Jamal Hadi Salim, Jiri Pirko, David S. Miller,
	Linux Kernel Network Developers, LKML

On Mon, Aug 30, 2021 at 11:05 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Sun, 29 Aug 2021 23:58:01 +0800 Xiyu Yang wrote:
> > The reference counting issue happens in one exception handling path of
> > cbq_change_class(). When failing to get tcf_block, the function forgets
> > to decrease the refcount of "rtab" increased by qdisc_put_rtab(),
> > causing a refcount leak.
> >
> > Fix this issue by jumping to "failure" label when get tcf_block failed.
> >
> > Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
>
> Fixes: 6529eaba33f0 ("net: sched: introduce tcf block infractructure")

Reviewed-by: Cong Wang <cong.wang@bytedance.com>

Thanks.

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

* Re: [PATCH] net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed
  2021-08-29 15:58 [PATCH] net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed Xiyu Yang
  2021-08-30 18:05 ` Jakub Kicinski
@ 2021-08-31  3:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-08-31  3:40 UTC (permalink / raw)
  To: Xiyu Yang; +Cc: jhs, xiyou.wangcong, jiri, davem, kuba, netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Sun, 29 Aug 2021 23:58:01 +0800 you wrote:
> The reference counting issue happens in one exception handling path of
> cbq_change_class(). When failing to get tcf_block, the function forgets
> to decrease the refcount of "rtab" increased by qdisc_put_rtab(),
> causing a refcount leak.
> 
> Fix this issue by jumping to "failure" label when get tcf_block failed.
> 
> [...]

Here is the summary with links:
  - net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed
    https://git.kernel.org/netdev/net-next/c/c66070125837

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-08-31  3:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-29 15:58 [PATCH] net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed Xiyu Yang
2021-08-30 18:05 ` Jakub Kicinski
2021-08-31  1:18   ` Cong Wang
2021-08-31  3:40 ` patchwork-bot+netdevbpf

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