diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-07 20:17:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-07 20:17:38 -0400 |
commit | bdf428feb225229b1d4715b45bbdad4a934cd89c (patch) | |
tree | 9bc47e348c2081fd46c0f7d715780ce294a6953d /kernel/params.c | |
parent | a40a7201a4584a66ab234ba1006472be952f20e0 (diff) | |
parent | 184c3fc3f52fb75800deb76deffb70907d1f76ea (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:
"Nothing major: support for compressing modules, and auto-tainting
params.
PS. My virtio-next tree is empty: DaveM took the patches I had. There
might be a virtio-rng starvation fix, but so far it's a bit voodoo
so I will get to that in the next two days or it will wait"
* tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
moduleparam: Resolve missing-field-initializer warning
kbuild: handle module compression while running 'make modules_install'.
modinst: wrap long lines in order to enhance cmd_modules_install
modsign: lookup lines ending in .ko in .mod files
modpost: simplify file name generation of *.mod.c files
modpost: reduce visibility of symbols and constify r/o arrays
param: check for tainting before calling set op.
drm/i915: taint the kernel if unsafe module parameters are set
module: add module_param_unsafe and module_param_named_unsafe
module: make it possible to have unsafe, tainting module params
module: rename KERNEL_PARAM_FL_NOARG to avoid confusion
Diffstat (limited to 'kernel/params.c')
-rw-r--r-- | kernel/params.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/kernel/params.c b/kernel/params.c index 34f527023794..041b5899d5e2 100644 --- a/kernel/params.c +++ b/kernel/params.c | |||
@@ -83,6 +83,15 @@ bool parameq(const char *a, const char *b) | |||
83 | return parameqn(a, b, strlen(a)+1); | 83 | return parameqn(a, b, strlen(a)+1); |
84 | } | 84 | } |
85 | 85 | ||
86 | static void param_check_unsafe(const struct kernel_param *kp) | ||
87 | { | ||
88 | if (kp->flags & KERNEL_PARAM_FL_UNSAFE) { | ||
89 | pr_warn("Setting dangerous option %s - tainting kernel\n", | ||
90 | kp->name); | ||
91 | add_taint(TAINT_USER, LOCKDEP_STILL_OK); | ||
92 | } | ||
93 | } | ||
94 | |||
86 | static int parse_one(char *param, | 95 | static int parse_one(char *param, |
87 | char *val, | 96 | char *val, |
88 | const char *doing, | 97 | const char *doing, |
@@ -104,11 +113,12 @@ static int parse_one(char *param, | |||
104 | return 0; | 113 | return 0; |
105 | /* No one handled NULL, so do it here. */ | 114 | /* No one handled NULL, so do it here. */ |
106 | if (!val && | 115 | if (!val && |
107 | !(params[i].ops->flags & KERNEL_PARAM_FL_NOARG)) | 116 | !(params[i].ops->flags & KERNEL_PARAM_OPS_FL_NOARG)) |
108 | return -EINVAL; | 117 | return -EINVAL; |
109 | pr_debug("handling %s with %p\n", param, | 118 | pr_debug("handling %s with %p\n", param, |
110 | params[i].ops->set); | 119 | params[i].ops->set); |
111 | mutex_lock(¶m_lock); | 120 | mutex_lock(¶m_lock); |
121 | param_check_unsafe(¶ms[i]); | ||
112 | err = params[i].ops->set(val, ¶ms[i]); | 122 | err = params[i].ops->set(val, ¶ms[i]); |
113 | mutex_unlock(¶m_lock); | 123 | mutex_unlock(¶m_lock); |
114 | return err; | 124 | return err; |
@@ -318,7 +328,7 @@ int param_get_bool(char *buffer, const struct kernel_param *kp) | |||
318 | EXPORT_SYMBOL(param_get_bool); | 328 | EXPORT_SYMBOL(param_get_bool); |
319 | 329 | ||
320 | struct kernel_param_ops param_ops_bool = { | 330 | struct kernel_param_ops param_ops_bool = { |
321 | .flags = KERNEL_PARAM_FL_NOARG, | 331 | .flags = KERNEL_PARAM_OPS_FL_NOARG, |
322 | .set = param_set_bool, | 332 | .set = param_set_bool, |
323 | .get = param_get_bool, | 333 | .get = param_get_bool, |
324 | }; | 334 | }; |
@@ -369,7 +379,7 @@ int param_set_bint(const char *val, const struct kernel_param *kp) | |||
369 | EXPORT_SYMBOL(param_set_bint); | 379 | EXPORT_SYMBOL(param_set_bint); |
370 | 380 | ||
371 | struct kernel_param_ops param_ops_bint = { | 381 | struct kernel_param_ops param_ops_bint = { |
372 | .flags = KERNEL_PARAM_FL_NOARG, | 382 | .flags = KERNEL_PARAM_OPS_FL_NOARG, |
373 | .set = param_set_bint, | 383 | .set = param_set_bint, |
374 | .get = param_get_int, | 384 | .get = param_get_int, |
375 | }; | 385 | }; |
@@ -552,6 +562,7 @@ static ssize_t param_attr_store(struct module_attribute *mattr, | |||
552 | return -EPERM; | 562 | return -EPERM; |
553 | 563 | ||
554 | mutex_lock(¶m_lock); | 564 | mutex_lock(¶m_lock); |
565 | param_check_unsafe(attribute->param); | ||
555 | err = attribute->param->ops->set(buf, attribute->param); | 566 | err = attribute->param->ops->set(buf, attribute->param); |
556 | mutex_unlock(¶m_lock); | 567 | mutex_unlock(¶m_lock); |
557 | if (!err) | 568 | if (!err) |