Skip to content

Commit 4f48795

Browse files
mhiramathitachirustyrussell
authored andcommitted
module: Wait for RCU synchronizing before releasing a module
Wait for RCU synchronizing on failure path of module loading before releasing struct module, because the memory of mod->list can still be accessed by list walkers (e.g. kallsyms). Signed-off-by: Masami Hiramatsu <[email protected]> Signed-off-by: Rusty Russell <[email protected]>
1 parent 0df1f24 commit 4f48795

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

kernel/module.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3326,6 +3326,8 @@ static int load_module(struct load_info *info, const char __user *uargs,
33263326
/* Unlink carefully: kallsyms could be walking list. */
33273327
list_del_rcu(&mod->list);
33283328
wake_up_all(&module_wq);
3329+
/* Wait for RCU synchronizing before releasing mod->list. */
3330+
synchronize_rcu();
33293331
mutex_unlock(&module_mutex);
33303332
free_module:
33313333
module_deallocate(mod, info);

0 commit comments

Comments
 (0)