[PATCH] net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed

Subsystems: networking [general], tc subsystem, the rest

STALE1800d LANDED

Landed in mainline as c66070125837 on 2021-08-31.

4 messages, 4 authors, 2021-08-31 · open the first message on its own page

[PATCH] net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed

From: Xiyu Yang <hidden>
Date: 2021-08-29 15:58:41

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 <redacted>
---
 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

Re: [PATCH] net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed

From: Jakub Kicinski <kuba@kernel.org>
Date: 2021-08-30 18:05:55

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 <redacted>
Fixes: 6529eaba33f0 ("net: sched: introduce tcf block infractructure")

Re: [PATCH] net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed

From: Cong Wang <hidden>
Date: 2021-08-31 01:18:48

On Mon, Aug 30, 2021 at 11:05 AM Jakub Kicinski [off-list ref] wrote:
On Sun, 29 Aug 2021 23:58:01 +0800 Xiyu Yang wrote:
quoted
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 <redacted>
Fixes: 6529eaba33f0 ("net: sched: introduce tcf block infractructure")
Reviewed-by: Cong Wang <redacted>

Thanks.

Re: [PATCH] net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed

From: patchwork-bot+netdevbpf@kernel.org
Date: 2021-08-31 03:40:15

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

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help