hfsc_reset_qdisc() drops the eligible tree root, but hfsc_reset_class() never resets the linkage state of cl->el_node. A class that sits in the eligible tree at reset time keeps a stale linked node while the tree is gone. This breaks the invariant that the linkage state of el_node matches the membership, which hfsc_change_class() establishes for new classes. Two consumers trip over the stale node. cl_in_el_or_vttree() reads it as "class is in the tree", so hfsc_enqueue() never calls init_ed() for the class again and the class is starved permanently. eltree_remove() later runs rb_erase() on the stale node against the reset root, which splices a stale sibling back into q->eligible.rb_node and revives a class the scheduler should have forgotten. Clear the linkage state where the rest of the scheduling state is reset. This issue was discovered by Tencent CodeBuddy Security. Cc: stable@vger.kernel.org Fixes: ac9fe7dd8e73 ("net_sched: hfsc: Address reentrant enqueue adding class to eltree twice") Signed-off-by: Henry Martin --- net/sched/sch_hfsc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 284490fd6ca91..e64df06429239 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -1491,6 +1491,10 @@ hfsc_reset_class(struct hfsc_class *cl) cl->vt_tree = RB_ROOT; cl->cf_tree = RB_ROOT; + /* hfsc_reset_qdisc() drops the eligible tree root; the + * linkage state of el_node must match the membership. + */ + RB_CLEAR_NODE(&cl->el_node); qdisc_reset(cl->qdisc); if (cl->cl_flags & HFSC_RSC) -- 2.39.5