Netdev List
 help / color / mirror / Atom feed
From: Henry Martin <bsdhenrymartin@gmail.com>
To: Jamal Hadi Salim <jhs@mojatatu.com>,
	Jiri Pirko <jiri@resnulli.us>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Pedro Tammela <pctammela@mojatatu.com>
Cc: netdev@vger.kernel.org, Henry Martin <bsdhenrymartin@gmail.com>,
	stable@vger.kernel.org
Subject: [PATCH net] net_sched: hfsc: clear el_node linkage in hfsc_reset_class()
Date: Fri, 27 Nov 2026 14:57:56 +0800	[thread overview]
Message-ID: <20261127065756.2927925-1-bsdhenrymartin@gmail.com> (raw)

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 <bsdhenrymartin@gmail.com>
---
 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


             reply	other threads:[~2026-11-27  6:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  6:57 Henry Martin [this message]
2026-11-27  7:03 ` [PATCH net] net_sched: hfsc: clear el_node linkage in hfsc_reset_class() netdev-bot+sinfo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261127065756.2927925-1-bsdhenrymartin@gmail.com \
    --to=bsdhenrymartin@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pctammela@mojatatu.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox