[patch] 2.3.99-pre3: xd_open race

From: Tim Waugh (tim@cyberelk.demon.co.uk)
Date: Mon Mar 27 2000 - 13:54:01 EST


Folks,

Here is a patch to close a race condition in xd_open. We drop the kernel
lock when sleeping, so we have to call MOD_INC_USE_COUNT _first_, to avoid
being unloaded.

There are _lots_ and _lots_ of places in the kernel that do this wrong. I
have a huge list here.

Maintainers -- check your code for this kind of stuff!

Tim.
*/

--- linux/drivers/block/xd.c~ Mon Feb 21 21:38:51 2000
+++ linux/drivers/block/xd.c Mon Mar 27 19:50:50 2000
@@ -258,12 +258,10 @@ static int xd_open (struct inode *inode,
         int dev = DEVICE_NR(inode->i_rdev);
 
         if (dev < xd_drives) {
+ MOD_INC_USE_COUNT;
+
                 while (!xd_valid[dev])
                         sleep_on(&xd_wait_open);
-
-#ifdef MODULE
- MOD_INC_USE_COUNT;
-#endif /* MODULE */
 
                 xd_access[dev]++;
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Mar 31 2000 - 21:00:20 EST