diff options
Diffstat (limited to 'include/linux/moduleparam.h')
| -rw-r--r-- | include/linux/moduleparam.h | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 494f99e852da..1c9effa25e26 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; |
| @@ -68,6 +78,8 @@ struct kernel_param { | |||
| 68 | }; | 78 | }; |
| 69 | }; | 79 | }; |
| 70 | 80 | ||
| 81 | extern const struct kernel_param __start___param[], __stop___param[]; | ||
| 82 | |||
| 71 | /* Special one for strings we want to copy into */ | 83 | /* Special one for strings we want to copy into */ |
| 72 | struct kparam_string { | 84 | struct kparam_string { |
| 73 | unsigned int maxlen; | 85 | unsigned int maxlen; |
| @@ -113,6 +125,12 @@ struct kparam_array | |||
| 113 | module_param_named(name, name, type, perm) | 125 | module_param_named(name, name, type, perm) |
| 114 | 126 | ||
| 115 | /** | 127 | /** |
| 128 | * module_param_unsafe - same as module_param but taints kernel | ||
| 129 | */ | ||
| 130 | #define module_param_unsafe(name, type, perm) \ | ||
| 131 | module_param_named_unsafe(name, name, type, perm) | ||
| 132 | |||
| 133 | /** | ||
| 116 | * module_param_named - typesafe helper for a renamed module/cmdline parameter | 134 | * module_param_named - typesafe helper for a renamed module/cmdline parameter |
| 117 | * @name: a valid C identifier which is the parameter name. | 135 | * @name: a valid C identifier which is the parameter name. |
| 118 | * @value: the actual lvalue to alter. | 136 | * @value: the actual lvalue to alter. |
| @@ -129,6 +147,14 @@ struct kparam_array | |||
| 129 | __MODULE_PARM_TYPE(name, #type) | 147 | __MODULE_PARM_TYPE(name, #type) |
| 130 | 148 | ||
| 131 | /** | 149 | /** |
| 150 | * module_param_named_unsafe - same as module_param_named but taints kernel | ||
| 151 | */ | ||
| 152 | #define module_param_named_unsafe(name, value, type, perm) \ | ||
| 153 | param_check_##type(name, &(value)); \ | ||
| 154 | module_param_cb_unsafe(name, ¶m_ops_##type, &value, perm); \ | ||
| 155 | __MODULE_PARM_TYPE(name, #type) | ||
| 156 | |||
| 157 | /** | ||
| 132 | * module_param_cb - general callback for a module/cmdline parameter | 158 | * module_param_cb - general callback for a module/cmdline parameter |
| 133 | * @name: a valid C identifier which is the parameter name. | 159 | * @name: a valid C identifier which is the parameter name. |
| 134 | * @ops: the set & get operations for this parameter. | 160 | * @ops: the set & get operations for this parameter. |
| @@ -137,7 +163,11 @@ struct kparam_array | |||
| 137 | * The ops can have NULL set or get functions. | 163 | * The ops can have NULL set or get functions. |
| 138 | */ | 164 | */ |
| 139 | #define module_param_cb(name, ops, arg, perm) \ | 165 | #define module_param_cb(name, ops, arg, perm) \ |
| 140 | __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1) | 166 | __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0) |
| 167 | |||
| 168 | #define module_param_cb_unsafe(name, ops, arg, perm) \ | ||
| 169 | __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, \ | ||
| 170 | KERNEL_PARAM_FL_UNSAFE) | ||
| 141 | 171 | ||
| 142 | /** | 172 | /** |
| 143 | * <level>_param_cb - general callback for a module/cmdline parameter | 173 | * <level>_param_cb - general callback for a module/cmdline parameter |
| @@ -149,7 +179,7 @@ struct kparam_array | |||
| 149 | * The ops can have NULL set or get functions. | 179 | * The ops can have NULL set or get functions. |
| 150 | */ | 180 | */ |
| 151 | #define __level_param_cb(name, ops, arg, perm, level) \ | 181 | #define __level_param_cb(name, ops, arg, perm, level) \ |
| 152 | __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, level) | 182 | __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, level, 0) |
| 153 | 183 | ||
| 154 | #define core_param_cb(name, ops, arg, perm) \ | 184 | #define core_param_cb(name, ops, arg, perm) \ |
| 155 | __level_param_cb(name, ops, arg, perm, 1) | 185 | __level_param_cb(name, ops, arg, perm, 1) |
| @@ -184,22 +214,22 @@ struct kparam_array | |||
| 184 | 214 | ||
| 185 | /* This is the fundamental function for registering boot/module | 215 | /* This is the fundamental function for registering boot/module |
| 186 | parameters. */ | 216 | parameters. */ |
| 187 | #define __module_param_call(prefix, name, ops, arg, perm, level) \ | 217 | #define __module_param_call(prefix, name, ops, arg, perm, level, flags) \ |
| 188 | /* Default value instead of permissions? */ \ | 218 | /* Default value instead of permissions? */ \ |
| 189 | static const char __param_str_##name[] = prefix #name; \ | 219 | static const char __param_str_##name[] = prefix #name; \ |
| 190 | static struct kernel_param __moduleparam_const __param_##name \ | 220 | static struct kernel_param __moduleparam_const __param_##name \ |
| 191 | __used \ | 221 | __used \ |
| 192 | __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ | 222 | __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ |
| 193 | = { __param_str_##name, ops, VERIFY_OCTAL_PERMISSIONS(perm), \ | 223 | = { __param_str_##name, ops, VERIFY_OCTAL_PERMISSIONS(perm), \ |
| 194 | level, { arg } } | 224 | level, flags, { arg } } |
| 195 | 225 | ||
| 196 | /* Obsolete - use module_param_cb() */ | 226 | /* Obsolete - use module_param_cb() */ |
| 197 | #define module_param_call(name, set, get, arg, perm) \ | 227 | #define module_param_call(name, set, get, arg, perm) \ |
| 198 | static struct kernel_param_ops __param_ops_##name = \ | 228 | static struct kernel_param_ops __param_ops_##name = \ |
| 199 | { 0, (void *)set, (void *)get }; \ | 229 | { .flags = 0, (void *)set, (void *)get }; \ |
| 200 | __module_param_call(MODULE_PARAM_PREFIX, \ | 230 | __module_param_call(MODULE_PARAM_PREFIX, \ |
| 201 | name, &__param_ops_##name, arg, \ | 231 | name, &__param_ops_##name, arg, \ |
| 202 | (perm) + sizeof(__check_old_set_param(set))*0, -1) | 232 | (perm) + sizeof(__check_old_set_param(set))*0, -1, 0) |
| 203 | 233 | ||
| 204 | /* We don't get oldget: it's often a new-style param_get_uint, etc. */ | 234 | /* We don't get oldget: it's often a new-style param_get_uint, etc. */ |
| 205 | static inline int | 235 | static inline int |
| @@ -279,7 +309,7 @@ static inline void __kernel_param_unlock(void) | |||
| 279 | */ | 309 | */ |
| 280 | #define core_param(name, var, type, perm) \ | 310 | #define core_param(name, var, type, perm) \ |
| 281 | param_check_##type(name, &(var)); \ | 311 | param_check_##type(name, &(var)); \ |
| 282 | __module_param_call("", name, ¶m_ops_##type, &var, perm, -1) | 312 | __module_param_call("", name, ¶m_ops_##type, &var, perm, -1, 0) |
| 283 | #endif /* !MODULE */ | 313 | #endif /* !MODULE */ |
| 284 | 314 | ||
| 285 | /** | 315 | /** |
| @@ -297,7 +327,7 @@ static inline void __kernel_param_unlock(void) | |||
| 297 | = { len, string }; \ | 327 | = { len, string }; \ |
| 298 | __module_param_call(MODULE_PARAM_PREFIX, name, \ | 328 | __module_param_call(MODULE_PARAM_PREFIX, name, \ |
| 299 | ¶m_ops_string, \ | 329 | ¶m_ops_string, \ |
| 300 | .str = &__param_string_##name, perm, -1); \ | 330 | .str = &__param_string_##name, perm, -1, 0);\ |
| 301 | __MODULE_PARM_TYPE(name, "string") | 331 | __MODULE_PARM_TYPE(name, "string") |
| 302 | 332 | ||
| 303 | /** | 333 | /** |
| @@ -444,7 +474,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp); | |||
| 444 | __module_param_call(MODULE_PARAM_PREFIX, name, \ | 474 | __module_param_call(MODULE_PARAM_PREFIX, name, \ |
| 445 | ¶m_array_ops, \ | 475 | ¶m_array_ops, \ |
| 446 | .arr = &__param_arr_##name, \ | 476 | .arr = &__param_arr_##name, \ |
| 447 | perm, -1); \ | 477 | perm, -1, 0); \ |
| 448 | __MODULE_PARM_TYPE(name, "array of " #type) | 478 | __MODULE_PARM_TYPE(name, "array of " #type) |
| 449 | 479 | ||
| 450 | extern struct kernel_param_ops param_array_ops; | 480 | extern struct kernel_param_ops param_array_ops; |
