Skip to content

Commit 05f408d

Browse files
mcgrofrustyrussell
authored andcommitted
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: Luis R. Rodriguez <mcgrof@suse.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 9c27847 commit 05f408d

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

‎kernel/module.c‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,23 +301,25 @@ static bool sig_enforce = false;
301301
static int param_set_bool_enable_only(const char *val,
302302
const struct kernel_param *kp)
303303
{
304-
int err;
305-
bool test;
304+
int err = 0;
305+
bool new_value;
306+
bool orig_value = *(bool *)kp->arg;
306307
struct kernel_param dummy_kp = *kp;
307308

308-
dummy_kp.arg = &test;
309+
dummy_kp.arg = &new_value;
309310

310311
err = param_set_bool(val, &dummy_kp);
311312
if (err)
312313
return err;
313314

314315
/* Don't let them unset it once it's set! */
315-
if (!test && sig_enforce)
316+
if (!new_value && orig_value)
316317
return -EROFS;
317318

318-
if (test)
319-
sig_enforce = true;
320-
return 0;
319+
if (new_value)
320+
err = param_set_bool(val, kp);
321+
322+
return err;
321323
}
322324

323325
static const struct kernel_param_ops param_ops_bool_enable_only = {

0 commit comments

Comments
 (0)