netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vinicius Costa Gomes <vinicius.gomes@intel.com>
To: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org
Cc: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>,
	jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us,
	andre.guedes@intel.com, ivan.briano@intel.com,
	boon.leong.ong@intel.com, richardcochran@gmail.com,
	henrik@austad.us, levipearson@gmail.com, rodney.cummings@ni.com
Subject: [next-queue PATCH v5 1/5] net/sched: Check for null dev_queue on create flow
Date: Tue, 10 Oct 2017 17:43:56 -0700	[thread overview]
Message-ID: <20171011004400.14946-2-vinicius.gomes@intel.com> (raw)
In-Reply-To: <20171011004400.14946-1-vinicius.gomes@intel.com>

From: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>

In qdisc_alloc() the dev_queue pointer was used without any checks
being performed. If qdisc_create() gets a null dev_queue pointer, it
just passes it along to qdisc_alloc(), leading to a crash. That
happens if a root qdisc implements select_queue() and returns a null
dev_queue pointer for an "invalid handle", for example, or if the
dev_queue associated with the parent qdisc is null.

This patch is in preparation for the next in this series, where
select_queue() is being added to mqprio and as it may return a null
dev_queue.

Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
---
 net/sched/sch_generic.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index a0a198768aad..de2408f1ccd3 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -603,8 +603,14 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
 	struct Qdisc *sch;
 	unsigned int size = QDISC_ALIGN(sizeof(*sch)) + ops->priv_size;
 	int err = -ENOBUFS;
-	struct net_device *dev = dev_queue->dev;
+	struct net_device *dev;
+
+	if (!dev_queue) {
+		err = -EINVAL;
+		goto errout;
+	}
 
+	dev = dev_queue->dev;
 	p = kzalloc_node(size, GFP_KERNEL,
 			 netdev_queue_numa_node_read(dev_queue));
 
-- 
2.14.2

  reply	other threads:[~2017-10-11  0:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11  0:43 [next-queue PATCH v5 0/5] TSN: Add qdisc based config interface for CBS Vinicius Costa Gomes
2017-10-11  0:43 ` Vinicius Costa Gomes [this message]
2017-10-11  0:43 ` [next-queue PATCH v5 2/5] mqprio: Implement select_queue class_ops Vinicius Costa Gomes
2017-10-11  0:43 ` [next-queue PATCH v5 3/5] net/sched: Introduce Credit Based Shaper (CBS) qdisc Vinicius Costa Gomes
2017-10-11  6:58   ` Jiri Pirko
2017-10-11 21:38     ` Vinicius Costa Gomes
2017-10-11  0:43 ` [next-queue PATCH v5 4/5] net/sched: Add support for HW offloading for CBS Vinicius Costa Gomes
2017-10-11  7:07   ` Jiri Pirko
2017-10-11 21:40     ` Vinicius Costa Gomes
2017-10-11  0:44 ` [next-queue PATCH v5 5/5] igb: Add support for CBS offload Vinicius Costa Gomes
2017-10-11  3:23 ` [next-queue PATCH v5 0/5] TSN: Add qdisc based config interface for CBS David Miller

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=20171011004400.14946-2-vinicius.gomes@intel.com \
    --to=vinicius.gomes@intel.com \
    --cc=andre.guedes@intel.com \
    --cc=boon.leong.ong@intel.com \
    --cc=henrik@austad.us \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=ivan.briano@intel.com \
    --cc=jesus.sanchez-palencia@intel.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=levipearson@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=rodney.cummings@ni.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 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).