From 3baee201b06cfaff84c2c5ddc551b192bb3eaed3 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Wed, 27 Aug 2014 06:23:23 +0930 Subject: [PATCH] module: add module_param_unsafe and module_param_named_unsafe 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 Cc: Jean Delvare Cc: Andrew Morton Cc: Li Zhong Cc: Jon Mason Cc: Daniel Vetter Signed-off-by: Jani Nikula Signed-off-by: Rusty Russell --- include/linux/moduleparam.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 1e3ffb839daa..9531f9f9729e 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -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. @@ -138,6 +144,14 @@ struct kparam_array module_param_cb(name, ¶m_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, ¶m_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. @@ -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) + /** * _param_cb - general callback for a module/cmdline parameter * to be evaluated before certain initcall level -- 2.39.5