[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:
>
> > First, don't pay attention to that guide, I believe it makes no mention of the horrible
> > module unload race implicit in over-riding system calls with your own code.
>
> Hi John,
> Can you elaborate on the race you are talking about. The document
> does talk about replacing back the original function pointer in the
> syscall table at the time of module unloading.
>
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.
4. Another module is loaded, or the memory is somehow used otherwise
5. The task wakes up and returns to garbage code, causing the kernel to panic.
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().
In my module I took the second option because I couldn't afford the cost of the atomic
operations implicit in MOD_INC/DEC_USE_COUNT
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