Skip to content

Commit 461e34a

Browse files
mhiramathitachirustyrussell
authored andcommitted
module: Unlink module with RCU synchronizing instead of stop_machine
Unlink module from module list with RCU synchronizing instead of using stop_machine(). Since module list is already protected by rcu, we don't need stop_machine() anymore. Signed-off-by: Masami Hiramatsu <[email protected]> Signed-off-by: Rusty Russell <[email protected]>
1 parent 4f48795 commit 461e34a

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

kernel/module.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,18 +1697,6 @@ static void mod_sysfs_teardown(struct module *mod)
16971697
mod_sysfs_fini(mod);
16981698
}
16991699

1700-
/*
1701-
* unlink the module with the whole machine is stopped with interrupts off
1702-
* - this defends against kallsyms not taking locks
1703-
*/
1704-
static 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-
17121700
#ifdef CONFIG_DEBUG_SET_MODULE_RONX
17131701
/*
17141702
* LKM RO/NX protection: protect module's text/ro-data
@@ -1860,7 +1848,11 @@ static void free_module(struct module *mod)
18601848

18611849
/* Now we can delete it from the lists */
18621850
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);
18641856
mutex_unlock(&module_mutex);
18651857

18661858
/* This may be NULL, but that's OK */

0 commit comments

Comments
 (0)