Re: kmod patch

Greg Zornetzer (gaz@andrew.cmu.edu)
Fri, 27 Mar 1998 23:19:48 -0500 (EST)


Hi everyone,

Here's a patch against my kmod patch (posted a couple of days ago) that (I
think) makes it play a bit nicer... I'm running 2.1.91 compiled with my
enhanced kmod and this patch. Still isn't totally bug free - for some
reason the init scripts wouldn't allow the loopback net interface to come
up. I'm still hunting down places where memory trashing
could be occuring.
Does anyone know if it's a problem to kmalloc memory within the kernel
itself, and then call the kfree on the memory from kmod. I don't think
there should be a problem, but I'm running out of possibilities...
Is there any way to make sense of these unreproduceable crashes? <shrug>
In terms of module loading, it seems solid - I've got 19 modules loaded
currently under it, including parport/lp.
I haven't touched sound, though :)

Greg Zornetzer - gaz+@andrew.cmu.edu
"Light shines brightest in the darkest night"
http://www.contrib.andrew.cmu.edu/~gaz

Patch begins here:

--- kmod.c Thu Mar 26 21:33:09 1998
+++ linux/kernel/kmod.c Sat Mar 28 22:41:17 1998
@@ -25,8 +25,6 @@
#define MODRQ_FAILURE 8
#define MODRQ_CLEANUP 16

-static inline _syscall1(int,delete_module,const char *,name_user)
-
/*
kmod_unload_delay and modprobe_path are set via /proc/sys.
kmod_active prevents module requests from being honored
@@ -49,8 +47,8 @@
struct wait_queue *mreq_queue;
int info;
pid_t pid;
- char *module_name;
- char * argv[4];
+ char module_name[64];
+ char *argv[4];
struct modslot *next;
};

@@ -66,7 +64,7 @@
static struct semaphore queue_access = MUTEX;


-struct modslot *makeslot(int info, char *modname)
+struct modslot *makeslot(int info, const char *modname)
{
int i;
struct modslot *slot;
@@ -74,9 +72,12 @@
slot->mreq_queue = NULL;
slot->pid = -1;
slot->info = info;
- slot->module_name = modname;
for(i=0;i < 4;i++)
slot->argv[i] = template_argv[i];
+ strncpy(slot->module_name, modname, sizeof(slot->module_name));
+ slot->module_name[sizeof(slot->module_name)-1] = '\0';
+ slot->argv[2] = slot->module_name;
+
slot->next = modlist;
modlist = slot;

@@ -102,7 +103,7 @@

void install_module(struct modslot *slot) {
pid_t pid, pid2;
-
+ int err;
/*
By forking off two processes, we create a system where the main
kmod loop can keep going while a request is being served.
@@ -121,9 +122,9 @@
Call modprobe with module_name. If execve
returns,
print out an error.
*/
- slot->argv[2] = slot->module_name;
- execve(modprobe_path, slot->argv, envp);
+ err = execve(modprobe_path, slot->argv, envp);
printk("Modprobe load failed - couldn't load
%s\n",slot->module_name);
+ printk("Error code %d\n");
slot->info = MODRQ_FAILURE;
_exit(0);
} else {
@@ -185,7 +186,8 @@
break;

case MODRQ_CLEANUP :
- waitpid(slot->pid,NULL,0);
+ if(waitpid(slot->pid,NULL,0) != slot->pid)
+ printk("Something fishy\n");
delslot(&last, &slot);
break;

@@ -222,7 +224,7 @@
*/

down(&queue_access);
- makeslot(MODRQ_REMOVE, NULL);
+ makeslot(MODRQ_REMOVE, "");

wake_up(&kmod_queue);
up(&queue_access);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu