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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0704011011080.6730@woody.linux-foundation.org>
Date:	Sun, 1 Apr 2007 10:17:18 -0700 (PDT)
From:	Linus Torvalds <torvalds@...ux-foundation.org>
To:	Pavel Machek <pavel@....cz>
cc:	Ingo Molnar <mingo@...e.hu>, Adrian Bunk <bunk@...sta.de>,
	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org, Greg Kroah-Hartman <gregkh@...e.de>
Subject: Re: [bug] hung bootup in various drivers, was: "2.6.21-rc5: known
 regressions"



On Sun, 1 Apr 2007, Pavel Machek wrote:
> 
> > @@ -183,7 +183,8 @@ int driver_register(struct device_driver
> >  void driver_unregister(struct device_driver * drv)
> >  {
> >  	bus_remove_driver(drv);
> > -	wait_for_completion(&drv->unloaded);
> > +	if (!drv->unloaded.done)
> > +		WARN_ON(1);
> >  }
> 
> WARN_ON(!done)?

I think the whole "wait_for_completion()" is just broken. 

We asked to *unregister* the driver, not to wait for users.

I would suggest that for 2.6.21, the minimal fix is actually something 
like the appended. Comments? Ingo, does this fix things for you?

In general, I think the whole "wait for locks" or "wait for users" is 
almost always a sign of a much bigger bug in reference counting. Modules 
are special, though, since module code/data doesn't really get reference 
counted. But doing it for built-in stuff when you don't need to really 
just sounds *wrong*.

		Linus

---
 drivers/base/driver.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 1214cbd..082bfde 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -183,7 +183,14 @@ int driver_register(struct device_driver * drv)
 void driver_unregister(struct device_driver * drv)
 {
 	bus_remove_driver(drv);
-	wait_for_completion(&drv->unloaded);
+	/*
+	 * If the driver is a module, we are probably in
+	 * the module unload path, and we want to wait
+	 * for everything to unload before we can actually
+	 * finish the unload.
+	 */
+	if (drv->owner)
+		wait_for_completion(&drv->unloaded);
 }
 
 /**
-
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