Commit 88173507 authored by Christoph Lameter's avatar Christoph Lameter Committed by Linus Torvalds

Modules: handle symbols that have a zero value

The module subsystem cannot handle symbols that are zero.  If symbols are
present that have a zero value then the module resolver prints out a
message that these symbols are unresolved.

[akinobu.mita@gmail.com: fix __find_symbl() error checks]
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Kay Sievers <kay.sievers@vrfy.org
Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 596f5601
...@@ -290,7 +290,7 @@ static unsigned long __find_symbol(const char *name, ...@@ -290,7 +290,7 @@ static unsigned long __find_symbol(const char *name,
} }
} }
DEBUGP("Failed to find symbol %s\n", name); DEBUGP("Failed to find symbol %s\n", name);
return 0; return -ENOENT;
} }
/* Search for module by name: must hold module_mutex. */ /* Search for module by name: must hold module_mutex. */
...@@ -783,7 +783,7 @@ void __symbol_put(const char *symbol) ...@@ -783,7 +783,7 @@ void __symbol_put(const char *symbol)
const unsigned long *crc; const unsigned long *crc;
preempt_disable(); preempt_disable();
if (!__find_symbol(symbol, &owner, &crc, 1)) if (IS_ERR_VALUE(__find_symbol(symbol, &owner, &crc, 1)))
BUG(); BUG();
module_put(owner); module_put(owner);
preempt_enable(); preempt_enable();
...@@ -929,7 +929,8 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs, ...@@ -929,7 +929,8 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,
const unsigned long *crc; const unsigned long *crc;
struct module *owner; struct module *owner;
if (!__find_symbol("struct_module", &owner, &crc, 1)) if (IS_ERR_VALUE(__find_symbol("struct_module",
&owner, &crc, 1)))
BUG(); BUG();
return check_version(sechdrs, versindex, "struct_module", mod, return check_version(sechdrs, versindex, "struct_module", mod,
crc); crc);
...@@ -978,12 +979,12 @@ static unsigned long resolve_symbol(Elf_Shdr *sechdrs, ...@@ -978,12 +979,12 @@ static unsigned long resolve_symbol(Elf_Shdr *sechdrs,
ret = __find_symbol(name, &owner, &crc, ret = __find_symbol(name, &owner, &crc,
!(mod->taints & TAINT_PROPRIETARY_MODULE)); !(mod->taints & TAINT_PROPRIETARY_MODULE));
if (ret) { if (!IS_ERR_VALUE(ret)) {
/* use_module can fail due to OOM, /* use_module can fail due to OOM,
or module initialization or unloading */ or module initialization or unloading */
if (!check_version(sechdrs, versindex, name, mod, crc) || if (!check_version(sechdrs, versindex, name, mod, crc) ||
!use_module(mod, owner)) !use_module(mod, owner))
ret = 0; ret = -EINVAL;
} }
return ret; return ret;
} }
...@@ -1371,7 +1372,9 @@ void *__symbol_get(const char *symbol) ...@@ -1371,7 +1372,9 @@ void *__symbol_get(const char *symbol)
preempt_disable(); preempt_disable();
value = __find_symbol(symbol, &owner, &crc, 1); value = __find_symbol(symbol, &owner, &crc, 1);
if (value && strong_try_module_get(owner) != 0) if (IS_ERR_VALUE(value))
value = 0;
else if (strong_try_module_get(owner))
value = 0; value = 0;
preempt_enable(); preempt_enable();
...@@ -1391,14 +1394,16 @@ static int verify_export_symbols(struct module *mod) ...@@ -1391,14 +1394,16 @@ static int verify_export_symbols(struct module *mod)
const unsigned long *crc; const unsigned long *crc;
for (i = 0; i < mod->num_syms; i++) for (i = 0; i < mod->num_syms; i++)
if (__find_symbol(mod->syms[i].name, &owner, &crc, 1)) { if (!IS_ERR_VALUE(__find_symbol(mod->syms[i].name,
&owner, &crc, 1))) {
name = mod->syms[i].name; name = mod->syms[i].name;
ret = -ENOEXEC; ret = -ENOEXEC;
goto dup; goto dup;
} }
for (i = 0; i < mod->num_gpl_syms; i++) for (i = 0; i < mod->num_gpl_syms; i++)
if (__find_symbol(mod->gpl_syms[i].name, &owner, &crc, 1)) { if (!IS_ERR_VALUE(__find_symbol(mod->gpl_syms[i].name,
&owner, &crc, 1))) {
name = mod->gpl_syms[i].name; name = mod->gpl_syms[i].name;
ret = -ENOEXEC; ret = -ENOEXEC;
goto dup; goto dup;
...@@ -1448,7 +1453,7 @@ static int simplify_symbols(Elf_Shdr *sechdrs, ...@@ -1448,7 +1453,7 @@ static int simplify_symbols(Elf_Shdr *sechdrs,
strtab + sym[i].st_name, mod); strtab + sym[i].st_name, mod);
/* Ok if resolved. */ /* Ok if resolved. */
if (sym[i].st_value != 0) if (!IS_ERR_VALUE(sym[i].st_value))
break; break;
/* Ok if weak. */ /* Ok if weak. */
if (ELF_ST_BIND(sym[i].st_info) == STB_WEAK) if (ELF_ST_BIND(sym[i].st_info) == STB_WEAK)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment