Hello Robert.... On Sun, Jun 28, 2009 at 10:47 PM, Robert P. J. Day<rpjday@xxxxxxxxxxxxxx> wrote: > > as a followup to my earlier post about writing a kernel newbies > column for linux.com, i'm hoping to use this mailing list to ask the > occasional question for someone to clarify when, quite simply, i don't > have the time since i have about eight things on the go right now and > it would be ever so convenient if others decided to dig into some of > the more arcane details that i'd add to a future piece. > > right now, i'm trying to clarify what you can and can't do with a > module that's been loaded and marked as "[permanent]". as i read it > (can't remember where now), if you manually load a module that has no > registered module_exit() routine, that module will show under "lsmod" > as "[permanent]" and is no longer unloadable. you can see that from > this snippet from kernel/module.c in the print_unload_info() routine: > > if (mod->init != NULL && mod->exit == NULL) { > printed_something = 1; > seq_printf(m, "[permanent],"); > } > > i did test that with a trivial module and, sure enough, that's how > lsmod displayed it, and trying to unload it normally with "rmmod" told > me it was busy (even though no one else was using it). fair enough. > but is that the whole story? In kernel/module.c, I see function which is declared like this: SYSCALL_DEFINE2(delete_module, const char __user *, name_user, unsigned int, flags) and few lines below that, you'll see: /* If it has an init func, it must have an exit func to unload */ if (mod->init && !mod->exit) { forced = try_force_unload(flags); if (!forced) { /* This module can't be removed */ ret = -EBUSY; goto out; } } let's assume the code doesn't reach "goto out". Then few lines below that we shall see a call to free_module(). Brief check of the code inside that function (theoritically) convince me that you can wipe your "permanent" module. However, it won't guarantee that it will exit cleanly i.e still grabbing a lock or unused page not being kfree()-d. You got the idea anyway. regards, Mulyadi. -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ