Skip to content

Commit 6ccbda4

Browse files
congwangkuba-moo
authored andcommitted
net_sched: hfsc: Fix a potential UAF in hfsc_dequeue() too
Similarly to the previous patch, we need to safe guard hfsc_dequeue() too. But for this one, we don't have a reliable reproducer. Fixes: 1da177e ("Linux-2.6.12-rc2") Reported-by: Gerrard Tai <gerrard.tai@starlabs.sg> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com> Link: https://patch.msgid.link/20250417184732.943057-3-xiyou.wangcong@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 3df275e commit 6ccbda4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

net/sched/sch_hfsc.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,10 +1641,16 @@ hfsc_dequeue(struct Qdisc *sch)
16411641
if (cl->qdisc->q.qlen != 0) {
16421642
/* update ed */
16431643
next_len = qdisc_peek_len(cl->qdisc);
1644-
if (realtime)
1645-
update_ed(cl, next_len);
1646-
else
1647-
update_d(cl, next_len);
1644+
/* Check queue length again since some qdisc implementations
1645+
* (e.g., netem/codel) might empty the queue during the peek
1646+
* operation.
1647+
*/
1648+
if (cl->qdisc->q.qlen != 0) {
1649+
if (realtime)
1650+
update_ed(cl, next_len);
1651+
else
1652+
update_d(cl, next_len);
1653+
}
16481654
} else {
16491655
/* the class becomes passive */
16501656
eltree_remove(cl);

0 commit comments

Comments
 (0)