Skip to content

Commit 0d069ea

Browse files
committed
sch_hfsc: Fix qlen accounting bug when using peek in hfsc_enqueue()
jira VULN-68349 cve CVE-2025-38000 commit-author Cong Wang <xiyou.wangcong@gmail.com> commit 3f98113 upstream-diff Minor conflict when applying because the conditional in hfsc_enqueue is slightly different in this version of the kernel. 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 24ea458 commit 0d069ea

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
@@ -1573,6 +1573,9 @@ hfsc_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free)
15731573
return err;
15741574
}
15751575

1576+
sch->qstats.backlog += len;
1577+
sch->q.qlen++;
1578+
15761579
if (cl->qdisc->q.qlen == 1) {
15771580
if (cl->cl_flags & HFSC_RSC)
15781581
init_ed(cl, len);
@@ -1588,9 +1591,6 @@ hfsc_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free)
15881591

15891592
}
15901593

1591-
sch->qstats.backlog += len;
1592-
sch->q.qlen++;
1593-
15941594
return NET_XMIT_SUCCESS;
15951595
}
15961596

0 commit comments

Comments
 (0)