aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/moduleparam.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-07-01 13:49:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-07-01 13:49:25 -0400
commit02201e3f1b46aed7c6348f406b7b40de80ba6de3 (patch)
tree2392c9098359725c195dd82a72b20ccedc1a1509 /include/linux/moduleparam.h
parent0890a264794f33df540fbaf274699146903b4e6b (diff)
parent20bdc2cfdbc484777b30b96fcdbb8994038f3ce1 (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.h99
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
68struct kernel_param { 68struct 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
286extern void __kernel_param_lock(void); 243extern void kernel_param_lock(struct module *mod);
287extern void __kernel_param_unlock(void); 244extern void kernel_param_unlock(struct module *mod);
288#else 245#else
289static inline void __kernel_param_lock(void) 246static inline void kernel_param_lock(struct module *mod)
290{ 247{
291} 248}
292static inline void __kernel_param_unlock(void) 249static 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
389extern struct kernel_param_ops param_ops_byte; 346extern const struct kernel_param_ops param_ops_byte;
390extern int param_set_byte(const char *val, const struct kernel_param *kp); 347extern int param_set_byte(const char *val, const struct kernel_param *kp);
391extern int param_get_byte(char *buffer, const struct kernel_param *kp); 348extern 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
394extern struct kernel_param_ops param_ops_short; 351extern const struct kernel_param_ops param_ops_short;
395extern int param_set_short(const char *val, const struct kernel_param *kp); 352extern int param_set_short(const char *val, const struct kernel_param *kp);
396extern int param_get_short(char *buffer, const struct kernel_param *kp); 353extern 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
399extern struct kernel_param_ops param_ops_ushort; 356extern const struct kernel_param_ops param_ops_ushort;
400extern int param_set_ushort(const char *val, const struct kernel_param *kp); 357extern int param_set_ushort(const char *val, const struct kernel_param *kp);
401extern int param_get_ushort(char *buffer, const struct kernel_param *kp); 358extern 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
404extern struct kernel_param_ops param_ops_int; 361extern const struct kernel_param_ops param_ops_int;
405extern int param_set_int(const char *val, const struct kernel_param *kp); 362extern int param_set_int(const char *val, const struct kernel_param *kp);
406extern int param_get_int(char *buffer, const struct kernel_param *kp); 363extern 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
409extern struct kernel_param_ops param_ops_uint; 366extern const struct kernel_param_ops param_ops_uint;
410extern int param_set_uint(const char *val, const struct kernel_param *kp); 367extern int param_set_uint(const char *val, const struct kernel_param *kp);
411extern int param_get_uint(char *buffer, const struct kernel_param *kp); 368extern 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
414extern struct kernel_param_ops param_ops_long; 371extern const struct kernel_param_ops param_ops_long;
415extern int param_set_long(const char *val, const struct kernel_param *kp); 372extern int param_set_long(const char *val, const struct kernel_param *kp);
416extern int param_get_long(char *buffer, const struct kernel_param *kp); 373extern 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
419extern struct kernel_param_ops param_ops_ulong; 376extern const struct kernel_param_ops param_ops_ulong;
420extern int param_set_ulong(const char *val, const struct kernel_param *kp); 377extern int param_set_ulong(const char *val, const struct kernel_param *kp);
421extern int param_get_ulong(char *buffer, const struct kernel_param *kp); 378extern 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
424extern struct kernel_param_ops param_ops_ullong; 381extern const struct kernel_param_ops param_ops_ullong;
425extern int param_set_ullong(const char *val, const struct kernel_param *kp); 382extern int param_set_ullong(const char *val, const struct kernel_param *kp);
426extern int param_get_ullong(char *buffer, const struct kernel_param *kp); 383extern 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
429extern struct kernel_param_ops param_ops_charp; 386extern const struct kernel_param_ops param_ops_charp;
430extern int param_set_charp(const char *val, const struct kernel_param *kp); 387extern int param_set_charp(const char *val, const struct kernel_param *kp);
431extern int param_get_charp(char *buffer, const struct kernel_param *kp); 388extern 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! */
435extern struct kernel_param_ops param_ops_bool; 392extern const struct kernel_param_ops param_ops_bool;
436extern int param_set_bool(const char *val, const struct kernel_param *kp); 393extern int param_set_bool(const char *val, const struct kernel_param *kp);
437extern int param_get_bool(char *buffer, const struct kernel_param *kp); 394extern 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
440extern struct kernel_param_ops param_ops_invbool; 397extern const struct kernel_param_ops param_ops_bool_enable_only;
398extern 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
403extern const struct kernel_param_ops param_ops_invbool;
441extern int param_set_invbool(const char *val, const struct kernel_param *kp); 404extern int param_set_invbool(const char *val, const struct kernel_param *kp);
442extern int param_get_invbool(char *buffer, const struct kernel_param *kp); 405extern 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). */
446extern struct kernel_param_ops param_ops_bint; 409extern const struct kernel_param_ops param_ops_bint;
447extern int param_set_bint(const char *val, const struct kernel_param *kp); 410extern 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
490extern struct kernel_param_ops param_array_ops; 453extern const struct kernel_param_ops param_array_ops;
491 454
492extern struct kernel_param_ops param_ops_string; 455extern const struct kernel_param_ops param_ops_string;
493extern int param_set_copystring(const char *val, const struct kernel_param *); 456extern int param_set_copystring(const char *val, const struct kernel_param *);
494extern int param_get_string(char *buffer, const struct kernel_param *kp); 457extern int param_get_string(char *buffer, const struct kernel_param *kp);
495 458