Skip to content

Commit 0c18f29

Browse files
mimizohartorvalds
authored andcommitted
module: limit enabling module.sig_enforce
Irrespective as to whether CONFIG_MODULE_SIG is configured, specifying "module.sig_enforce=1" on the boot command line sets "sig_enforce". Only allow "sig_enforce" to be set when CONFIG_MODULE_SIG is configured. This patch makes the presence of /sys/module/module/parameters/sig_enforce dependent on CONFIG_MODULE_SIG=y. Fixes: fda784e ("module: export module signature enforcement status") Reported-by: Nayna Jain <[email protected]> Tested-by: Mimi Zohar <[email protected]> Tested-by: Jessica Yu <[email protected]> Signed-off-by: Mimi Zohar <[email protected]> Signed-off-by: Jessica Yu <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent a96bfed commit 0c18f29

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

kernel/module.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,18 @@ static void module_assert_mutex_or_preempt(void)
266266
#endif
267267
}
268268

269+
#ifdef CONFIG_MODULE_SIG
269270
static bool sig_enforce = IS_ENABLED(CONFIG_MODULE_SIG_FORCE);
270271
module_param(sig_enforce, bool_enable_only, 0644);
271272

273+
void set_module_sig_enforced(void)
274+
{
275+
sig_enforce = true;
276+
}
277+
#else
278+
#define sig_enforce false
279+
#endif
280+
272281
/*
273282
* Export sig_enforce kernel cmdline parameter to allow other subsystems rely
274283
* on that instead of directly to CONFIG_MODULE_SIG_FORCE config.
@@ -279,11 +288,6 @@ bool is_module_sig_enforced(void)
279288
}
280289
EXPORT_SYMBOL(is_module_sig_enforced);
281290

282-
void set_module_sig_enforced(void)
283-
{
284-
sig_enforce = true;
285-
}
286-
287291
/* Block module loading/unloading? */
288292
int modules_disabled = 0;
289293
core_param(nomodule, modules_disabled, bint, 0);

0 commit comments

Comments
 (0)