From: Vinicius Costa Gomes <vinicius.gomes@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [next-queue PATCH v6 1/5] net/sched: Check for null dev_queue on create flow
Date: Wed, 11 Oct 2017 17:54:45 -0700 [thread overview]
Message-ID: <20171012005449.26533-2-vinicius.gomes@intel.com> (raw)
In-Reply-To: <20171012005449.26533-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
WARNING: multiple messages have this Message-ID (diff)
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 v6 1/5] net/sched: Check for null dev_queue on create flow
Date: Wed, 11 Oct 2017 17:54:45 -0700 [thread overview]
Message-ID: <20171012005449.26533-2-vinicius.gomes@intel.com> (raw)
In-Reply-To: <20171012005449.26533-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
next prev parent reply other threads:[~2017-10-12 0:54 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-12 0:54 [Intel-wired-lan] [next-queue PATCH v6 0/5] TSN: Add qdisc based config interface for CBS Vinicius Costa Gomes
2017-10-12 0:54 ` Vinicius Costa Gomes
2017-10-12 0:54 ` Vinicius Costa Gomes [this message]
2017-10-12 0:54 ` [next-queue PATCH v6 1/5] net/sched: Check for null dev_queue on create flow Vinicius Costa Gomes
2017-10-12 0:54 ` [Intel-wired-lan] [next-queue PATCH v6 2/5] mqprio: Implement select_queue class_ops Vinicius Costa Gomes
2017-10-12 0:54 ` Vinicius Costa Gomes
2017-10-12 15:21 ` [Intel-wired-lan] " Alexander Duyck
2017-10-12 15:21 ` Alexander Duyck
2017-10-12 15:59 ` Jesus Sanchez-Palencia
2017-10-12 15:59 ` Jesus Sanchez-Palencia
2017-10-12 16:09 ` Alexander Duyck
2017-10-12 16:09 ` Alexander Duyck
2017-10-12 16:16 ` Jesus Sanchez-Palencia
2017-10-12 16:16 ` Jesus Sanchez-Palencia
2017-10-12 0:54 ` [Intel-wired-lan] [next-queue PATCH v6 3/5] net/sched: Introduce Credit Based Shaper (CBS) qdisc Vinicius Costa Gomes
2017-10-12 0:54 ` Vinicius Costa Gomes
2017-10-12 1:32 ` [Intel-wired-lan] " Eric Dumazet
2017-10-12 1:32 ` Eric Dumazet
2017-10-12 17:50 ` [Intel-wired-lan] " Vinicius Costa Gomes
2017-10-12 17:50 ` Vinicius Costa Gomes
2017-10-12 7:58 ` [Intel-wired-lan] " Henrik Austad
2017-10-12 7:58 ` Henrik Austad
2017-10-12 15:45 ` [Intel-wired-lan] " Jesus Sanchez-Palencia
2017-10-12 15:45 ` Jesus Sanchez-Palencia
2017-10-12 0:54 ` [Intel-wired-lan] [next-queue PATCH v6 4/5] net/sched: Add support for HW offloading for CBS Vinicius Costa Gomes
2017-10-12 0:54 ` Vinicius Costa Gomes
2017-10-12 8:04 ` [Intel-wired-lan] " Henrik Austad
2017-10-12 8:04 ` Henrik Austad
2017-10-12 0:54 ` [Intel-wired-lan] [next-queue PATCH v6 5/5] igb: Add support for CBS offload Vinicius Costa Gomes
2017-10-12 0:54 ` Vinicius Costa Gomes
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=20171012005449.26533-2-vinicius.gomes@intel.com \
--to=vinicius.gomes@intel.com \
--cc=intel-wired-lan@osuosl.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 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.