diff options
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/kernel/module.c b/kernel/module.c index 2c932760fd33..78ac6ec1e425 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -105,6 +105,7 @@ struct list_head *kdb_modules = &modules; /* kdb needs the list of modules */ | |||
105 | 105 | ||
106 | /* Block module loading/unloading? */ | 106 | /* Block module loading/unloading? */ |
107 | int modules_disabled = 0; | 107 | int modules_disabled = 0; |
108 | core_param(nomodule, modules_disabled, bint, 0); | ||
108 | 109 | ||
109 | /* Waiting for a module to finish initializing? */ | 110 | /* Waiting for a module to finish initializing? */ |
110 | static DECLARE_WAIT_QUEUE_HEAD(module_wq); | 111 | static DECLARE_WAIT_QUEUE_HEAD(module_wq); |
@@ -903,6 +904,36 @@ static ssize_t show_refcnt(struct module_attribute *mattr, | |||
903 | static struct module_attribute modinfo_refcnt = | 904 | static struct module_attribute modinfo_refcnt = |
904 | __ATTR(refcnt, 0444, show_refcnt, NULL); | 905 | __ATTR(refcnt, 0444, show_refcnt, NULL); |
905 | 906 | ||
907 | void __module_get(struct module *module) | ||
908 | { | ||
909 | if (module) { | ||
910 | preempt_disable(); | ||
911 | __this_cpu_inc(module->refptr->incs); | ||
912 | trace_module_get(module, _RET_IP_); | ||
913 | preempt_enable(); | ||
914 | } | ||
915 | } | ||
916 | EXPORT_SYMBOL(__module_get); | ||
917 | |||
918 | bool try_module_get(struct module *module) | ||
919 | { | ||
920 | bool ret = true; | ||
921 | |||
922 | if (module) { | ||
923 | preempt_disable(); | ||
924 | |||
925 | if (likely(module_is_live(module))) { | ||
926 | __this_cpu_inc(module->refptr->incs); | ||
927 | trace_module_get(module, _RET_IP_); | ||
928 | } else | ||
929 | ret = false; | ||
930 | |||
931 | preempt_enable(); | ||
932 | } | ||
933 | return ret; | ||
934 | } | ||
935 | EXPORT_SYMBOL(try_module_get); | ||
936 | |||
906 | void module_put(struct module *module) | 937 | void module_put(struct module *module) |
907 | { | 938 | { |
908 | if (module) { | 939 | if (module) { |
@@ -2380,8 +2411,7 @@ static int copy_and_check(struct load_info *info, | |||
2380 | return -ENOEXEC; | 2411 | return -ENOEXEC; |
2381 | 2412 | ||
2382 | /* Suck in entire file: we'll want most of it. */ | 2413 | /* Suck in entire file: we'll want most of it. */ |
2383 | /* vmalloc barfs on "unusual" numbers. Check here */ | 2414 | if ((hdr = vmalloc(len)) == NULL) |
2384 | if (len > 64 * 1024 * 1024 || (hdr = vmalloc(len)) == NULL) | ||
2385 | return -ENOMEM; | 2415 | return -ENOMEM; |
2386 | 2416 | ||
2387 | if (copy_from_user(hdr, umod, len) != 0) { | 2417 | if (copy_from_user(hdr, umod, len) != 0) { |
@@ -2922,7 +2952,8 @@ static struct module *load_module(void __user *umod, | |||
2922 | mutex_unlock(&module_mutex); | 2952 | mutex_unlock(&module_mutex); |
2923 | 2953 | ||
2924 | /* Module is ready to execute: parsing args may do that. */ | 2954 | /* Module is ready to execute: parsing args may do that. */ |
2925 | err = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, NULL); | 2955 | err = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, |
2956 | -32768, 32767, NULL); | ||
2926 | if (err < 0) | 2957 | if (err < 0) |
2927 | goto unlink; | 2958 | goto unlink; |
2928 | 2959 | ||