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]
Date:   Fri, 17 Feb 2017 19:36:29 +0100
From:   Lucas Stach <l.stach@...gutronix.de>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     linux-kernel@...r.kernel.org, patchwork-lst@...gutronix.de,
        kernel@...gutronix.de
Subject: [PATCH] driver core: unbind consumers before locking parent on device unbind

On forced unbind the parent lock is taken, as the device might be a USB
device. The device to be unbound might have active consumers, which
must be unbound before calling device_release_driver(), otherwise this
function might deadlock when trying to take the parent lock during
consumer unbind.

Signed-off-by: Lucas Stach <l.stach@...gutronix.de>
---
 drivers/base/bus.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 6470eb8088f4..23df171a6a64 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -186,6 +186,9 @@ static ssize_t unbind_store(struct device_driver *drv, const char *buf,
 
 	dev = bus_find_device_by_name(bus, NULL, buf);
 	if (dev && dev->driver == drv) {
+		while (device_links_busy(dev)) {
+			device_links_unbind_consumers(dev);
+		}
 		if (dev->parent)	/* Needed for USB */
 			device_lock(dev->parent);
 		device_release_driver(dev);
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ