You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
module: make it possible to have unsafe, tainting module params
Add flags field to struct kernel_params, and add the first flag: unsafe parameter. Modifying a kernel parameter with the unsafe flag set, either via the kernel command line or sysfs, will issue a warning and taint the kernel. 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>
This commit is contained in:
committed by
Rusty Russell
parent
6a4c264313
commit
91f9d330cc
@@ -233,6 +233,7 @@ char *parse_args(const char *doing,
|
||||
#define STANDARD_PARAM_DEF(name, type, format, strtolfn) \
|
||||
int param_set_##name(const char *val, const struct kernel_param *kp) \
|
||||
{ \
|
||||
param_check_unsafe(kp); \
|
||||
return strtolfn(val, 0, (type *)kp->arg); \
|
||||
} \
|
||||
int param_get_##name(char *buffer, const struct kernel_param *kp) \
|
||||
@@ -265,6 +266,8 @@ int param_set_charp(const char *val, const struct kernel_param *kp)
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
param_check_unsafe(kp);
|
||||
|
||||
maybe_kfree_parameter(*(char **)kp->arg);
|
||||
|
||||
/* This is a hack. We can't kmalloc in early boot, and we
|
||||
@@ -302,6 +305,8 @@ EXPORT_SYMBOL(param_ops_charp);
|
||||
/* Actually could be a bool or an int, for historical reasons. */
|
||||
int param_set_bool(const char *val, const struct kernel_param *kp)
|
||||
{
|
||||
param_check_unsafe(kp);
|
||||
|
||||
/* No equals means "set"... */
|
||||
if (!val) val = "1";
|
||||
|
||||
@@ -331,6 +336,8 @@ int param_set_invbool(const char *val, const struct kernel_param *kp)
|
||||
bool boolval;
|
||||
struct kernel_param dummy;
|
||||
|
||||
param_check_unsafe(kp);
|
||||
|
||||
dummy.arg = &boolval;
|
||||
ret = param_set_bool(val, &dummy);
|
||||
if (ret == 0)
|
||||
@@ -357,6 +364,8 @@ int param_set_bint(const char *val, const struct kernel_param *kp)
|
||||
bool v;
|
||||
int ret;
|
||||
|
||||
param_check_unsafe(kp);
|
||||
|
||||
/* Match bool exactly, by re-using it. */
|
||||
boolkp = *kp;
|
||||
boolkp.arg = &v;
|
||||
@@ -476,6 +485,8 @@ int param_set_copystring(const char *val, const struct kernel_param *kp)
|
||||
{
|
||||
const struct kparam_string *kps = kp->str;
|
||||
|
||||
param_check_unsafe(kp);
|
||||
|
||||
if (strlen(val)+1 > kps->maxlen) {
|
||||
pr_err("%s: string doesn't fit in %u chars.\n",
|
||||
kp->name, kps->maxlen-1);
|
||||
|
||||
Reference in New Issue
Block a user