netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Peilin Ye <yepeilin.cs@gmail.com>, Jamal Hadi Salim <jhs@mojatatu.com>
Cc: shaozhengchao <shaozhengchao@huawei.com>,
	netdev@vger.kernel.org,  xiyou.wangcong@gmail.com,
	jiri@resnulli.us, davem@davemloft.net,  edumazet@google.com,
	kuba@kernel.org, weiyongjun1@huawei.com,  yuehaibing@huawei.com,
	wanghai38@huawei.com, peilin.ye@bytedance.com,
	 cong.wang@bytedance.com
Subject: Re: [PATCH net] net: sched: fix NULL pointer dereference in mq_attach
Date: Tue, 30 May 2023 12:16:10 +0200	[thread overview]
Message-ID: <9cf98c8ae48c99850a0a25ae7919420ce5dfa7b4.camel@redhat.com> (raw)
In-Reply-To: <ZHVAlCtzFeJrwKvc@C02FL77VMD6R.googleapis.com>

On Mon, 2023-05-29 at 17:17 -0700, Peilin Ye wrote:
> On Mon, May 29, 2023 at 09:53:28AM -0400, Jamal Hadi Salim wrote:
> > On Mon, May 29, 2023 at 4:59 AM Peilin Ye <yepeilin.cs@gmail.com> wrote:
> > > Ack, they are different: patch [4/6] prevents ingress (clsact) Qdiscs
> > > from being regrafted (to elsewhere), and Zhengchao's patch prevents other
> > > Qdiscs from being regrafted to ffff:fff1.
> > 
> > Ok, at first glance it was not obvious.
> > Do we catch all combinations? for egress (0xffffffff) allowed minor is
> > 0xfff3 (clsact::) and 0xffff. For ingress (0xfffffff1) allowed minor
> > is 0xfff1 and 0xfff2(clsact).
> 
> ffff:fff1 is special in tc_modify_qdisc(); if minor isn't fff1,
> tc_modify_qdisc() thinks user wants to graft a Qdisc under existing ingress
> or clsact Qdisc:
> 
> 	if (clid != TC_H_INGRESS) {	/* ffff:fff1 */
> 		p = qdisc_lookup(dev, TC_H_MAJ(clid));
> 		if (!p) {
> 			NL_SET_ERR_MSG(extack, "Failed to find specified qdisc");
> 			return -ENOENT;
> 		}
> 		q = qdisc_leaf(p, clid);
> 	} else if (dev_ingress_queue_create(dev)) {
> 		q = dev_ingress_queue(dev)->qdisc_sleeping;
> 	}
> 
> This will go to the "parent != NULL" path in qdisc_graft(), and
> sch_{ingress,clsact} doesn't implement cl_ops->graft(), so -EOPNOTSUPP will
> be returned.
> 
> In short, yes, I think ffff:fff1 is the only case should be fixed.
> 
> By the way I just noticed that currently it is possible to create a e.g.
> HTB class with a class ID of ffff:fff1...
> 
>   $ tc qdisc add dev eth0 root handle ffff: htb default fff1
>   $ tc class add dev eth0 \
>             parent ffff: classid ffff:fff1 htb rate 100%
> 
> Regrafting a Qdisc to such classes won't work as intended at all.  It's a
> separate issue though.

Jamal, are you ok with the above explanation? Perhaps it would be
worthy to add a specific test-case under tc-testing for this issue?

Thanks!

Paolo


  parent reply	other threads:[~2023-05-30 10:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-27  9:37 [PATCH net] net: sched: fix NULL pointer dereference in mq_attach Zhengchao Shao
2023-05-28 19:05 ` Jamal Hadi Salim
2023-05-29  1:10   ` shaozhengchao
2023-05-29  8:59     ` Peilin Ye
2023-05-29 10:18       ` shaozhengchao
2023-05-29 13:53       ` Jamal Hadi Salim
2023-05-30  0:17         ` Peilin Ye
2023-05-30  2:45           ` shaozhengchao
2023-05-30 10:16           ` Paolo Abeni [this message]
2023-05-31  0:35             ` Peilin Ye
2023-05-31  1:00               ` shaozhengchao
2023-05-31  0:43             ` Jamal Hadi Salim
2023-05-30  1:07 ` Peilin Ye
2023-05-31  0:50 ` Jamal Hadi Salim
2023-05-31  6: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=9cf98c8ae48c99850a0a25ae7919420ce5dfa7b4.camel@redhat.com \
    --to=pabeni@redhat.com \
    --cc=cong.wang@bytedance.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peilin.ye@bytedance.com \
    --cc=shaozhengchao@huawei.com \
    --cc=wanghai38@huawei.com \
    --cc=weiyongjun1@huawei.com \
    --cc=xiyou.wangcong@gmail.com \
    --cc=yepeilin.cs@gmail.com \
    --cc=yuehaibing@huawei.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;
as well as URLs for NNTP newsgroup(s).