提交 05f408dd 编写于 作者: L Luis R. Rodriguez 提交者: Rusty Russell

kernel/module.c: use generic module param operaters for sig_enforce

We're directly checking and modifying sig_enforce when needed instead
of using the generic helpers. This prevents us from generalizing this
helper so that others can use it. Use indirect helpers to allow us
to generalize this code a bit and to make it a bit more clear what
this is doing.

Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org
Cc: cocci@systeme.lip6.fr
Signed-off-by: NLuis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
上级 9c27847d
...@@ -301,23 +301,25 @@ static bool sig_enforce = false; ...@@ -301,23 +301,25 @@ static bool sig_enforce = false;
static int param_set_bool_enable_only(const char *val, static int param_set_bool_enable_only(const char *val,
const struct kernel_param *kp) const struct kernel_param *kp)
{ {
int err; int err = 0;
bool test; bool new_value;
bool orig_value = *(bool *)kp->arg;
struct kernel_param dummy_kp = *kp; struct kernel_param dummy_kp = *kp;
dummy_kp.arg = &test; dummy_kp.arg = &new_value;
err = param_set_bool(val, &dummy_kp); err = param_set_bool(val, &dummy_kp);
if (err) if (err)
return err; return err;
/* Don't let them unset it once it's set! */ /* Don't let them unset it once it's set! */
if (!test && sig_enforce) if (!new_value && orig_value)
return -EROFS; return -EROFS;
if (test) if (new_value)
sig_enforce = true; err = param_set_bool(val, kp);
return 0;
return err;
} }
static const struct kernel_param_ops param_ops_bool_enable_only = { static const struct kernel_param_ops param_ops_bool_enable_only = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册