[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: trapping execve()
On Thu, May 23, 2002 at 03:12:50AM +0530, Sridhar N wrote:
> 1) why isn't modifying syscalltable safe under module unloading ?
Consider code like this :
asmlinkage static long my_sys_init_module(char const * name_user, struct
module * mod_user)
{
long ret;
ret = old_sys_init_module(name_user, mod_user);
/* some code ... */
return ret;
}
Now consider what happens if a process is sleeping in
old_sys_init_module somewhere (i.e. sleeping in the kernel), and
somebody does a rmmod. This code (my_sys_init_module) is unmapped. Now
the process wakes up and tries to return to "some code" above.
Unfortunately, at this point the vfat module has been autoloaded and
/its/ code is now taking up this space. You just trashed your windows
partition.
You might think that module use counts will help here, but there is
always a tiny window between the decrement of the use count, and the end
of a process needing the code to be mapped[1]
> 2) why isn't the argument to execve not a pointer ?
Well, there's nothing stopping it being a pointer as far as I can see,
but the fact is, it is not, and your code must cope with this as result.
Hope this helps.
regards
john
[1] in fact my tests have /never/ caused this race in this manner, but
that's not the point
--
"I never understood what's so hard about picking a unique
first and last name - and not going beyond the 6 character limit."
- Toon Moene
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/