Skip to content

Commit

Permalink
module: add module_param_unsafe and module_param_named_unsafe
Browse files Browse the repository at this point in the history
Add the helpers to be used by modules wishing to expose unsafe debugging
or testing module parameters that taint the kernel when set.

Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Li Zhong <zhong@linux.vnet.ibm.com>
Cc: Jon Mason <jon.mason@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
Jani Nikula authored and Rusty Russell committed Aug 27, 2014
1 parent 91f9d33 commit 3baee20
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions include/linux/moduleparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ struct kparam_array
#define module_param(name, type, perm) \
module_param_named(name, name, type, perm)

/**
* module_param_unsafe - same as module_param but taints kernel
*/
#define module_param_unsafe(name, type, perm) \
module_param_named_unsafe(name, name, type, perm)

/**
* module_param_named - typesafe helper for a renamed module/cmdline parameter
* @name: a valid C identifier which is the parameter name.
Expand All @@ -138,6 +144,14 @@ struct kparam_array
module_param_cb(name, &param_ops_##type, &value, perm); \
__MODULE_PARM_TYPE(name, #type)

/**
* module_param_named_unsafe - same as module_param_named but taints kernel
*/
#define module_param_named_unsafe(name, value, type, perm) \
param_check_##type(name, &(value)); \
module_param_cb_unsafe(name, &param_ops_##type, &value, perm); \
__MODULE_PARM_TYPE(name, #type)

/**
* module_param_cb - general callback for a module/cmdline parameter
* @name: a valid C identifier which is the parameter name.
Expand All @@ -149,6 +163,10 @@ struct kparam_array
#define module_param_cb(name, ops, arg, perm) \
__module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0)

#define module_param_cb_unsafe(name, ops, arg, perm) \
__module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, \
KERNEL_PARAM_FL_UNSAFE)

/**
* <level>_param_cb - general callback for a module/cmdline parameter
* to be evaluated before certain initcall level
Expand Down

0 comments on commit 3baee20

Please sign in to comment.