History

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.

Luis R. Rodriguez committed 11 years ago

Commit 05f408d1 parent 9c278471 file · +9 −7Browse files

Unified · Split

kernel/module.c+9−7
@@ -301,23 +301,25 @@ static bool sig_enforce = false; · 300 unmodified lines
301static int param_set_bool_enable_only(const char *val,301static int param_set_bool_enable_only(const char *val,
302 const struct kernel_param *kp)302 const struct kernel_param *kp)
303{303{
304 int err;304 int err = 0;
305 bool test;305 bool new_value;
306 bool orig_value = *(bool *)kp->arg;
306 struct kernel_param dummy_kp = *kp;307 struct kernel_param dummy_kp = *kp;
307 308
308 dummy_kp.arg = &test;309 dummy_kp.arg = &new_value;
309 310
310 err = param_set_bool(val, &dummy_kp);311 err = param_set_bool(val, &dummy_kp);
311 if (err)312 if (err)
312 return err;313 return err;
313 314
314 /* Don't let them unset it once it's set! */315 /* Don't let them unset it once it's set! */
315 if (!test && sig_enforce)316 if (!new_value && orig_value)
316 return -EROFS;317 return -EROFS;
317 318
318 if (test)319 if (new_value)
319 sig_enforce = true;320 err = param_set_bool(val, kp);
320 return 0;321
322 return err;
321}323}
322 324
323static const struct kernel_param_ops param_ops_bool_enable_only = {325static const struct kernel_param_ops param_ops_bool_enable_only = {