Skip to contentSkip to conversation

net_sched: hfsc: clear el_node linkage in hfsc_reset_class()

PATCH New Henry Martin 2 participants 2 messages Nov 27

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net_sched: hfsc: clear el_node linkage in hfsc_reset_class()

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.

Fixes ac9fe7dd8e73 ("net_sched: hfsc: Address reentrant enqueue adding class to eltree twice")
---
 net/sched/sch_hfsc.c | 4 ++++
 1 file changed, 4 insertions(+)
net/sched/sch_hfsc.c +4 -0
index 284490fd6ca91..e64df06429239 100644
@@ -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)
Signature · 1 line
2.39.5
#1 lore raw
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

Hi!

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.

Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.