Skip to content

Commit

Permalink
module: Wait for RCU synchronizing before releasing a module
Browse files Browse the repository at this point in the history
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 <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
Masami Hiramatsu authored and Rusty Russell committed Nov 11, 2014
1 parent 0df1f24 commit 4f48795
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -3326,6 +3326,8 @@ static int load_module(struct load_info *info, const char __user *uargs,
/* Unlink carefully: kallsyms could be walking list. */
list_del_rcu(&mod->list);
wake_up_all(&module_wq);
/* Wait for RCU synchronizing before releasing mod->list. */
synchronize_rcu();
mutex_unlock(&module_mutex);
free_module:
module_deallocate(mod, info);
Expand Down

0 comments on commit 4f48795

Please sign in to comment.