Netdev List
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: netdev@vger.kernel.org, jiri@resnulli.us, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, petrm@mellanox.com,
	security@kernel.org, g1042620637@gmail.com
Subject: Re: [PATCH net v4 1/1] net: sched: fix ets qdisc OOB Indexing
Date: Sun, 12 Jan 2025 15:53:56 -0800	[thread overview]
Message-ID: <Z4RWFNIvS31kVhvA@pop-os.localdomain> (raw)
In-Reply-To: <20250111145740.74755-1-jhs@mojatatu.com>

On Sat, Jan 11, 2025 at 09:57:39AM -0500, Jamal Hadi Salim wrote:
> diff --git a/net/sched/sch_ets.c b/net/sched/sch_ets.c
> index f80bc05d4c5a..516038a44163 100644
> --- a/net/sched/sch_ets.c
> +++ b/net/sched/sch_ets.c
> @@ -91,6 +91,8 @@ ets_class_from_arg(struct Qdisc *sch, unsigned long arg)
>  {
>  	struct ets_sched *q = qdisc_priv(sch);
>  
> +	if (arg == 0 || arg > q->nbands)
> +		return NULL;
>  	return &q->classes[arg - 1];
>  }

I must miss something here. Some callers of this function don't handle
NULL at all, so are you sure it is safe to return NULL for all the
callers here??

For one quick example:

322 static int ets_class_dump_stats(struct Qdisc *sch, unsigned long arg,
323                                 struct gnet_dump *d)
324 {
325         struct ets_class *cl = ets_class_from_arg(sch, arg);
326         struct Qdisc *cl_q = cl->qdisc;

'cl' is not checked against NULL before dereferencing it.

There are other cases too, please ensure _all_ of them handle NULL
correctly.

Thanks!

  parent reply	other threads:[~2025-01-12 23:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-11 14:57 [PATCH net v4 1/1] net: sched: fix ets qdisc OOB Indexing Jamal Hadi Salim
2025-01-11 21:01 ` Jakub Kicinski
2025-01-11 21:17   ` Jamal Hadi Salim
2025-01-11 21:26     ` Jakub Kicinski
2025-01-12 23:53 ` Cong Wang [this message]
2025-01-13 10:21   ` Petr Machata
2025-01-13 11:47     ` Jamal Hadi Salim
2025-01-16  4:36       ` Cong Wang
2025-01-16  8:30         ` Paolo Abeni
2025-01-16 13:35           ` Jamal Hadi Salim
2025-01-22 18:40             ` Jamal Hadi Salim
2025-01-23  3:36               ` Jakub Kicinski
2025-01-23  3:40 ` 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=Z4RWFNIvS31kVhvA@pop-os.localdomain \
    --to=xiyou.wangcong@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=g1042620637@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=petrm@mellanox.com \
    --cc=security@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