--- a/kernel/module.c +++ b/kernel/module.c @@ -35,7 +35,7 @@ #include <linux/vermagic.h> #include <linux/notifier.h> #include <linux/sched.h> -#include <linux/stop_machine.h> +#include <linux/freezer.h> #include <linux/device.h> #include <linux/string.h> #include <linux/mutex.h> @@ -618,13 +618,23 @@ static int __try_stop_module(void *_sref return 0; } +static int freeze_machine_run(int (*fn)(void *), void *data, unsigned int cpu) +{ + int ret; + freeze_processes(); + ret = fn(data); + thaw_processes(); + return ret; +} + static int try_stop_module(struct module *mod, int flags, int *forced) { struct stopref sref = { mod, flags, forced }; - return stop_machine_run(__try_stop_module, &sref, NR_CPUS); + return freeze_machine_run(__try_stop_module, &sref, NR_CPUS); } + unsigned int module_refcount(struct module *mod) { unsigned int i, total = 0; @@ -1198,7 +1208,7 @@ static int __unlink_module(void *_mod) static void free_module(struct module *mod) { /* Delete from various lists */ - stop_machine_run(__unlink_module, mod, NR_CPUS); + freeze_machine_run(__unlink_module, mod, NR_CPUS); remove_sect_attrs(mod); mod_kobject_remove(mod); @@ -1997,7 +2007,7 @@ sys_init_module(void __user *umod, /* Now sew it into the lists. They won't access us, since strong_try_module_get() will fail. */ - stop_machine_run(__link_module, mod, NR_CPUS); + freeze_machine_run(__link_module, mod, NR_CPUS); /* Drop lock so they can recurse */ mutex_unlock(&module_mutex); @@ -2124,19 +2134,16 @@ struct module *module_get_kallsym(unsign { struct module *mod; - mutex_lock(&module_mutex); list_for_each_entry(mod, &modules, list) { if (symnum < mod->num_symtab) { *value = mod->symtab[symnum].st_value; *type = mod->symtab[symnum].st_info; strlcpy(name, mod->strtab + mod->symtab[symnum].st_name, namelen); - mutex_unlock(&module_mutex); return mod; } symnum -= mod->num_symtab; } - mutex_unlock(&module_mutex); return NULL; }