LoadPin: Initialize as ordered LSM
authorKees Cook <keescook@chromium.org>
Fri, 14 Sep 2018 22:26:37 +0000 (15:26 -0700)
committerKees Cook <keescook@chromium.org>
Tue, 8 Jan 2019 21:18:43 +0000 (13:18 -0800)
This converts LoadPin from being a direct "minor" LSM into an ordered LSM.

Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
include/linux/lsm_hooks.h
security/Kconfig
security/loadpin/loadpin.c
security/security.c

index c3843b33da9eaf149ca93296780ebaad25cb016c..fb1a653ccfcba29b15e3ab111aa3b4a293678f20 100644 (file)
@@ -2095,10 +2095,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 */
index cedf69e8a22c8583a1556467422fefdc9cdb20d1..2cd737ba7660a3a7d10d8307fb75bdbb7bb50534 100644 (file)
@@ -239,46 +239,9 @@ source "security/yama/Kconfig"
 
 source "security/integrity/Kconfig"
 
-choice
-       prompt "Default security module"
-       default DEFAULT_SECURITY_SELINUX if SECURITY_SELINUX
-       default DEFAULT_SECURITY_SMACK if SECURITY_SMACK
-       default DEFAULT_SECURITY_TOMOYO if SECURITY_TOMOYO
-       default DEFAULT_SECURITY_APPARMOR if SECURITY_APPARMOR
-       default DEFAULT_SECURITY_DAC
-
-       help
-         Select the security module that will be used by default if the
-         kernel parameter security= is not specified.
-
-       config DEFAULT_SECURITY_SELINUX
-               bool "SELinux" if SECURITY_SELINUX=y
-
-       config DEFAULT_SECURITY_SMACK
-               bool "Simplified Mandatory Access Control" if SECURITY_SMACK=y
-
-       config DEFAULT_SECURITY_TOMOYO
-               bool "TOMOYO" if SECURITY_TOMOYO=y
-
-       config DEFAULT_SECURITY_APPARMOR
-               bool "AppArmor" if SECURITY_APPARMOR=y
-
-       config DEFAULT_SECURITY_DAC
-               bool "Unix Discretionary Access Controls"
-
-endchoice
-
-config DEFAULT_SECURITY
-       string
-       default "selinux" if DEFAULT_SECURITY_SELINUX
-       default "smack" if DEFAULT_SECURITY_SMACK
-       default "tomoyo" if DEFAULT_SECURITY_TOMOYO
-       default "apparmor" if DEFAULT_SECURITY_APPARMOR
-       default "" if DEFAULT_SECURITY_DAC
-
 config LSM
        string "Ordered list of enabled LSMs"
-       default "integrity"
+       default "loadpin,integrity,selinux,smack,tomoyo,apparmor"
        help
          A comma-separated list of LSMs, in initialization order.
          Any LSMs left off this list will be ignored. This can be
index 48f39631b370a45677f166f8f746b8918c5dfe83..055fb0a6416932c89d7933514f95993bf46b8f68 100644 (file)
@@ -187,13 +187,19 @@ 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",
                enforce ? "" : "not ");
        security_add_hooks(loadpin_hooks, ARRAY_SIZE(loadpin_hooks), "loadpin");
+       return 0;
 }
 
+DEFINE_LSM(loadpin) = {
+       .name = "loadpin",
+       .init = loadpin_init,
+};
+
 /* Should not be mutable after boot, so not listed in sysfs (perm == 0). */
 module_param(enforce, int, 0);
 MODULE_PARM_DESC(enforce, "Enforce module/firmware pinning");
index 46c5b0fa515e2c199041c60565edf497f3fd21ec..b8d75f5a948d04f1c70fff78066fc6d85d930d9d 100644 (file)
@@ -275,7 +275,6 @@ int __init security_init(void)
         */
        capability_add_hooks();
        yama_add_hooks();
-       loadpin_add_hooks();
 
        /* Load LSMs in specified order. */
        ordered_lsm_init();