Smack: Minor initialisation improvement
authorJosé Bollo <jobol@nonadev.net>
Fri, 2 Oct 2015 13:15:56 +0000 (15:15 +0200)
committerCasey Schaufler <casey@schaufler-ca.com>
Fri, 9 Oct 2015 22:13:24 +0000 (15:13 -0700)
This change has two goals:
 - delay the setting of 'smack_enabled' until
   it will be really effective
 - ensure that smackfs is valid only if 'smack_enabled'
   is set (it is already the case in smack_netfilter.c)

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
security/smack/smack_lsm.c
security/smack/smackfs.c

index f02438cc6d295e832cc4df1fa024beb03fb515e5..2c0579d0da20da80b61e93f8f838615a06a2ac2c 100644 (file)
@@ -4708,8 +4708,6 @@ static __init int smack_init(void)
        if (!security_module_enable("smack"))
                return 0;
 
-       smack_enabled = 1;
-
        smack_inode_cache = KMEM_CACHE(inode_smack, 0);
        if (!smack_inode_cache)
                return -ENOMEM;
@@ -4721,6 +4719,8 @@ static __init int smack_init(void)
                return -ENOMEM;
        }
 
+       smack_enabled = 1;
+
        pr_info("Smack:  Initializing.\n");
 #ifdef CONFIG_SECURITY_SMACK_NETFILTER
        pr_info("Smack:  Netfilter enabled.\n");
index 103a619b136028afad4ecd8d996d8f849d748b80..ce8d503a18a0bf30523535af52c403d8178650e3 100644 (file)
@@ -2892,7 +2892,7 @@ static int __init init_smk_fs(void)
        int err;
        int rc;
 
-       if (!security_module_enable("smack"))
+       if (smack_enabled == 0)
                return 0;
 
        err = smk_init_sysfs();