History

kernel/module.c: compare symbol values when marking symbols as exported in /proc/kallsyms.

When there are two symbols in a module with the same name, one of which is exported, both will be marked as exported in /proc/kallsyms. There aren't any instances of this in the current kernel, but it is easy to construct a simple module with two compilation units that exhibits the problem. $ objdump -j .text -t testmod.ko | grep foo 00000000 l F .text 00000032 foo 00000080 g F .text 00000001 foo $ sudo insmod testmod.ko $ grep "T foo" /proc/kallsyms c28e8000 T foo [testmod] c28e8080 T foo [testmod] Fix this by comparing the symbol values once we've found the exported symbol table entry matching the symbol name. Tested using Ksplice: $ ksplice-create --patch=this_commit.patch --id=bar . $ sudo ksplice-apply ksplice-bar.tar.gz Done! $ grep "T foo" /proc/kallsyms c28e8080 T foo [testmod]

Tim Abbott committed 17 years ago

Commit ca4787b1 parent a327ca21 file · +8 −8Browse files

Unified · Split

kernel/module.c+8−8
@@ -1725,15 +1725,15 @@ static const struct kernel_symbol *lookup_symbol(const char *name, · 1724 unmodified lines
17251725 return NULL;
17261726 }
17271727
1728−static int is_exported(const char *name, const struct module *mod)
1728+static int is_exported(const char *name, unsigned long value,
1729+ const struct module *mod)
17291730 {
1730− if (!mod && lookup_symbol(name, __start___ksymtab, __stop___ksymtab))
1731− return 1;
1731+ const struct kernel_symbol *ks;
1732+ if (!mod)
1733+ ks = lookup_symbol(name, __start___ksymtab, __stop___ksymtab);
17321734 else
1733− if (mod && lookup_symbol(name, mod->syms, mod->syms + mod->num_syms))
1734− return 1;
1735− else
1736− return 0;
1735+ ks = lookup_symbol(name, mod->syms, mod->syms + mod->num_syms);
1736+ return ks != NULL && ks->value == value;
17371737 }
17381738
17391739 /* As per nm */
@@ -2504,7 +2504,7 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, · 764 unmodified lines
25042504 strlcpy(name, mod->strtab + mod->symtab[symnum].st_name,
25052505 KSYM_NAME_LEN);
25062506 strlcpy(module_name, mod->name, MODULE_NAME_LEN);
2507− *exported = is_exported(name, mod);
2507+ *exported = is_exported(name, *value, mod);
25082508 preempt_enable();
25092509 return 0;
25102510 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t