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: <1334573285-24016-1-git-send-email-hare@suse.de>
Date:	Mon, 16 Apr 2012 12:48:05 +0200
From:	Hannes Reinecke <hare@...e.de>
To:	Linux Kernel <linux-kernel@...r.kernel.org>
Cc:	Hannes Reinecke <hare@...e.de>,
	Greg Kroah-Hartmann <gregkh@...uxfoundation.org>,
	Kay Sievers <ksievers@...y.org>,
	Stable Kernel <stable@...nel.org>
Subject: [PATCH] driver core: check 'start' argument in bus iterators

bus_for_each_dev() and bus_find_device() both take a 'start'
argument to start the iteration at a specific list entry.
However, this list entry might already been detached by
the time these functions are called.
So we need to check if the arguments are still valid.

Signed-off-by: Hannes Reinecke <hare@...e.de>
Cc: Greg Kroah-Hartmann <gregkh@...uxfoundation.org>
Cc: Kay Sievers <ksievers@...y.org>
Cc: Stable Kernel <stable@...nel.org>

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 26a06b8..264e498 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -297,6 +297,9 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start,
 	if (!bus)
 		return -EINVAL;
 
+	if (start && !klist_node_attached(&start->p->knode_bus))
+		return -ENODEV;
+
 	klist_iter_init_node(&bus->p->klist_devices, &i,
 			     (start ? &start->p->knode_bus : NULL));
 	while ((dev = next_device(&i)) && !error)
@@ -331,6 +334,9 @@ struct device *bus_find_device(struct bus_type *bus,
 	if (!bus)
 		return NULL;
 
+	if (start && !klist_node_attached(&start->p->knode_bus))
+		return NULL;
+
 	klist_iter_init_node(&bus->p->klist_devices, &i,
 			     (start ? &start->p->knode_bus : NULL));
 	while ((dev = next_device(&i)))
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ