X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=kernel%2Fmodule.c;h=8b3726655a8717c28820a680f54822fcaa582b5a;hb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;hp=dfe295ecf2f104dfb09678be30322c1da4f4127e;hpb=a2c21200f1c81b08cb55e417b68150bba439b646;p=linux-2.6.git diff --git a/kernel/module.c b/kernel/module.c index dfe295ecf..8b3726655 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -89,13 +89,6 @@ static inline int strong_try_module_get(struct module *mod) return try_module_get(mod); } -/* Stub function for modules which don't have an initfn */ -int init_module(void) -{ - return 0; -} -EXPORT_SYMBOL(init_module); - /* A thread that wants to hold a reference to a module only while it * is running can call ths to safely exit. * nfsd and lockd use this. @@ -529,12 +522,6 @@ EXPORT_SYMBOL(module_refcount); /* This exists whether we can unload or not */ static void free_module(struct module *mod); -/* Stub function for modules which don't have an exitfn */ -void cleanup_module(void) -{ -} -EXPORT_SYMBOL(cleanup_module); - static void wait_for_zero_refcount(struct module *mod) { /* Since we might sleep for some time, drop the semaphore first */ @@ -589,7 +576,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags) } /* If it has an init func, it must have an exit func to unload */ - if ((mod->init != init_module && mod->exit == cleanup_module) + if ((mod->init != NULL && mod->exit == NULL) || mod->unsafe) { forced = try_force(flags); if (!forced) { @@ -610,9 +597,11 @@ sys_delete_module(const char __user *name_user, unsigned int flags) wait_for_zero_refcount(mod); /* Final destruction now noone is using it. */ - up(&module_mutex); - mod->exit(); - down(&module_mutex); + if (mod->exit != NULL) { + up(&module_mutex); + mod->exit(); + down(&module_mutex); + } free_module(mod); out: @@ -639,7 +628,7 @@ static void print_unload_info(struct seq_file *m, struct module *mod) seq_printf(m, "[unsafe],"); } - if (mod->init != init_module && mod->exit == cleanup_module) { + if (mod->init != NULL && mod->exit == NULL) { printed_something = 1; seq_printf(m, "[permanent],"); } @@ -725,19 +714,6 @@ static inline int sysfs_unload_setup(struct module *mod) #endif /* CONFIG_MODULE_UNLOAD */ #ifdef CONFIG_OBSOLETE_MODPARM -static int param_set_byte(const char *val, struct kernel_param *kp) -{ - char *endp; - long l; - - if (!val) return -EINVAL; - l = simple_strtol(val, &endp, 0); - if (endp == val || *endp || ((char)l != l)) - return -EINVAL; - *((char *)kp->arg) = l; - return 0; -} - /* Bounds checking done below */ static int obsparm_copy_string(const char *val, struct kernel_param *kp) { @@ -1551,9 +1527,6 @@ static struct module *load_module(void __user *umod, secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; sechdrs[0].sh_addr = 0; - /* And these should exist, but gcc whinges if we don't init them */ - symindex = strindex = 0; - for (i = 1; i < hdr->e_shnum; i++) { if (sechdrs[i].sh_type != SHT_NOBITS && len < sechdrs[i].sh_offset + sechdrs[i].sh_size) @@ -1585,6 +1558,13 @@ static struct module *load_module(void __user *umod, } mod = (void *)sechdrs[modindex].sh_addr; + if (symindex == 0) { + printk(KERN_WARNING "%s: module has no symbols (stripped?)\n", + mod->name); + err = -ENOEXEC; + goto free_hdr; + } + /* Optional sections */ exportindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab"); gplindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_gpl"); @@ -1845,7 +1825,7 @@ sys_init_module(void __user *umod, const char __user *uargs) { struct module *mod; - int ret; + int ret = 0; /* Must have permission */ if (!capable(CAP_SYS_MODULE)) @@ -1884,7 +1864,8 @@ sys_init_module(void __user *umod, up(¬ify_mutex); /* Start the module */ - ret = mod->init(); + if (mod->init != NULL) + ret = mod->init(); if (ret < 0) { /* Init routine failed: abort. Try to protect us from buggy refcounters. */