[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about EXPORT_SYMBOL



On Mon, 19 Feb 2001, Sourav Sen wrote:

> > It goes like this :
> > 
> > 	1. module overtakes system call that calls a routine that can cause the task to
> > 	   to sleep (kmalloc(), another system call etc. etc.)
> > 	2. The task sleeps
> > 	3. The module is unloaded.
> 
> 	But that may happen even for a normal module that do not replace a
> syscall by a fn. And hence the recommendation that is found in almost 
> every module writing resource that always use MOD_INC/DEC while
> loading/unloading a module to prevent accidental unloading.

no, because you either do the INC/DEC in the open()/release() routines for 
the device, or you use the owner field of fops with value THIS_MODULE. That
is easy to protect against (basically use the owner field !), this problem is
far more fiddly.

> > You can either add MOD_INC/DEC_USE_COUNTs to your system call code (although this will still
> > leave a very tiny race window), or make the module not unloadable by using can_unload().
> 
> 	So the method is not altogether broken, right!!

It's not, but you have to use one of the two methods I mention.

And of course doing this at all is frowned upon.

john

-- 
"Allocation is a fatal error."
	- me, cpd_util.c. Never document at 4AM

-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.surriel.com/kernelnewbies.shtml