aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/module.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/kernel/module.c b/kernel/module.c
index 331b03f6b411..bed608b8c8a6 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1697,18 +1697,6 @@ static void mod_sysfs_teardown(struct module *mod)
1697 mod_sysfs_fini(mod); 1697 mod_sysfs_fini(mod);
1698} 1698}
1699 1699
1700/*
1701 * unlink the module with the whole machine is stopped with interrupts off
1702 * - this defends against kallsyms not taking locks
1703 */
1704static int __unlink_module(void *_mod)
1705{
1706 struct module *mod = _mod;
1707 list_del(&mod->list);
1708 module_bug_cleanup(mod);
1709 return 0;
1710}
1711
1712#ifdef CONFIG_DEBUG_SET_MODULE_RONX 1700#ifdef CONFIG_DEBUG_SET_MODULE_RONX
1713/* 1701/*
1714 * LKM RO/NX protection: protect module's text/ro-data 1702 * LKM RO/NX protection: protect module's text/ro-data
@@ -1860,7 +1848,11 @@ static void free_module(struct module *mod)
1860 1848
1861 /* Now we can delete it from the lists */ 1849 /* Now we can delete it from the lists */
1862 mutex_lock(&module_mutex); 1850 mutex_lock(&module_mutex);
1863 stop_machine(__unlink_module, mod, NULL); 1851 /* Unlink carefully: kallsyms could be walking list. */
1852 list_del_rcu(&mod->list);
1853 /* Wait for RCU synchronizing before releasing mod->list. */
1854 synchronize_rcu();
1855 module_bug_cleanup(mod);
1864 mutex_unlock(&module_mutex); 1856 mutex_unlock(&module_mutex);
1865 1857
1866 /* This may be NULL, but that's OK */ 1858 /* This may be NULL, but that's OK */