Skip to content

Commit dbcd1f8

Browse files
committed
sch_hfsc: make hfsc_qlen_notify() idempotent
jira VULN-71949 cve CVE-2025-38177 commit-author Cong Wang <[email protected]> commit 51eb3b6 hfsc_qlen_notify() is not idempotent either and not friendly to its callers, like fq_codel_dequeue(). Let's make it idempotent to ease qdisc_tree_reduce_backlog() callers' life: 1. update_vf() decreases cl->cl_nactive, so we can check whether it is non-zero before calling it. 2. eltree_remove() always removes RB node cl->el_node, but we can use RB_EMPTY_NODE() + RB_CLEAR_NODE() to make it safe. Reported-by: Gerrard Tai <[email protected]> Signed-off-by: Cong Wang <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Acked-by: Jamal Hadi Salim <[email protected]> Signed-off-by: Paolo Abeni <[email protected]> (cherry picked from commit 51eb3b6) Signed-off-by: Brett Mastbergen <[email protected]>
1 parent 2c33c5e commit dbcd1f8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/sched/sch_hfsc.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,10 @@ eltree_insert(struct hfsc_class *cl)
209209
static inline void
210210
eltree_remove(struct hfsc_class *cl)
211211
{
212-
rb_erase(&cl->el_node, &cl->sched->eligible);
212+
if (!RB_EMPTY_NODE(&cl->el_node)) {
213+
rb_erase(&cl->el_node, &cl->sched->eligible);
214+
RB_CLEAR_NODE(&cl->el_node);
215+
}
213216
}
214217

215218
static inline void
@@ -1229,7 +1232,8 @@ hfsc_qlen_notify(struct Qdisc *sch, unsigned long arg)
12291232
/* vttree is now handled in update_vf() so that update_vf(cl, 0, 0)
12301233
* needs to be called explicitly to remove a class from vttree.
12311234
*/
1232-
update_vf(cl, 0, 0);
1235+
if (cl->cl_nactive)
1236+
update_vf(cl, 0, 0);
12331237
if (cl->cl_flags & HFSC_RSC)
12341238
eltree_remove(cl);
12351239
}

0 commit comments

Comments
 (0)