From: Jakub Kicinski <kuba@kernel.org>
To: jhs@mojatatu.com
Cc: Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, victor@mojatatu.com, davem@davemloft.net,
edumazet@google.com, pabeni@redhat.com, jiri@resnulli.us,
horms@kernel.org, vinicius.gomes@intel.com,
graypanda.inzag@gmail.com, security@kernel.org
Subject: Re: [PATCH net 1/2] net/sched: sch_cbs: Call qdisc_reset for child qdisc
Date: Wed, 6 May 2026 18:10:46 -0700 [thread overview]
Message-ID: <20260507011046.2172988-1-kuba@kernel.org> (raw)
In-Reply-To: <20260505132102.128903-1-jhs@mojatatu.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
net/sched: sch_cbs: Call qdisc_reset for child qdisc
This commit introduces a reset callback for the CBS qdisc. The new
cbs_reset() function propagates the reset to the child qdisc to prevent
qlen and backlog accounting issues during resets.
> diff --git a/net/sched/sch_cbs.c b/net/sched/sch_cbs.c
> index 8c9a0400c8622..1efd72581614e 100644
> --- a/net/sched/sch_cbs.c
> +++ b/net/sched/sch_cbs.c
> @@ -243,6 +243,16 @@ static struct sk_buff *cbs_dequeue(struct Qdisc *sch)
> return q->dequeue(sch);
> }
>
> +static void cbs_reset(struct Qdisc *sch)
> +{
> + struct cbs_sched_data *q = qdisc_priv(sch);
> +
> + qdisc_reset(q->qdisc);
Can this cause a null pointer dereference during qdisc teardown?
If a CBS qdisc is created and cbs_init() fails (for example, if opt is null),
it returns -EINVAL leaving q->qdisc and q->watchdog uninitialized.
The cleanup path in qdisc_create_dflt() will call qdisc_put(), which
triggers __qdisc_destroy(). __qdisc_destroy() unconditionally calls
qdisc_reset() before calling ops->destroy().
Because q->qdisc is null here, calling qdisc_reset(q->qdisc) would
dereference a null pointer.
> + qdisc_watchdog_cancel(&q->watchdog);
Similarly, could this trigger a crash by calling hrtimer_cancel() on an
uninitialized timer?
Does cbs_reset() need an early return if q->qdisc is null, similar to the
safety guard already present in cbs_destroy(), to prevent these issues?
> + q->credits = 0;
> + q->last = 0;
> +}
> +
--
pw-bot: cr
prev parent reply other threads:[~2026-05-07 1:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 13:21 [PATCH net 1/2] net/sched: sch_cbs: Call qdisc_reset for child qdisc Jamal Hadi Salim
2026-05-05 13:21 ` [PATCH net 2/2] selftests/tc-testing: Add QFQ/CBS qlen underflow test Jamal Hadi Salim
2026-05-07 1:10 ` Jakub Kicinski [this message]
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=20260507011046.2172988-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=graypanda.inzag@gmail.com \
--cc=horms@kernel.org \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=security@kernel.org \
--cc=victor@mojatatu.com \
--cc=vinicius.gomes@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox