Skip to content

Commit bc5ef8e

Browse files
committed
sch_hfsc: make hfsc_qlen_notify() idempotent
jira VULN-71943 cve CVE-2025-38177 commit-author Cong Wang <xiyou.wangcong@gmail.com> 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 <gerrard.tai@starlabs.sg> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250403211033.166059-4-xiyou.wangcong@gmail.com Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> (cherry picked from commit 51eb3b6) Signed-off-by: Brett Mastbergen <bmastbergen@ciq.com>
1 parent a55b4b4 commit bc5ef8e

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
@@ -204,7 +204,10 @@ eltree_insert(struct hfsc_class *cl)
204204
static inline void
205205
eltree_remove(struct hfsc_class *cl)
206206
{
207-
rb_erase(&cl->el_node, &cl->sched->eligible);
207+
if (!RB_EMPTY_NODE(&cl->el_node)) {
208+
rb_erase(&cl->el_node, &cl->sched->eligible);
209+
RB_CLEAR_NODE(&cl->el_node);
210+
}
208211
}
209212

210213
static inline void
@@ -1225,7 +1228,8 @@ hfsc_qlen_notify(struct Qdisc *sch, unsigned long arg)
12251228
/* vttree is now handled in update_vf() so that update_vf(cl, 0, 0)
12261229
* needs to be called explicitly to remove a class from vttree.
12271230
*/
1228-
update_vf(cl, 0, 0);
1231+
if (cl->cl_nactive)
1232+
update_vf(cl, 0, 0);
12291233
if (cl->cl_flags & HFSC_RSC)
12301234
eltree_remove(cl);
12311235
}

0 commit comments

Comments
 (0)