What protects cleanup_module() from open()?

Bret Indrelee (bindrelee@sbs-cp.com)
Tue, 30 Nov 1999 10:34:31 -0600


I haven't found anything that appears to close a race condition with device
drivers created as loadable modules.

Modules are serialized by the kernel_lock during init_module() and
cleanup_module(). In order to prevent modules from being unloaded, a module
is supposed to do a MOD_INC_USE_COUNT. This can't be done in the
init_module(), because then it would never unload. It looks to me as if this
is usually done in the open routine.

What is to prevent a module from being unloaded in the window between the
time that the OS has found the file operation for open (in get_fops() from
fs/devices.c) and the time that the open routine executes MOD_INC_USE_COUNT?

It seems to me that either all opens have to use the same mutex as used for
loading modules, or the modules have to put in some sort of protection to
prevent this.

-Bret

-------------------------------------------------------------
SBS Technologies, Connectivity Products
... solutions for real-time connectivity

Bret Indrelee, Engineer
SBS Technologies, Inc., Connectivity Products
1284 Corporate Center Drive, St. Paul MN 55121
Direct: (651) 905-4731
Main: (651) 905-4700 Fax: (651) 905-4701
E-mail: bindrelee@sbs-cp.com http://www.sbs.com
-------------------------------------------------------------

-
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/