diff options
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/kernel/module.c b/kernel/module.c index 8a94e054230c..8c25b1a04fa6 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -653,20 +653,11 @@ static void wait_for_zero_refcount(struct module *mod) | |||
653 | mutex_lock(&module_mutex); | 653 | mutex_lock(&module_mutex); |
654 | } | 654 | } |
655 | 655 | ||
656 | asmlinkage long | 656 | int delete_module(const char *name, unsigned int flags) |
657 | sys_delete_module(const char __user *name_user, unsigned int flags) | ||
658 | { | 657 | { |
659 | struct module *mod; | 658 | struct module *mod; |
660 | char name[MODULE_NAME_LEN]; | ||
661 | int ret, forced = 0; | 659 | int ret, forced = 0; |
662 | 660 | ||
663 | if (!capable(CAP_SYS_MODULE)) | ||
664 | return -EPERM; | ||
665 | |||
666 | if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) | ||
667 | return -EFAULT; | ||
668 | name[MODULE_NAME_LEN-1] = '\0'; | ||
669 | |||
670 | if (mutex_lock_interruptible(&module_mutex) != 0) | 661 | if (mutex_lock_interruptible(&module_mutex) != 0) |
671 | return -EINTR; | 662 | return -EINTR; |
672 | 663 | ||
@@ -727,6 +718,21 @@ sys_delete_module(const char __user *name_user, unsigned int flags) | |||
727 | return ret; | 718 | return ret; |
728 | } | 719 | } |
729 | 720 | ||
721 | asmlinkage long | ||
722 | sys_delete_module(const char __user *name_user, unsigned int flags) | ||
723 | { | ||
724 | char name[MODULE_NAME_LEN]; | ||
725 | |||
726 | if (!capable(CAP_SYS_MODULE)) | ||
727 | return -EPERM; | ||
728 | |||
729 | if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) | ||
730 | return -EFAULT; | ||
731 | name[MODULE_NAME_LEN-1] = '\0'; | ||
732 | |||
733 | return delete_module(name, flags); | ||
734 | } | ||
735 | |||
730 | static void print_unload_info(struct seq_file *m, struct module *mod) | 736 | static void print_unload_info(struct seq_file *m, struct module *mod) |
731 | { | 737 | { |
732 | struct module_use *use; | 738 | struct module_use *use; |
@@ -1068,7 +1074,8 @@ static inline void remove_sect_attrs(struct module *mod) | |||
1068 | } | 1074 | } |
1069 | #endif /* CONFIG_KALLSYMS */ | 1075 | #endif /* CONFIG_KALLSYMS */ |
1070 | 1076 | ||
1071 | static int module_add_modinfo_attrs(struct module *mod) | 1077 | #ifdef CONFIG_SYSFS |
1078 | int module_add_modinfo_attrs(struct module *mod) | ||
1072 | { | 1079 | { |
1073 | struct module_attribute *attr; | 1080 | struct module_attribute *attr; |
1074 | struct module_attribute *temp_attr; | 1081 | struct module_attribute *temp_attr; |
@@ -1094,7 +1101,7 @@ static int module_add_modinfo_attrs(struct module *mod) | |||
1094 | return error; | 1101 | return error; |
1095 | } | 1102 | } |
1096 | 1103 | ||
1097 | static void module_remove_modinfo_attrs(struct module *mod) | 1104 | void module_remove_modinfo_attrs(struct module *mod) |
1098 | { | 1105 | { |
1099 | struct module_attribute *attr; | 1106 | struct module_attribute *attr; |
1100 | int i; | 1107 | int i; |
@@ -1109,8 +1116,10 @@ static void module_remove_modinfo_attrs(struct module *mod) | |||
1109 | } | 1116 | } |
1110 | kfree(mod->modinfo_attrs); | 1117 | kfree(mod->modinfo_attrs); |
1111 | } | 1118 | } |
1119 | #endif | ||
1112 | 1120 | ||
1113 | static int mod_sysfs_init(struct module *mod) | 1121 | #ifdef CONFIG_SYSFS |
1122 | int mod_sysfs_init(struct module *mod) | ||
1114 | { | 1123 | { |
1115 | int err; | 1124 | int err; |
1116 | 1125 | ||
@@ -1133,7 +1142,7 @@ out: | |||
1133 | return err; | 1142 | return err; |
1134 | } | 1143 | } |
1135 | 1144 | ||
1136 | static int mod_sysfs_setup(struct module *mod, | 1145 | int mod_sysfs_setup(struct module *mod, |
1137 | struct kernel_param *kparam, | 1146 | struct kernel_param *kparam, |
1138 | unsigned int num_params) | 1147 | unsigned int num_params) |
1139 | { | 1148 | { |
@@ -1169,16 +1178,14 @@ out_unreg: | |||
1169 | out: | 1178 | out: |
1170 | return err; | 1179 | return err; |
1171 | } | 1180 | } |
1181 | #endif | ||
1172 | 1182 | ||
1173 | static void mod_kobject_remove(struct module *mod) | 1183 | static void mod_kobject_remove(struct module *mod) |
1174 | { | 1184 | { |
1175 | module_remove_modinfo_attrs(mod); | 1185 | module_remove_modinfo_attrs(mod); |
1176 | module_param_sysfs_remove(mod); | 1186 | module_param_sysfs_remove(mod); |
1177 | if (mod->mkobj.drivers_dir) | 1187 | kobject_unregister(mod->mkobj.drivers_dir); |
1178 | kobject_unregister(mod->mkobj.drivers_dir); | 1188 | kobject_unregister(mod->holders_dir); |
1179 | if (mod->holders_dir) | ||
1180 | kobject_unregister(mod->holders_dir); | ||
1181 | |||
1182 | kobject_unregister(&mod->mkobj.kobj); | 1189 | kobject_unregister(&mod->mkobj.kobj); |
1183 | } | 1190 | } |
1184 | 1191 | ||
@@ -2345,6 +2352,7 @@ void print_modules(void) | |||
2345 | printk("\n"); | 2352 | printk("\n"); |
2346 | } | 2353 | } |
2347 | 2354 | ||
2355 | #ifdef CONFIG_SYSFS | ||
2348 | static char *make_driver_name(struct device_driver *drv) | 2356 | static char *make_driver_name(struct device_driver *drv) |
2349 | { | 2357 | { |
2350 | char *driver_name; | 2358 | char *driver_name; |
@@ -2419,6 +2427,7 @@ void module_remove_driver(struct device_driver *drv) | |||
2419 | } | 2427 | } |
2420 | } | 2428 | } |
2421 | EXPORT_SYMBOL(module_remove_driver); | 2429 | EXPORT_SYMBOL(module_remove_driver); |
2430 | #endif | ||
2422 | 2431 | ||
2423 | #ifdef CONFIG_MODVERSIONS | 2432 | #ifdef CONFIG_MODVERSIONS |
2424 | /* Generate the signature for struct module here, too, for modversions. */ | 2433 | /* Generate the signature for struct module here, too, for modversions. */ |