diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-13 13:47:13 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-13 13:47:13 -0500 |
commit | a42cf70eb81558082e9a26fe8541d160b6c2a694 (patch) | |
tree | 53258e360c1934c8203bbed0e1f39df347185e37 /kernel | |
parent | f1252515d901ee2a184a9d49a7f29ae14da823eb (diff) | |
parent | 9cc019b8c94fa59e02fd82f15f7b7d689e35c190 (diff) |
Merge tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux
Pull module update from Rusty Russell:
"Trivial cleanups, mainly"
* tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
module: Replace over-engineered nested sleep
module: Annotate nested sleep in resolve_symbol()
module: Remove double spaces in module verification taint message
kernel/module.c: Free lock-classes if parse_args failed
module: set ksymtab/kcrctab* section addresses to 0x0
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/module.c | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/kernel/module.c b/kernel/module.c index d856e96a3cce..82dc1f899e6d 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -1225,6 +1225,12 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod, | |||
1225 | const unsigned long *crc; | 1225 | const unsigned long *crc; |
1226 | int err; | 1226 | int err; |
1227 | 1227 | ||
1228 | /* | ||
1229 | * The module_mutex should not be a heavily contended lock; | ||
1230 | * if we get the occasional sleep here, we'll go an extra iteration | ||
1231 | * in the wait_event_interruptible(), which is harmless. | ||
1232 | */ | ||
1233 | sched_annotate_sleep(); | ||
1228 | mutex_lock(&module_mutex); | 1234 | mutex_lock(&module_mutex); |
1229 | sym = find_symbol(name, &owner, &crc, | 1235 | sym = find_symbol(name, &owner, &crc, |
1230 | !(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true); | 1236 | !(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true); |
@@ -2978,6 +2984,12 @@ static bool finished_loading(const char *name) | |||
2978 | struct module *mod; | 2984 | struct module *mod; |
2979 | bool ret; | 2985 | bool ret; |
2980 | 2986 | ||
2987 | /* | ||
2988 | * The module_mutex should not be a heavily contended lock; | ||
2989 | * if we get the occasional sleep here, we'll go an extra iteration | ||
2990 | * in the wait_event_interruptible(), which is harmless. | ||
2991 | */ | ||
2992 | sched_annotate_sleep(); | ||
2981 | mutex_lock(&module_mutex); | 2993 | mutex_lock(&module_mutex); |
2982 | mod = find_module_all(name, strlen(name), true); | 2994 | mod = find_module_all(name, strlen(name), true); |
2983 | ret = !mod || mod->state == MODULE_STATE_LIVE | 2995 | ret = !mod || mod->state == MODULE_STATE_LIVE |
@@ -3120,32 +3132,6 @@ static int may_init_module(void) | |||
3120 | } | 3132 | } |
3121 | 3133 | ||
3122 | /* | 3134 | /* |
3123 | * Can't use wait_event_interruptible() because our condition | ||
3124 | * 'finished_loading()' contains a blocking primitive itself (mutex_lock). | ||
3125 | */ | ||
3126 | static int wait_finished_loading(struct module *mod) | ||
3127 | { | ||
3128 | DEFINE_WAIT_FUNC(wait, woken_wake_function); | ||
3129 | int ret = 0; | ||
3130 | |||
3131 | add_wait_queue(&module_wq, &wait); | ||
3132 | for (;;) { | ||
3133 | if (finished_loading(mod->name)) | ||
3134 | break; | ||
3135 | |||
3136 | if (signal_pending(current)) { | ||
3137 | ret = -ERESTARTSYS; | ||
3138 | break; | ||
3139 | } | ||
3140 | |||
3141 | wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); | ||
3142 | } | ||
3143 | remove_wait_queue(&module_wq, &wait); | ||
3144 | |||
3145 | return ret; | ||
3146 | } | ||
3147 | |||
3148 | /* | ||
3149 | * We try to place it in the list now to make sure it's unique before | 3135 | * We try to place it in the list now to make sure it's unique before |
3150 | * we dedicate too many resources. In particular, temporary percpu | 3136 | * we dedicate too many resources. In particular, temporary percpu |
3151 | * memory exhaustion. | 3137 | * memory exhaustion. |
@@ -3165,8 +3151,8 @@ again: | |||
3165 | || old->state == MODULE_STATE_UNFORMED) { | 3151 | || old->state == MODULE_STATE_UNFORMED) { |
3166 | /* Wait in case it fails to load. */ | 3152 | /* Wait in case it fails to load. */ |
3167 | mutex_unlock(&module_mutex); | 3153 | mutex_unlock(&module_mutex); |
3168 | 3154 | err = wait_event_interruptible(module_wq, | |
3169 | err = wait_finished_loading(mod); | 3155 | finished_loading(mod->name)); |
3170 | if (err) | 3156 | if (err) |
3171 | goto out_unlocked; | 3157 | goto out_unlocked; |
3172 | goto again; | 3158 | goto again; |
@@ -3265,7 +3251,7 @@ static int load_module(struct load_info *info, const char __user *uargs, | |||
3265 | mod->sig_ok = info->sig_ok; | 3251 | mod->sig_ok = info->sig_ok; |
3266 | if (!mod->sig_ok) { | 3252 | if (!mod->sig_ok) { |
3267 | pr_notice_once("%s: module verification failed: signature " | 3253 | pr_notice_once("%s: module verification failed: signature " |
3268 | "and/or required key missing - tainting " | 3254 | "and/or required key missing - tainting " |
3269 | "kernel\n", mod->name); | 3255 | "kernel\n", mod->name); |
3270 | add_taint_module(mod, TAINT_UNSIGNED_MODULE, LOCKDEP_STILL_OK); | 3256 | add_taint_module(mod, TAINT_UNSIGNED_MODULE, LOCKDEP_STILL_OK); |
3271 | } | 3257 | } |
@@ -3356,6 +3342,9 @@ static int load_module(struct load_info *info, const char __user *uargs, | |||
3356 | module_bug_cleanup(mod); | 3342 | module_bug_cleanup(mod); |
3357 | mutex_unlock(&module_mutex); | 3343 | mutex_unlock(&module_mutex); |
3358 | 3344 | ||
3345 | /* Free lock-classes: */ | ||
3346 | lockdep_free_key_range(mod->module_core, mod->core_size); | ||
3347 | |||
3359 | /* we can't deallocate the module until we clear memory protection */ | 3348 | /* we can't deallocate the module until we clear memory protection */ |
3360 | unset_module_init_ro_nx(mod); | 3349 | unset_module_init_ro_nx(mod); |
3361 | unset_module_core_ro_nx(mod); | 3350 | unset_module_core_ro_nx(mod); |