lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <acc2f5949d2ab4562be3c28a6131fecefbaf8db1.1509040243.git.dcaratti@redhat.com>
Date:   Thu, 26 Oct 2017 20:26:48 +0200
From:   Davide Caratti <dcaratti@...hat.com>
To:     Jiri Pirko <jiri@...nulli.us>,
        "David S. Miller" <davem@...emloft.net>,
        Cong Wang <xiyou.wangcong@...il.com>,
        Jamal Hadi Salim <jhs@...atatu.com>
Cc:     Jiri Kosina <jkosina@...e.cz>, netdev@...r.kernel.org
Subject: [PATCH net] net/sched: fix NULL pointer dereference in qdisc_alloc()

the following script generates a NULL pointer dereference error:

ip l a name eth0 type dummy
tc q a dev eth0 parent :1 handle 1: htb

upon creation of classful qdiscs, qdisc_alloc() dereferences dev_queue->dev
assuming it is not NULL. This is not true when eth0 has been added, but not
yet set administratively up; a bisect test proved that Linux started making
NULL exception with the above two commands after commit 59cc1f61f09c ("net:
sched:convert qdisc linked list to hashtable"). Let qdisc_alloc() return -1
(-ENOENT) when a NULL value of dev_queue->dev is seen, so that non-crashing
behaviour observable in Linux 4.8 is restored.

Fixes: 59cc1f61f09c ("net: sched:convert qdisc linked list to hashtable")
Signed-off-by: Davide Caratti <dcaratti@...hat.com>
---
 net/sched/sch_generic.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index bf8c81e07c70..5fb96f43d951 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -605,6 +605,14 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
 	int err = -ENOBUFS;
 	struct net_device *dev = dev_queue->dev;
 
+	/* dev_queue->dev can be NULL, if device has been registered but not
+	 * (yet) set administratively up: test it to avoid NULL dereference.
+	 */
+	if (!dev) {
+		err = -ENOENT;
+		goto errout;
+	}
+
 	p = kzalloc_node(size, GFP_KERNEL,
 			 netdev_queue_numa_node_read(dev_queue));
 
-- 
2.13.6

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ