net/sched: sch_qfq: prevent aggregate self-replacement
Subsystems (4)
PATCH v2 1/1 net/sched: sch_qfq: prevent aggregate self-replacement
From: Kyle Zeng <[email protected]>
qfq_change_class() snapshots the current aggregate settings while holding the qdisc tree lock, but drops the lock before selecting the destination aggregate. During that gap, qfq_enqueue() can move the class to an aggregate matching the requested settings.
When qfq_change_class() resumes, qfq_find_agg() then returns cl->agg. If it is a singleton, qfq_deact_rm_from_agg() frees the aggregate before qfq_add_to_agg() immediately accesses the same pointer, causing a use-after-free.
While holding the tree lock, skip the replacement when the destination is already the current aggregate. Any estimator replacement has already completed, so the class change can finish normally.
---
Changes in v2:
- Add the net tree prefix to the subject.
- Restore attribution.
- Remove Assisted-by and add stable to Cc.
v1: https://lore.kernel.org/netdev/[email protected]/
Bug found and triaged by OpenAI Security Research and validated by Trail of Bits.
net/sched/sch_qfq.c | 3 +++ 1 file changed, 3 insertions(+)
net/sched/sch_qfq.c +3 -0
@@ -517,11 +517,14 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,sch_tree_lock (sch);qfq_init_agg (q, new_agg, lmax, weight); } +if (existing && new_agg == cl->agg) + goto unlock;if (existing)qfq_deact_rm_from_agg (q, cl);else qdisc_class_hash_insert (&q->clhash, &cl->common);qfq_add_to_agg (q, new_agg, cl); +unlock:sch_tree_unlock (sch);qdisc_class_hash_grow (sch, &q->clhash);
Signature · 1 line
2.53.0
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 8 lines · On Thu, 29 Oct 2026 14:09:57 -0400 you wrote:
From: Kyle Zeng <[email protected]>
qfq_change_class()snapshots the current aggregate settings while holding the qdisc tree lock, but drops the lock before selecting the destination aggregate. During that gap,qfq_enqueue()can move the class to an aggregate matching the requested settings.[...]
Here is the summary with links:
- [net,v2] net/sched: sch_qfq: prevent aggregate self-replacement
https://git.kernel.org/netdev/net/c/2e54b3e18730
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html