diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-24 12:54:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-24 12:54:54 -0400 |
commit | fcda12e7f6d58d61997681a9d41779e3fd2ffc94 (patch) | |
tree | ea865215c10b8b09828db2918013dfe02ce62f25 /kernel | |
parent | 5fabc487c96819dd12ddb9414835d170fd9cd6d5 (diff) | |
parent | 62a2635610dbc83c5e8d724e00941eee4d18c186 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
* git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus:
modpost: Fix modpost's license checking V3
module: add /sys/module/<name>/uevent files
module: change attr callbacks to take struct module_kobject
modules: make arch's use default loader hooks
modules: add default loader hook implementations
param: fix return value handling in param_set_*
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/module.c | 80 | ||||
-rw-r--r-- | kernel/params.c | 18 |
2 files changed, 84 insertions, 14 deletions
diff --git a/kernel/module.c b/kernel/module.c index 795bdc7f5c3f..04379f92f843 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -545,9 +545,9 @@ static void setup_modinfo_##field(struct module *mod, const char *s) \ | |||
545 | mod->field = kstrdup(s, GFP_KERNEL); \ | 545 | mod->field = kstrdup(s, GFP_KERNEL); \ |
546 | } \ | 546 | } \ |
547 | static ssize_t show_modinfo_##field(struct module_attribute *mattr, \ | 547 | static ssize_t show_modinfo_##field(struct module_attribute *mattr, \ |
548 | struct module *mod, char *buffer) \ | 548 | struct module_kobject *mk, char *buffer) \ |
549 | { \ | 549 | { \ |
550 | return sprintf(buffer, "%s\n", mod->field); \ | 550 | return sprintf(buffer, "%s\n", mk->mod->field); \ |
551 | } \ | 551 | } \ |
552 | static int modinfo_##field##_exists(struct module *mod) \ | 552 | static int modinfo_##field##_exists(struct module *mod) \ |
553 | { \ | 553 | { \ |
@@ -902,9 +902,9 @@ void symbol_put_addr(void *addr) | |||
902 | EXPORT_SYMBOL_GPL(symbol_put_addr); | 902 | EXPORT_SYMBOL_GPL(symbol_put_addr); |
903 | 903 | ||
904 | static ssize_t show_refcnt(struct module_attribute *mattr, | 904 | static ssize_t show_refcnt(struct module_attribute *mattr, |
905 | struct module *mod, char *buffer) | 905 | struct module_kobject *mk, char *buffer) |
906 | { | 906 | { |
907 | return sprintf(buffer, "%u\n", module_refcount(mod)); | 907 | return sprintf(buffer, "%u\n", module_refcount(mk->mod)); |
908 | } | 908 | } |
909 | 909 | ||
910 | static struct module_attribute refcnt = { | 910 | static struct module_attribute refcnt = { |
@@ -952,11 +952,11 @@ static inline int module_unload_init(struct module *mod) | |||
952 | #endif /* CONFIG_MODULE_UNLOAD */ | 952 | #endif /* CONFIG_MODULE_UNLOAD */ |
953 | 953 | ||
954 | static ssize_t show_initstate(struct module_attribute *mattr, | 954 | static ssize_t show_initstate(struct module_attribute *mattr, |
955 | struct module *mod, char *buffer) | 955 | struct module_kobject *mk, char *buffer) |
956 | { | 956 | { |
957 | const char *state = "unknown"; | 957 | const char *state = "unknown"; |
958 | 958 | ||
959 | switch (mod->state) { | 959 | switch (mk->mod->state) { |
960 | case MODULE_STATE_LIVE: | 960 | case MODULE_STATE_LIVE: |
961 | state = "live"; | 961 | state = "live"; |
962 | break; | 962 | break; |
@@ -975,10 +975,27 @@ static struct module_attribute initstate = { | |||
975 | .show = show_initstate, | 975 | .show = show_initstate, |
976 | }; | 976 | }; |
977 | 977 | ||
978 | static ssize_t store_uevent(struct module_attribute *mattr, | ||
979 | struct module_kobject *mk, | ||
980 | const char *buffer, size_t count) | ||
981 | { | ||
982 | enum kobject_action action; | ||
983 | |||
984 | if (kobject_action_type(buffer, count, &action) == 0) | ||
985 | kobject_uevent(&mk->kobj, action); | ||
986 | return count; | ||
987 | } | ||
988 | |||
989 | struct module_attribute module_uevent = { | ||
990 | .attr = { .name = "uevent", .mode = 0200 }, | ||
991 | .store = store_uevent, | ||
992 | }; | ||
993 | |||
978 | static struct module_attribute *modinfo_attrs[] = { | 994 | static struct module_attribute *modinfo_attrs[] = { |
979 | &modinfo_version, | 995 | &modinfo_version, |
980 | &modinfo_srcversion, | 996 | &modinfo_srcversion, |
981 | &initstate, | 997 | &initstate, |
998 | &module_uevent, | ||
982 | #ifdef CONFIG_MODULE_UNLOAD | 999 | #ifdef CONFIG_MODULE_UNLOAD |
983 | &refcnt, | 1000 | &refcnt, |
984 | #endif | 1001 | #endif |
@@ -1187,7 +1204,7 @@ struct module_sect_attrs | |||
1187 | }; | 1204 | }; |
1188 | 1205 | ||
1189 | static ssize_t module_sect_show(struct module_attribute *mattr, | 1206 | static ssize_t module_sect_show(struct module_attribute *mattr, |
1190 | struct module *mod, char *buf) | 1207 | struct module_kobject *mk, char *buf) |
1191 | { | 1208 | { |
1192 | struct module_sect_attr *sattr = | 1209 | struct module_sect_attr *sattr = |
1193 | container_of(mattr, struct module_sect_attr, mattr); | 1210 | container_of(mattr, struct module_sect_attr, mattr); |
@@ -1697,6 +1714,15 @@ static void unset_module_core_ro_nx(struct module *mod) { } | |||
1697 | static void unset_module_init_ro_nx(struct module *mod) { } | 1714 | static void unset_module_init_ro_nx(struct module *mod) { } |
1698 | #endif | 1715 | #endif |
1699 | 1716 | ||
1717 | void __weak module_free(struct module *mod, void *module_region) | ||
1718 | { | ||
1719 | vfree(module_region); | ||
1720 | } | ||
1721 | |||
1722 | void __weak module_arch_cleanup(struct module *mod) | ||
1723 | { | ||
1724 | } | ||
1725 | |||
1700 | /* Free a module, remove from lists, etc. */ | 1726 | /* Free a module, remove from lists, etc. */ |
1701 | static void free_module(struct module *mod) | 1727 | static void free_module(struct module *mod) |
1702 | { | 1728 | { |
@@ -1851,6 +1877,26 @@ static int simplify_symbols(struct module *mod, const struct load_info *info) | |||
1851 | return ret; | 1877 | return ret; |
1852 | } | 1878 | } |
1853 | 1879 | ||
1880 | int __weak apply_relocate(Elf_Shdr *sechdrs, | ||
1881 | const char *strtab, | ||
1882 | unsigned int symindex, | ||
1883 | unsigned int relsec, | ||
1884 | struct module *me) | ||
1885 | { | ||
1886 | pr_err("module %s: REL relocation unsupported\n", me->name); | ||
1887 | return -ENOEXEC; | ||
1888 | } | ||
1889 | |||
1890 | int __weak apply_relocate_add(Elf_Shdr *sechdrs, | ||
1891 | const char *strtab, | ||
1892 | unsigned int symindex, | ||
1893 | unsigned int relsec, | ||
1894 | struct module *me) | ||
1895 | { | ||
1896 | pr_err("module %s: RELA relocation unsupported\n", me->name); | ||
1897 | return -ENOEXEC; | ||
1898 | } | ||
1899 | |||
1854 | static int apply_relocations(struct module *mod, const struct load_info *info) | 1900 | static int apply_relocations(struct module *mod, const struct load_info *info) |
1855 | { | 1901 | { |
1856 | unsigned int i; | 1902 | unsigned int i; |
@@ -2235,6 +2281,11 @@ static void dynamic_debug_remove(struct _ddebug *debug) | |||
2235 | ddebug_remove_module(debug->modname); | 2281 | ddebug_remove_module(debug->modname); |
2236 | } | 2282 | } |
2237 | 2283 | ||
2284 | void * __weak module_alloc(unsigned long size) | ||
2285 | { | ||
2286 | return size == 0 ? NULL : vmalloc_exec(size); | ||
2287 | } | ||
2288 | |||
2238 | static void *module_alloc_update_bounds(unsigned long size) | 2289 | static void *module_alloc_update_bounds(unsigned long size) |
2239 | { | 2290 | { |
2240 | void *ret = module_alloc(size); | 2291 | void *ret = module_alloc(size); |
@@ -2645,6 +2696,14 @@ static void flush_module_icache(const struct module *mod) | |||
2645 | set_fs(old_fs); | 2696 | set_fs(old_fs); |
2646 | } | 2697 | } |
2647 | 2698 | ||
2699 | int __weak module_frob_arch_sections(Elf_Ehdr *hdr, | ||
2700 | Elf_Shdr *sechdrs, | ||
2701 | char *secstrings, | ||
2702 | struct module *mod) | ||
2703 | { | ||
2704 | return 0; | ||
2705 | } | ||
2706 | |||
2648 | static struct module *layout_and_allocate(struct load_info *info) | 2707 | static struct module *layout_and_allocate(struct load_info *info) |
2649 | { | 2708 | { |
2650 | /* Module within temporary copy. */ | 2709 | /* Module within temporary copy. */ |
@@ -2716,6 +2775,13 @@ static void module_deallocate(struct module *mod, struct load_info *info) | |||
2716 | module_free(mod, mod->module_core); | 2775 | module_free(mod, mod->module_core); |
2717 | } | 2776 | } |
2718 | 2777 | ||
2778 | int __weak module_finalize(const Elf_Ehdr *hdr, | ||
2779 | const Elf_Shdr *sechdrs, | ||
2780 | struct module *me) | ||
2781 | { | ||
2782 | return 0; | ||
2783 | } | ||
2784 | |||
2719 | static int post_relocation(struct module *mod, const struct load_info *info) | 2785 | static int post_relocation(struct module *mod, const struct load_info *info) |
2720 | { | 2786 | { |
2721 | /* Sort exception table now relocations are done. */ | 2787 | /* Sort exception table now relocations are done. */ |
diff --git a/kernel/params.c b/kernel/params.c index ed72e1330862..22df3e0d142a 100644 --- a/kernel/params.c +++ b/kernel/params.c | |||
@@ -225,8 +225,8 @@ int parse_args(const char *name, | |||
225 | int ret; \ | 225 | int ret; \ |
226 | \ | 226 | \ |
227 | ret = strtolfn(val, 0, &l); \ | 227 | ret = strtolfn(val, 0, &l); \ |
228 | if (ret == -EINVAL || ((type)l != l)) \ | 228 | if (ret < 0 || ((type)l != l)) \ |
229 | return -EINVAL; \ | 229 | return ret < 0 ? ret : -EINVAL; \ |
230 | *((type *)kp->arg) = l; \ | 230 | *((type *)kp->arg) = l; \ |
231 | return 0; \ | 231 | return 0; \ |
232 | } \ | 232 | } \ |
@@ -511,7 +511,7 @@ struct module_param_attrs | |||
511 | #define to_param_attr(n) container_of(n, struct param_attribute, mattr) | 511 | #define to_param_attr(n) container_of(n, struct param_attribute, mattr) |
512 | 512 | ||
513 | static ssize_t param_attr_show(struct module_attribute *mattr, | 513 | static ssize_t param_attr_show(struct module_attribute *mattr, |
514 | struct module *mod, char *buf) | 514 | struct module_kobject *mk, char *buf) |
515 | { | 515 | { |
516 | int count; | 516 | int count; |
517 | struct param_attribute *attribute = to_param_attr(mattr); | 517 | struct param_attribute *attribute = to_param_attr(mattr); |
@@ -531,7 +531,7 @@ static ssize_t param_attr_show(struct module_attribute *mattr, | |||
531 | 531 | ||
532 | /* sysfs always hands a nul-terminated string in buf. We rely on that. */ | 532 | /* sysfs always hands a nul-terminated string in buf. We rely on that. */ |
533 | static ssize_t param_attr_store(struct module_attribute *mattr, | 533 | static ssize_t param_attr_store(struct module_attribute *mattr, |
534 | struct module *owner, | 534 | struct module_kobject *km, |
535 | const char *buf, size_t len) | 535 | const char *buf, size_t len) |
536 | { | 536 | { |
537 | int err; | 537 | int err; |
@@ -730,6 +730,10 @@ static struct module_kobject * __init locate_module_kobject(const char *name) | |||
730 | mk->kobj.kset = module_kset; | 730 | mk->kobj.kset = module_kset; |
731 | err = kobject_init_and_add(&mk->kobj, &module_ktype, NULL, | 731 | err = kobject_init_and_add(&mk->kobj, &module_ktype, NULL, |
732 | "%s", name); | 732 | "%s", name); |
733 | #ifdef CONFIG_MODULES | ||
734 | if (!err) | ||
735 | err = sysfs_create_file(&mk->kobj, &module_uevent.attr); | ||
736 | #endif | ||
733 | if (err) { | 737 | if (err) { |
734 | kobject_put(&mk->kobj); | 738 | kobject_put(&mk->kobj); |
735 | printk(KERN_ERR | 739 | printk(KERN_ERR |
@@ -807,7 +811,7 @@ static void __init param_sysfs_builtin(void) | |||
807 | } | 811 | } |
808 | 812 | ||
809 | ssize_t __modver_version_show(struct module_attribute *mattr, | 813 | ssize_t __modver_version_show(struct module_attribute *mattr, |
810 | struct module *mod, char *buf) | 814 | struct module_kobject *mk, char *buf) |
811 | { | 815 | { |
812 | struct module_version_attribute *vattr = | 816 | struct module_version_attribute *vattr = |
813 | container_of(mattr, struct module_version_attribute, mattr); | 817 | container_of(mattr, struct module_version_attribute, mattr); |
@@ -852,7 +856,7 @@ static ssize_t module_attr_show(struct kobject *kobj, | |||
852 | if (!attribute->show) | 856 | if (!attribute->show) |
853 | return -EIO; | 857 | return -EIO; |
854 | 858 | ||
855 | ret = attribute->show(attribute, mk->mod, buf); | 859 | ret = attribute->show(attribute, mk, buf); |
856 | 860 | ||
857 | return ret; | 861 | return ret; |
858 | } | 862 | } |
@@ -871,7 +875,7 @@ static ssize_t module_attr_store(struct kobject *kobj, | |||
871 | if (!attribute->store) | 875 | if (!attribute->store) |
872 | return -EIO; | 876 | return -EIO; |
873 | 877 | ||
874 | ret = attribute->store(attribute, mk->mod, buf, len); | 878 | ret = attribute->store(attribute, mk, buf, len); |
875 | 879 | ||
876 | return ret; | 880 | return ret; |
877 | } | 881 | } |