diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-07-01 13:49:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-07-01 13:49:25 -0400 |
commit | 02201e3f1b46aed7c6348f406b7b40de80ba6de3 (patch) | |
tree | 2392c9098359725c195dd82a72b20ccedc1a1509 /include/linux/moduleparam.h | |
parent | 0890a264794f33df540fbaf274699146903b4e6b (diff) | |
parent | 20bdc2cfdbc484777b30b96fcdbb8994038f3ce1 (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:
"Main excitement here is Peter Zijlstra's lockless rbtree optimization
to speed module address lookup. He found some abusers of the module
lock doing that too.
A little bit of parameter work here too; including Dan Streetman's
breaking up the big param mutex so writing a parameter can load
another module (yeah, really). Unfortunately that broke the usual
suspects, !CONFIG_MODULES and !CONFIG_SYSFS, so those fixes were
appended too"
* tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux: (26 commits)
modules: only use mod->param_lock if CONFIG_MODULES
param: fix module param locks when !CONFIG_SYSFS.
rcu: merge fix for Convert ACCESS_ONCE() to READ_ONCE() and WRITE_ONCE()
module: add per-module param_lock
module: make perm const
params: suppress unused variable error, warn once just in case code changes.
modules: clarify CONFIG_MODULE_COMPRESS help, suggest 'N'.
kernel/module.c: avoid ifdefs for sig_enforce declaration
kernel/workqueue.c: remove ifdefs over wq_power_efficient
kernel/params.c: export param_ops_bool_enable_only
kernel/params.c: generalize bool_enable_only
kernel/module.c: use generic module param operaters for sig_enforce
kernel/params: constify struct kernel_param_ops uses
sysfs: tightened sysfs permission checks
module: Rework module_addr_{min,max}
module: Use __module_address() for module_address_lookup()
module: Make the mod_tree stuff conditional on PERF_EVENTS || TRACING
module: Optimize __module_address() using a latched RB-tree
rbtree: Implement generic latch_tree
seqlock: Introduce raw_read_seqcount_latch()
...
Diffstat (limited to 'include/linux/moduleparam.h')
-rw-r--r-- | include/linux/moduleparam.h | 99 |
1 files changed, 31 insertions, 68 deletions
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 6480dcaca275..c12f2147c350 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h | |||
@@ -67,8 +67,9 @@ enum { | |||
67 | 67 | ||
68 | struct kernel_param { | 68 | struct kernel_param { |
69 | const char *name; | 69 | const char *name; |
70 | struct module *mod; | ||
70 | const struct kernel_param_ops *ops; | 71 | const struct kernel_param_ops *ops; |
71 | u16 perm; | 72 | const u16 perm; |
72 | s8 level; | 73 | s8 level; |
73 | u8 flags; | 74 | u8 flags; |
74 | union { | 75 | union { |
@@ -108,7 +109,7 @@ struct kparam_array | |||
108 | * | 109 | * |
109 | * @perm is 0 if the the variable is not to appear in sysfs, or 0444 | 110 | * @perm is 0 if the the variable is not to appear in sysfs, or 0444 |
110 | * for world-readable, 0644 for root-writable, etc. Note that if it | 111 | * for world-readable, 0644 for root-writable, etc. Note that if it |
111 | * is writable, you may need to use kparam_block_sysfs_write() around | 112 | * is writable, you may need to use kernel_param_lock() around |
112 | * accesses (esp. charp, which can be kfreed when it changes). | 113 | * accesses (esp. charp, which can be kfreed when it changes). |
113 | * | 114 | * |
114 | * The @type is simply pasted to refer to a param_ops_##type and a | 115 | * The @type is simply pasted to refer to a param_ops_##type and a |
@@ -216,16 +217,16 @@ struct kparam_array | |||
216 | parameters. */ | 217 | parameters. */ |
217 | #define __module_param_call(prefix, name, ops, arg, perm, level, flags) \ | 218 | #define __module_param_call(prefix, name, ops, arg, perm, level, flags) \ |
218 | /* Default value instead of permissions? */ \ | 219 | /* Default value instead of permissions? */ \ |
219 | static const char __param_str_##name[] = prefix #name; \ | 220 | static const char __param_str_##name[] = prefix #name; \ |
220 | static struct kernel_param __moduleparam_const __param_##name \ | 221 | static struct kernel_param __moduleparam_const __param_##name \ |
221 | __used \ | 222 | __used \ |
222 | __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ | 223 | __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ |
223 | = { __param_str_##name, ops, VERIFY_OCTAL_PERMISSIONS(perm), \ | 224 | = { __param_str_##name, THIS_MODULE, ops, \ |
224 | level, flags, { arg } } | 225 | VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } } |
225 | 226 | ||
226 | /* Obsolete - use module_param_cb() */ | 227 | /* Obsolete - use module_param_cb() */ |
227 | #define module_param_call(name, set, get, arg, perm) \ | 228 | #define module_param_call(name, set, get, arg, perm) \ |
228 | static struct kernel_param_ops __param_ops_##name = \ | 229 | static const struct kernel_param_ops __param_ops_##name = \ |
229 | { .flags = 0, (void *)set, (void *)get }; \ | 230 | { .flags = 0, (void *)set, (void *)get }; \ |
230 | __module_param_call(MODULE_PARAM_PREFIX, \ | 231 | __module_param_call(MODULE_PARAM_PREFIX, \ |
231 | name, &__param_ops_##name, arg, \ | 232 | name, &__param_ops_##name, arg, \ |
@@ -238,58 +239,14 @@ __check_old_set_param(int (*oldset)(const char *, struct kernel_param *)) | |||
238 | return 0; | 239 | return 0; |
239 | } | 240 | } |
240 | 241 | ||
241 | /** | ||
242 | * kparam_block_sysfs_write - make sure a parameter isn't written via sysfs. | ||
243 | * @name: the name of the parameter | ||
244 | * | ||
245 | * There's no point blocking write on a paramter that isn't writable via sysfs! | ||
246 | */ | ||
247 | #define kparam_block_sysfs_write(name) \ | ||
248 | do { \ | ||
249 | BUG_ON(!(__param_##name.perm & 0222)); \ | ||
250 | __kernel_param_lock(); \ | ||
251 | } while (0) | ||
252 | |||
253 | /** | ||
254 | * kparam_unblock_sysfs_write - allows sysfs to write to a parameter again. | ||
255 | * @name: the name of the parameter | ||
256 | */ | ||
257 | #define kparam_unblock_sysfs_write(name) \ | ||
258 | do { \ | ||
259 | BUG_ON(!(__param_##name.perm & 0222)); \ | ||
260 | __kernel_param_unlock(); \ | ||
261 | } while (0) | ||
262 | |||
263 | /** | ||
264 | * kparam_block_sysfs_read - make sure a parameter isn't read via sysfs. | ||
265 | * @name: the name of the parameter | ||
266 | * | ||
267 | * This also blocks sysfs writes. | ||
268 | */ | ||
269 | #define kparam_block_sysfs_read(name) \ | ||
270 | do { \ | ||
271 | BUG_ON(!(__param_##name.perm & 0444)); \ | ||
272 | __kernel_param_lock(); \ | ||
273 | } while (0) | ||
274 | |||
275 | /** | ||
276 | * kparam_unblock_sysfs_read - allows sysfs to read a parameter again. | ||
277 | * @name: the name of the parameter | ||
278 | */ | ||
279 | #define kparam_unblock_sysfs_read(name) \ | ||
280 | do { \ | ||
281 | BUG_ON(!(__param_##name.perm & 0444)); \ | ||
282 | __kernel_param_unlock(); \ | ||
283 | } while (0) | ||
284 | |||
285 | #ifdef CONFIG_SYSFS | 242 | #ifdef CONFIG_SYSFS |
286 | extern void __kernel_param_lock(void); | 243 | extern void kernel_param_lock(struct module *mod); |
287 | extern void __kernel_param_unlock(void); | 244 | extern void kernel_param_unlock(struct module *mod); |
288 | #else | 245 | #else |
289 | static inline void __kernel_param_lock(void) | 246 | static inline void kernel_param_lock(struct module *mod) |
290 | { | 247 | { |
291 | } | 248 | } |
292 | static inline void __kernel_param_unlock(void) | 249 | static inline void kernel_param_unlock(struct module *mod) |
293 | { | 250 | { |
294 | } | 251 | } |
295 | #endif | 252 | #endif |
@@ -386,64 +343,70 @@ static inline void destroy_params(const struct kernel_param *params, | |||
386 | #define __param_check(name, p, type) \ | 343 | #define __param_check(name, p, type) \ |
387 | static inline type __always_unused *__check_##name(void) { return(p); } | 344 | static inline type __always_unused *__check_##name(void) { return(p); } |
388 | 345 | ||
389 | extern struct kernel_param_ops param_ops_byte; | 346 | extern const struct kernel_param_ops param_ops_byte; |
390 | extern int param_set_byte(const char *val, const struct kernel_param *kp); | 347 | extern int param_set_byte(const char *val, const struct kernel_param *kp); |
391 | extern int param_get_byte(char *buffer, const struct kernel_param *kp); | 348 | extern int param_get_byte(char *buffer, const struct kernel_param *kp); |
392 | #define param_check_byte(name, p) __param_check(name, p, unsigned char) | 349 | #define param_check_byte(name, p) __param_check(name, p, unsigned char) |
393 | 350 | ||
394 | extern struct kernel_param_ops param_ops_short; | 351 | extern const struct kernel_param_ops param_ops_short; |
395 | extern int param_set_short(const char *val, const struct kernel_param *kp); | 352 | extern int param_set_short(const char *val, const struct kernel_param *kp); |
396 | extern int param_get_short(char *buffer, const struct kernel_param *kp); | 353 | extern int param_get_short(char *buffer, const struct kernel_param *kp); |
397 | #define param_check_short(name, p) __param_check(name, p, short) | 354 | #define param_check_short(name, p) __param_check(name, p, short) |
398 | 355 | ||
399 | extern struct kernel_param_ops param_ops_ushort; | 356 | extern const struct kernel_param_ops param_ops_ushort; |
400 | extern int param_set_ushort(const char *val, const struct kernel_param *kp); | 357 | extern int param_set_ushort(const char *val, const struct kernel_param *kp); |
401 | extern int param_get_ushort(char *buffer, const struct kernel_param *kp); | 358 | extern int param_get_ushort(char *buffer, const struct kernel_param *kp); |
402 | #define param_check_ushort(name, p) __param_check(name, p, unsigned short) | 359 | #define param_check_ushort(name, p) __param_check(name, p, unsigned short) |
403 | 360 | ||
404 | extern struct kernel_param_ops param_ops_int; | 361 | extern const struct kernel_param_ops param_ops_int; |
405 | extern int param_set_int(const char *val, const struct kernel_param *kp); | 362 | extern int param_set_int(const char *val, const struct kernel_param *kp); |
406 | extern int param_get_int(char *buffer, const struct kernel_param *kp); | 363 | extern int param_get_int(char *buffer, const struct kernel_param *kp); |
407 | #define param_check_int(name, p) __param_check(name, p, int) | 364 | #define param_check_int(name, p) __param_check(name, p, int) |
408 | 365 | ||
409 | extern struct kernel_param_ops param_ops_uint; | 366 | extern const struct kernel_param_ops param_ops_uint; |
410 | extern int param_set_uint(const char *val, const struct kernel_param *kp); | 367 | extern int param_set_uint(const char *val, const struct kernel_param *kp); |
411 | extern int param_get_uint(char *buffer, const struct kernel_param *kp); | 368 | extern int param_get_uint(char *buffer, const struct kernel_param *kp); |
412 | #define param_check_uint(name, p) __param_check(name, p, unsigned int) | 369 | #define param_check_uint(name, p) __param_check(name, p, unsigned int) |
413 | 370 | ||
414 | extern struct kernel_param_ops param_ops_long; | 371 | extern const struct kernel_param_ops param_ops_long; |
415 | extern int param_set_long(const char *val, const struct kernel_param *kp); | 372 | extern int param_set_long(const char *val, const struct kernel_param *kp); |
416 | extern int param_get_long(char *buffer, const struct kernel_param *kp); | 373 | extern int param_get_long(char *buffer, const struct kernel_param *kp); |
417 | #define param_check_long(name, p) __param_check(name, p, long) | 374 | #define param_check_long(name, p) __param_check(name, p, long) |
418 | 375 | ||
419 | extern struct kernel_param_ops param_ops_ulong; | 376 | extern const struct kernel_param_ops param_ops_ulong; |
420 | extern int param_set_ulong(const char *val, const struct kernel_param *kp); | 377 | extern int param_set_ulong(const char *val, const struct kernel_param *kp); |
421 | extern int param_get_ulong(char *buffer, const struct kernel_param *kp); | 378 | extern int param_get_ulong(char *buffer, const struct kernel_param *kp); |
422 | #define param_check_ulong(name, p) __param_check(name, p, unsigned long) | 379 | #define param_check_ulong(name, p) __param_check(name, p, unsigned long) |
423 | 380 | ||
424 | extern struct kernel_param_ops param_ops_ullong; | 381 | extern const struct kernel_param_ops param_ops_ullong; |
425 | extern int param_set_ullong(const char *val, const struct kernel_param *kp); | 382 | extern int param_set_ullong(const char *val, const struct kernel_param *kp); |
426 | extern int param_get_ullong(char *buffer, const struct kernel_param *kp); | 383 | extern int param_get_ullong(char *buffer, const struct kernel_param *kp); |
427 | #define param_check_ullong(name, p) __param_check(name, p, unsigned long long) | 384 | #define param_check_ullong(name, p) __param_check(name, p, unsigned long long) |
428 | 385 | ||
429 | extern struct kernel_param_ops param_ops_charp; | 386 | extern const struct kernel_param_ops param_ops_charp; |
430 | extern int param_set_charp(const char *val, const struct kernel_param *kp); | 387 | extern int param_set_charp(const char *val, const struct kernel_param *kp); |
431 | extern int param_get_charp(char *buffer, const struct kernel_param *kp); | 388 | extern int param_get_charp(char *buffer, const struct kernel_param *kp); |
432 | #define param_check_charp(name, p) __param_check(name, p, char *) | 389 | #define param_check_charp(name, p) __param_check(name, p, char *) |
433 | 390 | ||
434 | /* We used to allow int as well as bool. We're taking that away! */ | 391 | /* We used to allow int as well as bool. We're taking that away! */ |
435 | extern struct kernel_param_ops param_ops_bool; | 392 | extern const struct kernel_param_ops param_ops_bool; |
436 | extern int param_set_bool(const char *val, const struct kernel_param *kp); | 393 | extern int param_set_bool(const char *val, const struct kernel_param *kp); |
437 | extern int param_get_bool(char *buffer, const struct kernel_param *kp); | 394 | extern int param_get_bool(char *buffer, const struct kernel_param *kp); |
438 | #define param_check_bool(name, p) __param_check(name, p, bool) | 395 | #define param_check_bool(name, p) __param_check(name, p, bool) |
439 | 396 | ||
440 | extern struct kernel_param_ops param_ops_invbool; | 397 | extern const struct kernel_param_ops param_ops_bool_enable_only; |
398 | extern int param_set_bool_enable_only(const char *val, | ||
399 | const struct kernel_param *kp); | ||
400 | /* getter is the same as for the regular bool */ | ||
401 | #define param_check_bool_enable_only param_check_bool | ||
402 | |||
403 | extern const struct kernel_param_ops param_ops_invbool; | ||
441 | extern int param_set_invbool(const char *val, const struct kernel_param *kp); | 404 | extern int param_set_invbool(const char *val, const struct kernel_param *kp); |
442 | extern int param_get_invbool(char *buffer, const struct kernel_param *kp); | 405 | extern int param_get_invbool(char *buffer, const struct kernel_param *kp); |
443 | #define param_check_invbool(name, p) __param_check(name, p, bool) | 406 | #define param_check_invbool(name, p) __param_check(name, p, bool) |
444 | 407 | ||
445 | /* An int, which can only be set like a bool (though it shows as an int). */ | 408 | /* An int, which can only be set like a bool (though it shows as an int). */ |
446 | extern struct kernel_param_ops param_ops_bint; | 409 | extern const struct kernel_param_ops param_ops_bint; |
447 | extern int param_set_bint(const char *val, const struct kernel_param *kp); | 410 | extern int param_set_bint(const char *val, const struct kernel_param *kp); |
448 | #define param_get_bint param_get_int | 411 | #define param_get_bint param_get_int |
449 | #define param_check_bint param_check_int | 412 | #define param_check_bint param_check_int |
@@ -487,9 +450,9 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp); | |||
487 | perm, -1, 0); \ | 450 | perm, -1, 0); \ |
488 | __MODULE_PARM_TYPE(name, "array of " #type) | 451 | __MODULE_PARM_TYPE(name, "array of " #type) |
489 | 452 | ||
490 | extern struct kernel_param_ops param_array_ops; | 453 | extern const struct kernel_param_ops param_array_ops; |
491 | 454 | ||
492 | extern struct kernel_param_ops param_ops_string; | 455 | extern const struct kernel_param_ops param_ops_string; |
493 | extern int param_set_copystring(const char *val, const struct kernel_param *); | 456 | extern int param_set_copystring(const char *val, const struct kernel_param *); |
494 | extern int param_get_string(char *buffer, const struct kernel_param *kp); | 457 | extern int param_get_string(char *buffer, const struct kernel_param *kp); |
495 | 458 | ||