Skip to content

Commit

Permalink
Smack: Minor initialisation improvement
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
José Bollo authored and Casey Schaufler committed Oct 9, 2015
1 parent 8b549ef commit d21b7b0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions security/smack/smack_lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion security/smack/smackfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit d21b7b0

Please sign in to comment.