Skip to content

Commit 09b7e0f

Browse files
committed
sch_hfsc: Fix qlen accounting bug when using peek in hfsc_enqueue()
jira VULN-68355 cve CVE-2025-38000 commit-author Cong Wang <xiyou.wangcong@gmail.com> commit 3f98113 upstream-diff Minor conflict in hfsc_enqueue because we have already backported ac9fe7d which changed !cl->cl_nactive to cl_in_el_or_vttree(cl). No changes to the commit content. When enqueuing the first packet to an HFSC class, hfsc_enqueue() calls the child qdisc's peek() operation before incrementing sch->q.qlen and sch->qstats.backlog. If the child qdisc uses qdisc_peek_dequeued(), this may trigger an immediate dequeue and potential packet drop. In such cases, qdisc_tree_reduce_backlog() is called, but the HFSC qdisc's qlen and backlog have not yet been updated, leading to inconsistent queue accounting. This can leave an empty HFSC class in the active list, causing further consequences like use-after-free. This patch fixes the bug by moving the increment of sch->q.qlen and sch->qstats.backlog before the call to the child qdisc's peek() operation. This ensures that queue length and backlog are always accurate when packet drops or dequeues are triggered during the peek. Fixes: 12d0ad3 ("net/sched/sch_hfsc.c: handle corner cases where head may change invalidating calculated deadline") Reported-by: Mingi Cho <mincho@theori.io> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250518222038.58538-2-xiyou.wangcong@gmail.com Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> (cherry picked from commit 3f98113) Signed-off-by: Brett Mastbergen <bmastbergen@ciq.com>
1 parent 3a4ffa4 commit 09b7e0f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/sched/sch_hfsc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,9 @@ hfsc_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free)
15841584
return err;
15851585
}
15861586

1587+
sch->qstats.backlog += len;
1588+
sch->q.qlen++;
1589+
15871590
if (first && !cl_in_el_or_vttree(cl)) {
15881591
if (cl->cl_flags & HFSC_RSC)
15891592
init_ed(cl, len);
@@ -1599,9 +1602,6 @@ hfsc_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free)
15991602

16001603
}
16011604

1602-
sch->qstats.backlog += len;
1603-
sch->q.qlen++;
1604-
16051605
return NET_XMIT_SUCCESS;
16061606
}
16071607

0 commit comments

Comments
 (0)