diff options
Diffstat (limited to 'include/linux/moduleparam.h')
-rw-r--r-- | include/linux/moduleparam.h | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 494f99e852da..b43f4752304e 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h | |||
@@ -42,7 +42,7 @@ struct kernel_param; | |||
42 | * NOARG - the parameter allows for no argument (foo instead of foo=1) | 42 | * NOARG - the parameter allows for no argument (foo instead of foo=1) |
43 | */ | 43 | */ |
44 | enum { | 44 | enum { |
45 | KERNEL_PARAM_FL_NOARG = (1 << 0) | 45 | KERNEL_PARAM_OPS_FL_NOARG = (1 << 0) |
46 | }; | 46 | }; |
47 | 47 | ||
48 | struct kernel_param_ops { | 48 | struct kernel_param_ops { |
@@ -56,11 +56,21 @@ struct kernel_param_ops { | |||
56 | void (*free)(void *arg); | 56 | void (*free)(void *arg); |
57 | }; | 57 | }; |
58 | 58 | ||
59 | /* | ||
60 | * Flags available for kernel_param | ||
61 | * | ||
62 | * UNSAFE - the parameter is dangerous and setting it will taint the kernel | ||
63 | */ | ||
64 | enum { | ||
65 | KERNEL_PARAM_FL_UNSAFE = (1 << 0) | ||
66 | }; | ||
67 | |||
59 | struct kernel_param { | 68 | struct kernel_param { |
60 | const char *name; | 69 | const char *name; |
61 | const struct kernel_param_ops *ops; | 70 | const struct kernel_param_ops *ops; |
62 | u16 perm; | 71 | u16 perm; |
63 | s16 level; | 72 | s8 level; |
73 | u8 flags; | ||
64 | union { | 74 | union { |
65 | void *arg; | 75 | void *arg; |
66 | const struct kparam_string *str; | 76 | const struct kparam_string *str; |
@@ -113,6 +123,12 @@ struct kparam_array | |||
113 | module_param_named(name, name, type, perm) | 123 | module_param_named(name, name, type, perm) |
114 | 124 | ||
115 | /** | 125 | /** |
126 | * module_param_unsafe - same as module_param but taints kernel | ||
127 | */ | ||
128 | #define module_param_unsafe(name, type, perm) \ | ||
129 | module_param_named_unsafe(name, name, type, perm) | ||
130 | |||
131 | /** | ||
116 | * module_param_named - typesafe helper for a renamed module/cmdline parameter | 132 | * module_param_named - typesafe helper for a renamed module/cmdline parameter |
117 | * @name: a valid C identifier which is the parameter name. | 133 | * @name: a valid C identifier which is the parameter name. |
118 | * @value: the actual lvalue to alter. | 134 | * @value: the actual lvalue to alter. |
@@ -129,6 +145,14 @@ struct kparam_array | |||
129 | __MODULE_PARM_TYPE(name, #type) | 145 | __MODULE_PARM_TYPE(name, #type) |
130 | 146 | ||
131 | /** | 147 | /** |
148 | * module_param_named_unsafe - same as module_param_named but taints kernel | ||
149 | */ | ||
150 | #define module_param_named_unsafe(name, value, type, perm) \ | ||
151 | param_check_##type(name, &(value)); \ | ||
152 | module_param_cb_unsafe(name, ¶m_ops_##type, &value, perm); \ | ||
153 | __MODULE_PARM_TYPE(name, #type) | ||
154 | |||
155 | /** | ||
132 | * module_param_cb - general callback for a module/cmdline parameter | 156 | * module_param_cb - general callback for a module/cmdline parameter |
133 | * @name: a valid C identifier which is the parameter name. | 157 | * @name: a valid C identifier which is the parameter name. |
134 | * @ops: the set & get operations for this parameter. | 158 | * @ops: the set & get operations for this parameter. |
@@ -137,7 +161,11 @@ struct kparam_array | |||
137 | * The ops can have NULL set or get functions. | 161 | * The ops can have NULL set or get functions. |
138 | */ | 162 | */ |
139 | #define module_param_cb(name, ops, arg, perm) \ | 163 | #define module_param_cb(name, ops, arg, perm) \ |
140 | __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1) | 164 | __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0) |
165 | |||
166 | #define module_param_cb_unsafe(name, ops, arg, perm) \ | ||
167 | __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, \ | ||
168 | KERNEL_PARAM_FL_UNSAFE) | ||
141 | 169 | ||
142 | /** | 170 | /** |
143 | * <level>_param_cb - general callback for a module/cmdline parameter | 171 | * <level>_param_cb - general callback for a module/cmdline parameter |
@@ -149,7 +177,7 @@ struct kparam_array | |||
149 | * The ops can have NULL set or get functions. | 177 | * The ops can have NULL set or get functions. |
150 | */ | 178 | */ |
151 | #define __level_param_cb(name, ops, arg, perm, level) \ | 179 | #define __level_param_cb(name, ops, arg, perm, level) \ |
152 | __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, level) | 180 | __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, level, 0) |
153 | 181 | ||
154 | #define core_param_cb(name, ops, arg, perm) \ | 182 | #define core_param_cb(name, ops, arg, perm) \ |
155 | __level_param_cb(name, ops, arg, perm, 1) | 183 | __level_param_cb(name, ops, arg, perm, 1) |
@@ -184,22 +212,22 @@ struct kparam_array | |||
184 | 212 | ||
185 | /* This is the fundamental function for registering boot/module | 213 | /* This is the fundamental function for registering boot/module |
186 | parameters. */ | 214 | parameters. */ |
187 | #define __module_param_call(prefix, name, ops, arg, perm, level) \ | 215 | #define __module_param_call(prefix, name, ops, arg, perm, level, flags) \ |
188 | /* Default value instead of permissions? */ \ | 216 | /* Default value instead of permissions? */ \ |
189 | static const char __param_str_##name[] = prefix #name; \ | 217 | static const char __param_str_##name[] = prefix #name; \ |
190 | static struct kernel_param __moduleparam_const __param_##name \ | 218 | static struct kernel_param __moduleparam_const __param_##name \ |
191 | __used \ | 219 | __used \ |
192 | __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ | 220 | __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ |
193 | = { __param_str_##name, ops, VERIFY_OCTAL_PERMISSIONS(perm), \ | 221 | = { __param_str_##name, ops, VERIFY_OCTAL_PERMISSIONS(perm), \ |
194 | level, { arg } } | 222 | level, flags, { arg } } |
195 | 223 | ||
196 | /* Obsolete - use module_param_cb() */ | 224 | /* Obsolete - use module_param_cb() */ |
197 | #define module_param_call(name, set, get, arg, perm) \ | 225 | #define module_param_call(name, set, get, arg, perm) \ |
198 | static struct kernel_param_ops __param_ops_##name = \ | 226 | static struct kernel_param_ops __param_ops_##name = \ |
199 | { 0, (void *)set, (void *)get }; \ | 227 | { .flags = 0, (void *)set, (void *)get }; \ |
200 | __module_param_call(MODULE_PARAM_PREFIX, \ | 228 | __module_param_call(MODULE_PARAM_PREFIX, \ |
201 | name, &__param_ops_##name, arg, \ | 229 | name, &__param_ops_##name, arg, \ |
202 | (perm) + sizeof(__check_old_set_param(set))*0, -1) | 230 | (perm) + sizeof(__check_old_set_param(set))*0, -1, 0) |
203 | 231 | ||
204 | /* We don't get oldget: it's often a new-style param_get_uint, etc. */ | 232 | /* We don't get oldget: it's often a new-style param_get_uint, etc. */ |
205 | static inline int | 233 | static inline int |
@@ -279,7 +307,7 @@ static inline void __kernel_param_unlock(void) | |||
279 | */ | 307 | */ |
280 | #define core_param(name, var, type, perm) \ | 308 | #define core_param(name, var, type, perm) \ |
281 | param_check_##type(name, &(var)); \ | 309 | param_check_##type(name, &(var)); \ |
282 | __module_param_call("", name, ¶m_ops_##type, &var, perm, -1) | 310 | __module_param_call("", name, ¶m_ops_##type, &var, perm, -1, 0) |
283 | #endif /* !MODULE */ | 311 | #endif /* !MODULE */ |
284 | 312 | ||
285 | /** | 313 | /** |
@@ -297,7 +325,7 @@ static inline void __kernel_param_unlock(void) | |||
297 | = { len, string }; \ | 325 | = { len, string }; \ |
298 | __module_param_call(MODULE_PARAM_PREFIX, name, \ | 326 | __module_param_call(MODULE_PARAM_PREFIX, name, \ |
299 | ¶m_ops_string, \ | 327 | ¶m_ops_string, \ |
300 | .str = &__param_string_##name, perm, -1); \ | 328 | .str = &__param_string_##name, perm, -1, 0);\ |
301 | __MODULE_PARM_TYPE(name, "string") | 329 | __MODULE_PARM_TYPE(name, "string") |
302 | 330 | ||
303 | /** | 331 | /** |
@@ -444,7 +472,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp); | |||
444 | __module_param_call(MODULE_PARAM_PREFIX, name, \ | 472 | __module_param_call(MODULE_PARAM_PREFIX, name, \ |
445 | ¶m_array_ops, \ | 473 | ¶m_array_ops, \ |
446 | .arr = &__param_arr_##name, \ | 474 | .arr = &__param_arr_##name, \ |
447 | perm, -1); \ | 475 | perm, -1, 0); \ |
448 | __MODULE_PARM_TYPE(name, "array of " #type) | 476 | __MODULE_PARM_TYPE(name, "array of " #type) |
449 | 477 | ||
450 | extern struct kernel_param_ops param_array_ops; | 478 | extern struct kernel_param_ops param_array_ops; |