Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 126340
b: refs/heads/master
c: a06f621
h: refs/heads/master
v: v3
  • Loading branch information
Masami Hiramatsu authored and Linus Torvalds committed Jan 6, 2009
1 parent a748b6b commit e5385d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 12da3b888b2035bb0f106122f1cc1b6d357fad53
refs/heads/master: a06f6211ef9b1785922f9d0e8766d63ac4e66de1
12 changes: 12 additions & 0 deletions trunk/include/linux/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,18 @@ struct module *module_text_address(unsigned long addr);
struct module *__module_text_address(unsigned long addr);
int is_module_address(unsigned long addr);

static inline int within_module_core(unsigned long addr, struct module *mod)
{
return (unsigned long)mod->module_core <= addr &&
addr < (unsigned long)mod->module_core + mod->core_size;
}

static inline int within_module_init(unsigned long addr, struct module *mod)
{
return (unsigned long)mod->module_init <= addr &&
addr < (unsigned long)mod->module_init + mod->init_size;
}

/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
symnum out of range. */
int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
Expand Down
16 changes: 8 additions & 8 deletions trunk/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2390,7 +2390,7 @@ static const char *get_ksymbol(struct module *mod,
unsigned long nextval;

/* At worse, next value is at end of module */
if (within(addr, mod->module_init, mod->init_size))
if (within_module_init(addr, mod))
nextval = (unsigned long)mod->module_init+mod->init_text_size;
else
nextval = (unsigned long)mod->module_core+mod->core_text_size;
Expand Down Expand Up @@ -2438,8 +2438,8 @@ const char *module_address_lookup(unsigned long addr,

preempt_disable();
list_for_each_entry_rcu(mod, &modules, list) {
if (within(addr, mod->module_init, mod->init_size)
|| within(addr, mod->module_core, mod->core_size)) {
if (within_module_init(addr, mod) ||
within_module_core(addr, mod)) {
if (modname)
*modname = mod->name;
ret = get_ksymbol(mod, addr, size, offset);
Expand All @@ -2461,8 +2461,8 @@ int lookup_module_symbol_name(unsigned long addr, char *symname)

preempt_disable();
list_for_each_entry_rcu(mod, &modules, list) {
if (within(addr, mod->module_init, mod->init_size) ||
within(addr, mod->module_core, mod->core_size)) {
if (within_module_init(addr, mod) ||
within_module_core(addr, mod)) {
const char *sym;

sym = get_ksymbol(mod, addr, NULL, NULL);
Expand All @@ -2485,8 +2485,8 @@ int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size,

preempt_disable();
list_for_each_entry_rcu(mod, &modules, list) {
if (within(addr, mod->module_init, mod->init_size) ||
within(addr, mod->module_core, mod->core_size)) {
if (within_module_init(addr, mod) ||
within_module_core(addr, mod)) {
const char *sym;

sym = get_ksymbol(mod, addr, size, offset);
Expand Down Expand Up @@ -2705,7 +2705,7 @@ int is_module_address(unsigned long addr)
preempt_disable();

list_for_each_entry_rcu(mod, &modules, list) {
if (within(addr, mod->module_core, mod->core_size)) {
if (within_module_core(addr, mod)) {
preempt_enable();
return 1;
}
Expand Down

0 comments on commit e5385d9

Please sign in to comment.