aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/module.c
diff options
context:
space:
mode:
authorLachlan McIlroy <lachlan@redback.melbourne.sgi.com>2008-02-17 21:51:42 -0500
committerLachlan McIlroy <lachlan@redback.melbourne.sgi.com>2008-02-17 21:51:42 -0500
commitc58310bf4933986513020fa90b4190c7492995ae (patch)
tree143f2c7578d02ebef5db8fc57ae69e951ae0e2ee /kernel/module.c
parent269cdfaf769f5cd831284cc831790c7c5038040f (diff)
parent1309d4e68497184d2fd87e892ddf14076c2bda98 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 into for-linus
Diffstat (limited to 'kernel/module.c')
-rw-r--r--kernel/module.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/kernel/module.c b/kernel/module.c
index bd60278ee703..92595bad3812 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -46,6 +46,7 @@
46#include <asm/semaphore.h> 46#include <asm/semaphore.h>
47#include <asm/cacheflush.h> 47#include <asm/cacheflush.h>
48#include <linux/license.h> 48#include <linux/license.h>
49#include <asm/sections.h>
49 50
50#if 0 51#if 0
51#define DEBUGP printk 52#define DEBUGP printk
@@ -290,7 +291,7 @@ static unsigned long __find_symbol(const char *name,
290 } 291 }
291 } 292 }
292 DEBUGP("Failed to find symbol %s\n", name); 293 DEBUGP("Failed to find symbol %s\n", name);
293 return 0; 294 return -ENOENT;
294} 295}
295 296
296/* Search for module by name: must hold module_mutex. */ 297/* Search for module by name: must hold module_mutex. */
@@ -343,9 +344,6 @@ static inline unsigned int block_size(int val)
343 return val; 344 return val;
344} 345}
345 346
346/* Created by linker magic */
347extern char __per_cpu_start[], __per_cpu_end[];
348
349static void *percpu_modalloc(unsigned long size, unsigned long align, 347static void *percpu_modalloc(unsigned long size, unsigned long align,
350 const char *name) 348 const char *name)
351{ 349{
@@ -783,7 +781,7 @@ void __symbol_put(const char *symbol)
783 const unsigned long *crc; 781 const unsigned long *crc;
784 782
785 preempt_disable(); 783 preempt_disable();
786 if (!__find_symbol(symbol, &owner, &crc, 1)) 784 if (IS_ERR_VALUE(__find_symbol(symbol, &owner, &crc, 1)))
787 BUG(); 785 BUG();
788 module_put(owner); 786 module_put(owner);
789 preempt_enable(); 787 preempt_enable();
@@ -929,7 +927,8 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,
929 const unsigned long *crc; 927 const unsigned long *crc;
930 struct module *owner; 928 struct module *owner;
931 929
932 if (!__find_symbol("struct_module", &owner, &crc, 1)) 930 if (IS_ERR_VALUE(__find_symbol("struct_module",
931 &owner, &crc, 1)))
933 BUG(); 932 BUG();
934 return check_version(sechdrs, versindex, "struct_module", mod, 933 return check_version(sechdrs, versindex, "struct_module", mod,
935 crc); 934 crc);
@@ -978,12 +977,12 @@ static unsigned long resolve_symbol(Elf_Shdr *sechdrs,
978 977
979 ret = __find_symbol(name, &owner, &crc, 978 ret = __find_symbol(name, &owner, &crc,
980 !(mod->taints & TAINT_PROPRIETARY_MODULE)); 979 !(mod->taints & TAINT_PROPRIETARY_MODULE));
981 if (ret) { 980 if (!IS_ERR_VALUE(ret)) {
982 /* use_module can fail due to OOM, 981 /* use_module can fail due to OOM,
983 or module initialization or unloading */ 982 or module initialization or unloading */
984 if (!check_version(sechdrs, versindex, name, mod, crc) || 983 if (!check_version(sechdrs, versindex, name, mod, crc) ||
985 !use_module(mod, owner)) 984 !use_module(mod, owner))
986 ret = 0; 985 ret = -EINVAL;
987 } 986 }
988 return ret; 987 return ret;
989} 988}
@@ -1371,7 +1370,9 @@ void *__symbol_get(const char *symbol)
1371 1370
1372 preempt_disable(); 1371 preempt_disable();
1373 value = __find_symbol(symbol, &owner, &crc, 1); 1372 value = __find_symbol(symbol, &owner, &crc, 1);
1374 if (value && strong_try_module_get(owner) != 0) 1373 if (IS_ERR_VALUE(value))
1374 value = 0;
1375 else if (strong_try_module_get(owner))
1375 value = 0; 1376 value = 0;
1376 preempt_enable(); 1377 preempt_enable();
1377 1378
@@ -1391,14 +1392,16 @@ static int verify_export_symbols(struct module *mod)
1391 const unsigned long *crc; 1392 const unsigned long *crc;
1392 1393
1393 for (i = 0; i < mod->num_syms; i++) 1394 for (i = 0; i < mod->num_syms; i++)
1394 if (__find_symbol(mod->syms[i].name, &owner, &crc, 1)) { 1395 if (!IS_ERR_VALUE(__find_symbol(mod->syms[i].name,
1396 &owner, &crc, 1))) {
1395 name = mod->syms[i].name; 1397 name = mod->syms[i].name;
1396 ret = -ENOEXEC; 1398 ret = -ENOEXEC;
1397 goto dup; 1399 goto dup;
1398 } 1400 }
1399 1401
1400 for (i = 0; i < mod->num_gpl_syms; i++) 1402 for (i = 0; i < mod->num_gpl_syms; i++)
1401 if (__find_symbol(mod->gpl_syms[i].name, &owner, &crc, 1)) { 1403 if (!IS_ERR_VALUE(__find_symbol(mod->gpl_syms[i].name,
1404 &owner, &crc, 1))) {
1402 name = mod->gpl_syms[i].name; 1405 name = mod->gpl_syms[i].name;
1403 ret = -ENOEXEC; 1406 ret = -ENOEXEC;
1404 goto dup; 1407 goto dup;
@@ -1448,7 +1451,7 @@ static int simplify_symbols(Elf_Shdr *sechdrs,
1448 strtab + sym[i].st_name, mod); 1451 strtab + sym[i].st_name, mod);
1449 1452
1450 /* Ok if resolved. */ 1453 /* Ok if resolved. */
1451 if (sym[i].st_value != 0) 1454 if (!IS_ERR_VALUE(sym[i].st_value))
1452 break; 1455 break;
1453 /* Ok if weak. */ 1456 /* Ok if weak. */
1454 if (ELF_ST_BIND(sym[i].st_info) == STB_WEAK) 1457 if (ELF_ST_BIND(sym[i].st_info) == STB_WEAK)
@@ -2035,7 +2038,7 @@ static struct module *load_module(void __user *umod,
2035#ifdef CONFIG_MARKERS 2038#ifdef CONFIG_MARKERS
2036 if (!mod->taints) 2039 if (!mod->taints)
2037 marker_update_probe_range(mod->markers, 2040 marker_update_probe_range(mod->markers,
2038 mod->markers + mod->num_markers, NULL, NULL); 2041 mod->markers + mod->num_markers);
2039#endif 2042#endif
2040 err = module_finalize(hdr, sechdrs, mod); 2043 err = module_finalize(hdr, sechdrs, mod);
2041 if (err < 0) 2044 if (err < 0)
@@ -2250,7 +2253,7 @@ static const char *get_ksymbol(struct module *mod,
2250 2253
2251/* For kallsyms to ask for address resolution. NULL means not found. Careful 2254/* For kallsyms to ask for address resolution. NULL means not found. Careful
2252 * not to lock to avoid deadlock on oopses, simply disable preemption. */ 2255 * not to lock to avoid deadlock on oopses, simply disable preemption. */
2253char *module_address_lookup(unsigned long addr, 2256const char *module_address_lookup(unsigned long addr,
2254 unsigned long *size, 2257 unsigned long *size,
2255 unsigned long *offset, 2258 unsigned long *offset,
2256 char **modname, 2259 char **modname,
@@ -2275,7 +2278,7 @@ char *module_address_lookup(unsigned long addr,
2275 ret = namebuf; 2278 ret = namebuf;
2276 } 2279 }
2277 preempt_enable(); 2280 preempt_enable();
2278 return (char *)ret; 2281 return ret;
2279} 2282}
2280 2283
2281int lookup_module_symbol_name(unsigned long addr, char *symname) 2284int lookup_module_symbol_name(unsigned long addr, char *symname)
@@ -2561,7 +2564,7 @@ EXPORT_SYMBOL(struct_module);
2561#endif 2564#endif
2562 2565
2563#ifdef CONFIG_MARKERS 2566#ifdef CONFIG_MARKERS
2564void module_update_markers(struct module *probe_module, int *refcount) 2567void module_update_markers(void)
2565{ 2568{
2566 struct module *mod; 2569 struct module *mod;
2567 2570
@@ -2569,8 +2572,7 @@ void module_update_markers(struct module *probe_module, int *refcount)
2569 list_for_each_entry(mod, &modules, list) 2572 list_for_each_entry(mod, &modules, list)
2570 if (!mod->taints) 2573 if (!mod->taints)
2571 marker_update_probe_range(mod->markers, 2574 marker_update_probe_range(mod->markers,
2572 mod->markers + mod->num_markers, 2575 mod->markers + mod->num_markers);
2573 probe_module, refcount);
2574 mutex_unlock(&module_mutex); 2576 mutex_unlock(&module_mutex);
2575} 2577}
2576#endif 2578#endif