Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

module: use RCU to synchronize find_module

Allow for a RCU-sched critical section around find_module, following
the lower level find_module_all helper, and switch the two callers
outside of module.c to use such a RCU-sched critical section instead
of module_mutex.

Reviewed-by: Petr Mladek <pmladek@suse.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>

authored by

Christoph Hellwig and committed by
Jessica Yu
a0060505 089049f6

+6 -6
+1 -1
include/linux/module.h
··· 586 586 return within_module_init(addr, mod) || within_module_core(addr, mod); 587 587 } 588 588 589 - /* Search for module by name: must hold module_mutex. */ 589 + /* Search for module by name: must be in a RCU-sched critical section. */ 590 590 struct module *find_module(const char *name); 591 591 592 592 struct symsearch {
+3 -2
kernel/livepatch/core.c
··· 19 19 #include <linux/moduleloader.h> 20 20 #include <linux/completion.h> 21 21 #include <linux/memory.h> 22 + #include <linux/rcupdate.h> 22 23 #include <asm/cacheflush.h> 23 24 #include "core.h" 24 25 #include "patch.h" ··· 58 57 if (!klp_is_module(obj)) 59 58 return; 60 59 61 - mutex_lock(&module_mutex); 60 + rcu_read_lock_sched(); 62 61 /* 63 62 * We do not want to block removal of patched modules and therefore 64 63 * we do not take a reference here. The patches are removed by ··· 75 74 if (mod && mod->klp_alive) 76 75 obj->mod = mod; 77 76 78 - mutex_unlock(&module_mutex); 77 + rcu_read_unlock_sched(); 79 78 } 80 79 81 80 static bool klp_initialized(void)
-1
kernel/module.c
··· 668 668 669 669 struct module *find_module(const char *name) 670 670 { 671 - module_assert_mutex(); 672 671 return find_module_all(name, strlen(name), false); 673 672 } 674 673
+2 -2
kernel/trace/trace_kprobe.c
··· 124 124 if (!p) 125 125 return true; 126 126 *p = '\0'; 127 - mutex_lock(&module_mutex); 127 + rcu_read_lock_sched(); 128 128 ret = !!find_module(tk->symbol); 129 - mutex_unlock(&module_mutex); 129 + rcu_read_unlock_sched(); 130 130 *p = ':'; 131 131 132 132 return ret;