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.

kallsyms: refactor {,module_}kallsyms_on_each_symbol

Require an explicit call to module_kallsyms_on_each_symbol to look
for symbols in modules instead of the call from kallsyms_on_each_symbol,
and acquire module_mutex inside of module_kallsyms_on_each_symbol instead
of leaving that up to the caller. Note that this slightly changes the
behavior for the livepatch code in that the symbols from vmlinux are not
iterated anymore if objname is set, but that actually is the desired
behavior in this case.

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
013c1667 a0060505

+9 -12
+5 -1
kernel/kallsyms.c
··· 177 177 return module_kallsyms_lookup_name(name); 178 178 } 179 179 180 + /* 181 + * Iterate over all symbols in vmlinux. For symbols from modules use 182 + * module_kallsyms_on_each_symbol instead. 183 + */ 180 184 int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, 181 185 unsigned long), 182 186 void *data) ··· 196 192 if (ret != 0) 197 193 return ret; 198 194 } 199 - return module_kallsyms_on_each_symbol(fn, data); 195 + return 0; 200 196 } 201 197 202 198 static unsigned long get_symbol_pos(unsigned long addr,
-2
kernel/livepatch/core.c
··· 164 164 .pos = sympos, 165 165 }; 166 166 167 - mutex_lock(&module_mutex); 168 167 if (objname) 169 168 module_kallsyms_on_each_symbol(klp_find_callback, &args); 170 169 else 171 170 kallsyms_on_each_symbol(klp_find_callback, &args); 172 - mutex_unlock(&module_mutex); 173 171 174 172 /* 175 173 * Ensure an address was found. If sympos is 0, ensure symbol is unique;
+4 -9
kernel/module.c
··· 255 255 struct list_head *kdb_modules = &modules; /* kdb needs the list of modules */ 256 256 #endif /* CONFIG_KGDB_KDB */ 257 257 258 - static void module_assert_mutex(void) 259 - { 260 - lockdep_assert_held(&module_mutex); 261 - } 262 - 263 258 static void module_assert_mutex_or_preempt(void) 264 259 { 265 260 #ifdef CONFIG_LOCKDEP ··· 4496 4501 unsigned int i; 4497 4502 int ret; 4498 4503 4499 - module_assert_mutex(); 4500 - 4504 + mutex_lock(&module_mutex); 4501 4505 list_for_each_entry(mod, &modules, list) { 4502 4506 /* We hold module_mutex: no need for rcu_dereference_sched */ 4503 4507 struct mod_kallsyms *kallsyms = mod->kallsyms; ··· 4512 4518 ret = fn(data, kallsyms_symbol_name(kallsyms, i), 4513 4519 mod, kallsyms_symbol_value(sym)); 4514 4520 if (ret != 0) 4515 - return ret; 4521 + break; 4516 4522 } 4517 4523 } 4518 - return 0; 4524 + mutex_unlock(&module_mutex); 4525 + return ret; 4519 4526 } 4520 4527 #endif /* CONFIG_KALLSYMS */ 4521 4528