BACKPORT: Smack: Minor initialisation improvement
authorJosé Bollo <jobol@nonadev.net>
Fri, 2 Oct 2015 13:15:56 +0000 (15:15 +0200)
committerRafal Krypa <r.krypa@samsung.com>
Fri, 12 Aug 2016 16:00:06 +0000 (18:00 +0200)
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>
(cherry-picked from upstream d21b7b049c0c1753a10c1d01606f42bad0e0f733)

security/smack/smack_lsm.c
security/smack/smackfs.c

index 534428e417715b5cd357da5fa81065a35a61165b..f607ef702288be57a184c3ba4ced388a05e4e3b7 100644 (file)
@@ -4711,8 +4711,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;
@@ -4724,6 +4722,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 80a8039be79a27f7c140fea8f568295f4a376b8b..36e7b7fbec548dbbbda51dcae4c82e884d177b5f 100644 (file)
@@ -2896,7 +2896,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();