@@ -2097,10 +2097,5 @@ extern void __init yama_add_hooks(void);
#else
static inline void __init yama_add_hooks(void) { }
#endif
-#ifdef CONFIG_SECURITY_LOADPIN
-void __init loadpin_add_hooks(void);
-#else
-static inline void loadpin_add_hooks(void) { };
-#endif
#endif /* ! __LINUX_LSM_HOOKS_H */
@@ -293,7 +293,7 @@ config LSM_ENABLE
config LSM_ORDER
string "Default initialization order of builtin LSMs"
- default "integrity"
+ default "loadpin,integrity"
help
A comma-separated list of LSMs, in initialization order.
Any LSMs left off this list will be link-order initialized
@@ -184,13 +184,18 @@ static struct security_hook_list loadpin_hooks[] __lsm_ro_after_init = {
LSM_HOOK_INIT(kernel_load_data, loadpin_load_data),
};
-void __init loadpin_add_hooks(void)
+static int __init loadpin_init(void)
{
pr_info("ready to pin (currently %senforcing)\n",
enforcing ? "" : "not ");
security_add_hooks(loadpin_hooks, ARRAY_SIZE(loadpin_hooks), "loadpin");
+ return 0;
}
+DEFINE_LSM(loadpin)
+ .init = loadpin_init,
+END_LSM;
+
/* Should not be mutable after boot, so not listed in sysfs (perm == 0). */
module_param(enforcing, int, 0);
MODULE_PARM_DESC(enforcing, "Enforce module/firmware pinning");
@@ -305,7 +305,6 @@ int __init security_init(void)
*/
capability_add_hooks();
yama_add_hooks();
- loadpin_add_hooks();
/* Load LSMs in specified order. */
prepare_lsm_order();
This converts LoadPin from being a direct "minor" LSM into an ordered LSM. Signed-off-by: Kees Cook <keescook@chromium.org> --- include/linux/lsm_hooks.h | 5 ----- security/Kconfig | 2 +- security/loadpin/loadpin.c | 7 ++++++- security/security.c | 1 - 4 files changed, 7 insertions(+), 8 deletions(-)