aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/module.h12
-rw-r--r--kernel/module.c16
2 files changed, 20 insertions, 8 deletions
diff --git a/include/linux/module.h b/include/linux/module.h
index 03cb93d1865a..4f7ea12463d3 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -365,6 +365,18 @@ struct module *module_text_address(unsigned long addr);
365struct module *__module_text_address(unsigned long addr); 365struct module *__module_text_address(unsigned long addr);
366int is_module_address(unsigned long addr); 366int is_module_address(unsigned long addr);
367 367
368static inline int within_module_core(unsigned long addr, struct module *mod)
369{
370 return (unsigned long)mod->module_core <= addr &&
371 addr < (unsigned long)mod->module_core + mod->core_size;
372}
373
374static inline int within_module_init(unsigned long addr, struct module *mod)
375{
376 return (unsigned long)mod->module_init <= addr &&
377 addr < (unsigned long)mod->module_init + mod->init_size;
378}
379
368/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if 380/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
369 symnum out of range. */ 381 symnum out of range. */
370int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, 382int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
diff --git a/kernel/module.c b/kernel/module.c
index 34b56cf06615..cc79c942c572 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2390,7 +2390,7 @@ static const char *get_ksymbol(struct module *mod,
2390 unsigned long nextval; 2390 unsigned long nextval;
2391 2391
2392 /* At worse, next value is at end of module */ 2392 /* At worse, next value is at end of module */
2393 if (within(addr, mod->module_init, mod->init_size)) 2393 if (within_module_init(addr, mod))
2394 nextval = (unsigned long)mod->module_init+mod->init_text_size; 2394 nextval = (unsigned long)mod->module_init+mod->init_text_size;
2395 else 2395 else
2396 nextval = (unsigned long)mod->module_core+mod->core_text_size; 2396 nextval = (unsigned long)mod->module_core+mod->core_text_size;
@@ -2438,8 +2438,8 @@ const char *module_address_lookup(unsigned long addr,
2438 2438
2439 preempt_disable(); 2439 preempt_disable();
2440 list_for_each_entry_rcu(mod, &modules, list) { 2440 list_for_each_entry_rcu(mod, &modules, list) {
2441 if (within(addr, mod->module_init, mod->init_size) 2441 if (within_module_init(addr, mod) ||
2442 || within(addr, mod->module_core, mod->core_size)) { 2442 within_module_core(addr, mod)) {
2443 if (modname) 2443 if (modname)
2444 *modname = mod->name; 2444 *modname = mod->name;
2445 ret = get_ksymbol(mod, addr, size, offset); 2445 ret = get_ksymbol(mod, addr, size, offset);
@@ -2461,8 +2461,8 @@ int lookup_module_symbol_name(unsigned long addr, char *symname)
2461 2461
2462 preempt_disable(); 2462 preempt_disable();
2463 list_for_each_entry_rcu(mod, &modules, list) { 2463 list_for_each_entry_rcu(mod, &modules, list) {
2464 if (within(addr, mod->module_init, mod->init_size) || 2464 if (within_module_init(addr, mod) ||
2465 within(addr, mod->module_core, mod->core_size)) { 2465 within_module_core(addr, mod)) {
2466 const char *sym; 2466 const char *sym;
2467 2467
2468 sym = get_ksymbol(mod, addr, NULL, NULL); 2468 sym = get_ksymbol(mod, addr, NULL, NULL);
@@ -2485,8 +2485,8 @@ int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size,
2485 2485
2486 preempt_disable(); 2486 preempt_disable();
2487 list_for_each_entry_rcu(mod, &modules, list) { 2487 list_for_each_entry_rcu(mod, &modules, list) {
2488 if (within(addr, mod->module_init, mod->init_size) || 2488 if (within_module_init(addr, mod) ||
2489 within(addr, mod->module_core, mod->core_size)) { 2489 within_module_core(addr, mod)) {
2490 const char *sym; 2490 const char *sym;
2491 2491
2492 sym = get_ksymbol(mod, addr, size, offset); 2492 sym = get_ksymbol(mod, addr, size, offset);
@@ -2705,7 +2705,7 @@ int is_module_address(unsigned long addr)
2705 preempt_disable(); 2705 preempt_disable();
2706 2706
2707 list_for_each_entry_rcu(mod, &modules, list) { 2707 list_for_each_entry_rcu(mod, &modules, list) {
2708 if (within(addr, mod->module_core, mod->core_size)) { 2708 if (within_module_core(addr, mod)) {
2709 preempt_enable(); 2709 preempt_enable();
2710 return 1; 2710 return 1;
2711 } 2711 }