Commit 4f48795b authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Rusty Russell

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: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 0df1f248
...@@ -3326,6 +3326,8 @@ static int load_module(struct load_info *info, const char __user *uargs, ...@@ -3326,6 +3326,8 @@ static int load_module(struct load_info *info, const char __user *uargs,
/* Unlink carefully: kallsyms could be walking list. */ /* Unlink carefully: kallsyms could be walking list. */
list_del_rcu(&mod->list); list_del_rcu(&mod->list);
wake_up_all(&module_wq); wake_up_all(&module_wq);
/* Wait for RCU synchronizing before releasing mod->list. */
synchronize_rcu();
mutex_unlock(&module_mutex); mutex_unlock(&module_mutex);
free_module: free_module:
module_deallocate(mod, info); module_deallocate(mod, info);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment