This takes out the bool_enable_only implementation from the module loading code and generalizes it so that others can make use of it.
Showing the changes to kernel/module.c (1 of 3 files). Show all
Unified · Split
| @@ -298,37 +298,6 @@ static bool sig_enforce = true; · 297 unmodified lines | ||
| 298 | 298 | #else |
| 299 | 299 | static bool sig_enforce = false; |
| 300 | 300 | |
| 301 | −static int param_set_bool_enable_only(const char *val, | |
| 302 | − const struct kernel_param *kp) | |
| 303 | −{ | |
| 304 | − int err = 0; | |
| 305 | − bool new_value; | |
| 306 | − bool orig_value = *(bool *)kp->arg; | |
| 307 | − struct kernel_param dummy_kp = *kp; | |
| 308 | − | |
| 309 | − dummy_kp.arg = &new_value; | |
| 310 | − | |
| 311 | − err = param_set_bool(val, &dummy_kp); | |
| 312 | − if (err) | |
| 313 | − return err; | |
| 314 | − | |
| 315 | − /* Don't let them unset it once it's set! */ | |
| 316 | − if (!new_value && orig_value) | |
| 317 | − return -EROFS; | |
| 318 | − | |
| 319 | − if (new_value) | |
| 320 | − err = param_set_bool(val, kp); | |
| 321 | − | |
| 322 | − return err; | |
| 323 | −} | |
| 324 | − | |
| 325 | −static const struct kernel_param_ops param_ops_bool_enable_only = { | |
| 326 | − .flags = KERNEL_PARAM_OPS_FL_NOARG, | |
| 327 | − .set = param_set_bool_enable_only, | |
| 328 | − .get = param_get_bool, | |
| 329 | −}; | |
| 330 | −#define param_check_bool_enable_only param_check_bool | |
| 331 | − | |
| 332 | 301 | module_param(sig_enforce, bool_enable_only, 0644); |
| 333 | 302 | #endif /* !CONFIG_MODULE_SIG_FORCE */ |
| 334 | 303 | #endif /* CONFIG_MODULE_SIG */ |