kmod patch

Charles Anderson (caa@wavefront.com)
Wed, 26 Aug 1998 10:18:35 -0500 (CDT)


I've been getting oops trying to load modules from kmod ever since 106,
every time a new kernel came out I'd give it a try to see if it would fix
my oops (none did). Well last night I finally made the time to look and fix
it myself. In the process I came up with several questions. Foremost being
why hadn't anyone else had this problem, it's been quite consistent for me?
Also, when are modutils going to changed to get rid of kerneld, it fails
to build, and is not needed?

I traced my problem to the creation of the kernel thread for running
modprobe. The oops happened in lookup_dentry when current->fs->root
was dereferenced. I added printks that showed both root and pwd were
null. I traced back from the kernel_thread call to exec_modprobe and
found that the first routine called in exec_modprobe use_init_file_context
was my culprit. use_init_file_context's job is to change context to make
it seem as if init started modprobe. First thing it does is close_fs(current)
(why do the kernel_thread with CLONE_FS, if we're gonna close it?) then
assigns current->fs with task_init->fs. This is the problem. task_init
is #define'd as task[smp_num_cpus], smp_num_cpus on my box is 1, I don't
know what task[1] is but it doesn't have fs->root or fs->pwd set to anything.
I'm not sure if this is because I have a dual processor MB with only one
CPU or what. I changed this to init_task.fs and all is well.

Does anyone have any of the answers?

Thank you,
-Charlie

Here is the patch
--- kmod.c-orig Wed Aug 26 09:54:21 1998
+++ kmod.c Wed Aug 26 09:54:21 1998
@@ -31,7 +31,6 @@
(ppid and {e,}gid are not adjusted, but that shouldn't
be a problem since we trust modprobe)
*/
-#define task_init task[smp_num_cpus]
static inline void
use_init_file_context(void)
@@ -40,7 +39,7 @@
/* don't use the user's root, use init's root instead */
exit_fs(current); /* current->fs->count--; */
- current->fs = task_init->fs;
+ current->fs = init_task.fs;
atomic_inc(&current->fs->count);
unlock_kernel();

-- 
Charles Anderson - caa@wavefront.com              -finger for PGP public key

Disclaimer: They tell me disclaimers are useless, so here's mine: thhhppt...

- 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.altern.org/andrebalsa/doc/lkml-faq.html