Re: How to unload a buggy LKM without rebooting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> MOD_INC_USE_COUNT and MOD_DEC_USE_COUNT are incorrect on SMP. That is,
> if they are called from the module, there is a race condition.
>
Hmmm...but this code from linux/include/linux/module.h says atomic_inc.

#define __MOD_INC_USE_COUNT(mod)       \
    (atomic_inc(&(mod)->uc.usecount), (mod)->flags |=
MOD_VISITED|MOD_USED_ONCE)

> Anyway, such module may be unloaded using kgdb, or maybe even gdb on
> /proc/kcore - you zero out the counter manually. Or you can write
> a simple module, that will zero the count (it will only have the init
> function, which will return error at the end, so nothing will be actualy
> loaded).

Well ive an idea, plz tellme if this is feasible.

We traverse the list of modules by doing:

struct module *mod_list = THIS_MODULE;

and identify the module which has faulted.
Then manually doin some cleanups.

in linux/kernel/module.c i saw this code:
sys_delete_module(const char *name_user);
{ 
        : 
        :
               if (!__MOD_IN_USE(mod)) {
                        mod->flags |= MOD_DELETED;
                         spin_unlock(&unload_lock);
                        free_module(mod, 0);
                        error = 0;
                 } else {
            /* We can do cleanup here */
                        spin_unlock(&unload_lock);
                 }
            goto out;
        :
        :
}

Well, but i think this would also introduce bugs. 
Anybody who knows what r those ??

-nagaraj
\(*_*)/




--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux