diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-11 19:09:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-11 19:09:14 -0400 |
commit | 4251c2a67011801caecd63671f26dd8c9aedb24c (patch) | |
tree | 06f659cb3f9e91fb2b8fc92791b5e021754e025e /kernel | |
parent | c31c24b8251fd44962a9b0bf82c770653bf07f6e (diff) | |
parent | 4982223e51e8ea9d09bb33c8323b5ec1877b2b51 (diff) |
Merge tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux
Pull module updates from Rusty Russell:
"Most of this is cleaning up various driver sysfs permissions so we can
re-add the perm check (we unified the module param and sysfs checks,
but the module ones were stronger so we weakened them temporarily).
Param parsing gets documented, and also "--" now forces args to be
handed to init (and ignored by the kernel).
Module NX/RO protections get tightened: we now set them before calling
parse_args()"
* tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
module: set nx before marking module MODULE_STATE_COMING.
samples/kobject/: avoid world-writable sysfs files.
drivers/hid/hid-picolcd_fb: avoid world-writable sysfs files.
drivers/staging/speakup/: avoid world-writable sysfs files.
drivers/regulator/virtual: avoid world-writable sysfs files.
drivers/scsi/pm8001/pm8001_ctl.c: avoid world-writable sysfs files.
drivers/hid/hid-lg4ff.c: avoid world-writable sysfs files.
drivers/video/fbdev/sm501fb.c: avoid world-writable sysfs files.
drivers/mtd/devices/docg3.c: avoid world-writable sysfs files.
speakup: fix incorrect perms on speakup_acntsa.c
cpumask.h: silence warning with -Wsign-compare
Documentation: Update kernel-parameters.tx
param: hand arguments after -- straight to init
modpost: Fix resource leak in read_dump()
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/module.c | 44 | ||||
-rw-r--r-- | kernel/params.c | 25 |
2 files changed, 40 insertions, 29 deletions
diff --git a/kernel/module.c b/kernel/module.c index 079c4615607d..81e727cf6df9 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -3020,21 +3020,6 @@ static int do_init_module(struct module *mod) | |||
3020 | */ | 3020 | */ |
3021 | current->flags &= ~PF_USED_ASYNC; | 3021 | current->flags &= ~PF_USED_ASYNC; |
3022 | 3022 | ||
3023 | blocking_notifier_call_chain(&module_notify_list, | ||
3024 | MODULE_STATE_COMING, mod); | ||
3025 | |||
3026 | /* Set RO and NX regions for core */ | ||
3027 | set_section_ro_nx(mod->module_core, | ||
3028 | mod->core_text_size, | ||
3029 | mod->core_ro_size, | ||
3030 | mod->core_size); | ||
3031 | |||
3032 | /* Set RO and NX regions for init */ | ||
3033 | set_section_ro_nx(mod->module_init, | ||
3034 | mod->init_text_size, | ||
3035 | mod->init_ro_size, | ||
3036 | mod->init_size); | ||
3037 | |||
3038 | do_mod_ctors(mod); | 3023 | do_mod_ctors(mod); |
3039 | /* Start the module */ | 3024 | /* Start the module */ |
3040 | if (mod->init != NULL) | 3025 | if (mod->init != NULL) |
@@ -3165,9 +3150,26 @@ static int complete_formation(struct module *mod, struct load_info *info) | |||
3165 | /* This relies on module_mutex for list integrity. */ | 3150 | /* This relies on module_mutex for list integrity. */ |
3166 | module_bug_finalize(info->hdr, info->sechdrs, mod); | 3151 | module_bug_finalize(info->hdr, info->sechdrs, mod); |
3167 | 3152 | ||
3153 | /* Set RO and NX regions for core */ | ||
3154 | set_section_ro_nx(mod->module_core, | ||
3155 | mod->core_text_size, | ||
3156 | mod->core_ro_size, | ||
3157 | mod->core_size); | ||
3158 | |||
3159 | /* Set RO and NX regions for init */ | ||
3160 | set_section_ro_nx(mod->module_init, | ||
3161 | mod->init_text_size, | ||
3162 | mod->init_ro_size, | ||
3163 | mod->init_size); | ||
3164 | |||
3168 | /* Mark state as coming so strong_try_module_get() ignores us, | 3165 | /* Mark state as coming so strong_try_module_get() ignores us, |
3169 | * but kallsyms etc. can see us. */ | 3166 | * but kallsyms etc. can see us. */ |
3170 | mod->state = MODULE_STATE_COMING; | 3167 | mod->state = MODULE_STATE_COMING; |
3168 | mutex_unlock(&module_mutex); | ||
3169 | |||
3170 | blocking_notifier_call_chain(&module_notify_list, | ||
3171 | MODULE_STATE_COMING, mod); | ||
3172 | return 0; | ||
3171 | 3173 | ||
3172 | out: | 3174 | out: |
3173 | mutex_unlock(&module_mutex); | 3175 | mutex_unlock(&module_mutex); |
@@ -3190,6 +3192,7 @@ static int load_module(struct load_info *info, const char __user *uargs, | |||
3190 | { | 3192 | { |
3191 | struct module *mod; | 3193 | struct module *mod; |
3192 | long err; | 3194 | long err; |
3195 | char *after_dashes; | ||
3193 | 3196 | ||
3194 | err = module_sig_check(info); | 3197 | err = module_sig_check(info); |
3195 | if (err) | 3198 | if (err) |
@@ -3277,10 +3280,15 @@ static int load_module(struct load_info *info, const char __user *uargs, | |||
3277 | goto ddebug_cleanup; | 3280 | goto ddebug_cleanup; |
3278 | 3281 | ||
3279 | /* Module is ready to execute: parsing args may do that. */ | 3282 | /* Module is ready to execute: parsing args may do that. */ |
3280 | err = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, | 3283 | after_dashes = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, |
3281 | -32768, 32767, unknown_module_param_cb); | 3284 | -32768, 32767, unknown_module_param_cb); |
3282 | if (err < 0) | 3285 | if (IS_ERR(after_dashes)) { |
3286 | err = PTR_ERR(after_dashes); | ||
3283 | goto bug_cleanup; | 3287 | goto bug_cleanup; |
3288 | } else if (after_dashes) { | ||
3289 | pr_warn("%s: parameters '%s' after `--' ignored\n", | ||
3290 | mod->name, after_dashes); | ||
3291 | } | ||
3284 | 3292 | ||
3285 | /* Link in to syfs. */ | 3293 | /* Link in to syfs. */ |
3286 | err = mod_sysfs_setup(mod, info, mod->kp, mod->num_kp); | 3294 | err = mod_sysfs_setup(mod, info, mod->kp, mod->num_kp); |
diff --git a/kernel/params.c b/kernel/params.c index b00142e7f3ba..1e52ca233fd9 100644 --- a/kernel/params.c +++ b/kernel/params.c | |||
@@ -177,13 +177,13 @@ static char *next_arg(char *args, char **param, char **val) | |||
177 | } | 177 | } |
178 | 178 | ||
179 | /* Args looks like "foo=bar,bar2 baz=fuz wiz". */ | 179 | /* Args looks like "foo=bar,bar2 baz=fuz wiz". */ |
180 | int parse_args(const char *doing, | 180 | char *parse_args(const char *doing, |
181 | char *args, | 181 | char *args, |
182 | const struct kernel_param *params, | 182 | const struct kernel_param *params, |
183 | unsigned num, | 183 | unsigned num, |
184 | s16 min_level, | 184 | s16 min_level, |
185 | s16 max_level, | 185 | s16 max_level, |
186 | int (*unknown)(char *param, char *val, const char *doing)) | 186 | int (*unknown)(char *param, char *val, const char *doing)) |
187 | { | 187 | { |
188 | char *param, *val; | 188 | char *param, *val; |
189 | 189 | ||
@@ -198,6 +198,9 @@ int parse_args(const char *doing, | |||
198 | int irq_was_disabled; | 198 | int irq_was_disabled; |
199 | 199 | ||
200 | args = next_arg(args, ¶m, &val); | 200 | args = next_arg(args, ¶m, &val); |
201 | /* Stop at -- */ | ||
202 | if (!val && strcmp(param, "--") == 0) | ||
203 | return args; | ||
201 | irq_was_disabled = irqs_disabled(); | 204 | irq_was_disabled = irqs_disabled(); |
202 | ret = parse_one(param, val, doing, params, num, | 205 | ret = parse_one(param, val, doing, params, num, |
203 | min_level, max_level, unknown); | 206 | min_level, max_level, unknown); |
@@ -208,22 +211,22 @@ int parse_args(const char *doing, | |||
208 | switch (ret) { | 211 | switch (ret) { |
209 | case -ENOENT: | 212 | case -ENOENT: |
210 | pr_err("%s: Unknown parameter `%s'\n", doing, param); | 213 | pr_err("%s: Unknown parameter `%s'\n", doing, param); |
211 | return ret; | 214 | return ERR_PTR(ret); |
212 | case -ENOSPC: | 215 | case -ENOSPC: |
213 | pr_err("%s: `%s' too large for parameter `%s'\n", | 216 | pr_err("%s: `%s' too large for parameter `%s'\n", |
214 | doing, val ?: "", param); | 217 | doing, val ?: "", param); |
215 | return ret; | 218 | return ERR_PTR(ret); |
216 | case 0: | 219 | case 0: |
217 | break; | 220 | break; |
218 | default: | 221 | default: |
219 | pr_err("%s: `%s' invalid for parameter `%s'\n", | 222 | pr_err("%s: `%s' invalid for parameter `%s'\n", |
220 | doing, val ?: "", param); | 223 | doing, val ?: "", param); |
221 | return ret; | 224 | return ERR_PTR(ret); |
222 | } | 225 | } |
223 | } | 226 | } |
224 | 227 | ||
225 | /* All parsed OK. */ | 228 | /* All parsed OK. */ |
226 | return 0; | 229 | return NULL; |
227 | } | 230 | } |
228 | 231 | ||
229 | /* Lazy bastard, eh? */ | 232 | /* Lazy bastard, eh? */ |