From: Victor Nogueira <victor@mojatatu.com>
To: netdev@vger.kernel.org
Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, toke@redhat.com, gerrard.tai@starlabs.sg,
pctammela@mojatatu.com, stephen@networkplumber.org
Subject: [PATCH net v3 2/5] net_sched: hfsc: Fix a UAF vulnerability in class with netem as child qdisc
Date: Fri, 25 Apr 2025 19:07:06 -0300 [thread overview]
Message-ID: <20250425220710.3964791-3-victor@mojatatu.com> (raw)
In-Reply-To: <20250425220710.3964791-1-victor@mojatatu.com>
As described in Gerrard's report [1], we have a UAF case when an hfsc class
has a netem child qdisc. The crux of the issue is that hfsc is assuming
that checking for cl->qdisc->q.qlen == 0 guarantees that it hasn't inserted
the class in the vttree or eltree (which is not true for the netem
duplicate case).
This patch checks the n_active class variable to make sure that the code
won't insert the class in the vttree or eltree twice, catering for the
reentrant case.
[1] https://lore.kernel.org/netdev/CAHcdcOm+03OD2j6R0=YHKqmy=VgJ8xEOKuP6c7mSgnp-TEJJbw@mail.gmail.com/
Fixes: 37d9cf1a3ce3 ("sched: Fix detection of empty queues in child qdiscs")
Reported-by: Gerrard Tai <gerrard.tai@starlabs.sg>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Victor Nogueira <victor@mojatatu.com>
---
net/sched/sch_hfsc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index 6c8ef826cec0..cb8c525ea20e 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -1569,7 +1569,7 @@ hfsc_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free)
return err;
}
- if (first) {
+ if (first && !cl->cl_nactive) {
if (cl->cl_flags & HFSC_RSC)
init_ed(cl, len);
if (cl->cl_flags & HFSC_FSC)
--
2.34.1
next prev parent reply other threads:[~2025-04-25 22:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-25 22:07 [PATCH net v3 0/5] net_sched: Adapt qdiscs for reentrant enqueue cases Victor Nogueira
2025-04-25 22:07 ` [PATCH net v3 1/5] net_sched: drr: Fix double list add in class with netem as child qdisc Victor Nogueira
2025-04-25 22:07 ` Victor Nogueira [this message]
2025-04-25 22:07 ` [PATCH net v3 3/5] net_sched: ets: " Victor Nogueira
2025-04-25 22:07 ` [PATCH net v3 4/5] net_sched: qfq: " Victor Nogueira
2025-04-25 22:07 ` [PATCH net v3 5/5] selftests: tc-testing: Add TDC tests that exercise reentrant enqueue behaviour Victor Nogueira
2025-04-28 23:00 ` [PATCH net v3 0/5] net_sched: Adapt qdiscs for reentrant enqueue cases patchwork-bot+netdevbpf
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=20250425220710.3964791-3-victor@mojatatu.com \
--to=victor@mojatatu.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gerrard.tai@starlabs.sg \
--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=stephen@networkplumber.org \
--cc=toke@redhat.com \
--cc=xiyou.wangcong@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.