Skip to contentSkip to conversation

net/sched: sch_qfq: do not free existing class in qfq_change_class()

PATCH Applied Eric Dumazet 3 participants 4 messages Jan 12 – Jan 14

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/sched: sch_qfq: do not free existing class in qfq_change_class()

Fixes qfq_change_class() error case.

cl->qdisc and cl should only be freed if a new class and qdisc were allocated, or we risk various UAF.

Fixes 462dbc9101ac ("pkt_sched: QFQ Plus: fair-queueing service at DRR cost")
Reported-by [email protected]
---
 net/sched/sch_qfq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/sched/sch_qfq.c +4 -2
index f4013b547438ffe1bdc8ba519971a1681df4700b..9d59090bbe934ad56ab08a59708aab375aa77cf0 100644
@@ -529,8 +529,10 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
 	return 0;
 
 destroy_class:
-	qdisc_put(cl->qdisc);
-	kfree(cl);
+	if (!existing) {
+		qdisc_put(cl->qdisc);
+		kfree(cl);
+	}
 	return err;
 }
 
Signature · 1 line
2.52.0.457.g6b5491de43-goog
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Eric Dumazet

Fixes qfq_change_class() error case.

cl->qdisc and cl should only be freed if a new class and qdisc were allocated, or we risk various UAF.

Fixes 462dbc9101ac ("pkt_sched: QFQ Plus: fair-queueing service at DRR cost")
Reported-by [email protected]

Eric,
The patch looks correct. Initially i was scratching my head trying to see how you knew it was the same issue. I gues on a UAF even without a repro syzbot can tell you exactly where the UAF happened?

cheers,
jamal

Quoted 23 lines
 net/sched/sch_qfq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/sched/sch_qfq.c +4 -3
index f4013b547438ffe1bdc8ba519971a1681df4700b..9d59090bbe934ad56ab08a59708aab375aa77cf0 100644
@@ -529,8 +529,10 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
        return 0;
 
 destroy_class:
-       qdisc_put(cl->qdisc);
-       kfree(cl);
+       if (!existing) {
+               qdisc_put(cl->qdisc);
+               kfree(cl);
+       }
        return err;
 }
 
--

2.52.0.457.g6b5491de43-goog

#2 lore raw
Quoted 13 lines · Jamal Hadi Salim
Quoted 10 lines · Eric Dumazet

Fixes qfq_change_class() error case.

cl->qdisc and cl should only be freed if a new class and qdisc were allocated, or we risk various UAF.

Fixes 462dbc9101ac ("pkt_sched: QFQ Plus: fair-queueing service at DRR cost")
Reported-by [email protected]
Quoted 4 lines

Eric,
The patch looks correct. Initially i was scratching my head trying to see how you knew it was the same issue. I gues on a UAF even without a repro syzbot can tell you exactly where the UAF happened?

Without a repro, I was still able to root-cause the issue to the unexpected kfree().

syzbot report was sent as-is on the mailing list, I had no more information.

Thanks.

Quoted 29 lines

cheers,
jamal

Quoted 23 lines
 net/sched/sch_qfq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/sched/sch_qfq.c +4 -3
index f4013b547438ffe1bdc8ba519971a1681df4700b..9d59090bbe934ad56ab08a59708aab375aa77cf0 100644
@@ -529,8 +529,10 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
        return 0;
 
 destroy_class:
-       qdisc_put(cl->qdisc);
-       kfree(cl);
+       if (!existing) {
+               qdisc_put(cl->qdisc);
+               kfree(cl);
+       }
        return err;
 }
 
--

2.52.0.457.g6b5491de43-goog

#3 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Mon, 12 Jan 2026 17:56:56 +0000 you wrote:

Fixes qfq_change_class() error case.

cl->qdisc and cl should only be freed if a new class and qdisc were allocated, or we risk various UAF.

Fixes 462dbc9101ac ("pkt_sched: QFQ Plus: fair-queueing service at DRR cost")
Reported-by [email protected]

[...]

Here is the summary with links:
- [net] net/sched: sch_qfq: do not free existing class in qfq_change_class()

    https://git.kernel.org/netdev/net/c/3879cffd9d07

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html