Skip to content

Commit 06643d5

Browse files
committed
smack: move initcalls to the LSM framework
As the LSM framework only supports one LSM initcall callback for each initcall type, the init_smk_fs() and smack_nf_ip_init() functions were wrapped with a new function, smack_initcall() that is registered with the LSM framework. Acked-by: Casey Schaufler <casey@schaufler-ca.com> Reviewed-by: John Johansen <john.johhansen@canonical.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent d934f97 commit 06643d5

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

security/smack/smack.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,20 @@ struct smk_audit_info {
275275
#endif
276276
};
277277

278+
/*
279+
* Initialization
280+
*/
281+
#if defined(CONFIG_SECURITY_SMACK_NETFILTER)
282+
int smack_nf_ip_init(void);
283+
#else
284+
static inline int smack_nf_ip_init(void)
285+
{
286+
return 0;
287+
}
288+
#endif
289+
int init_smk_fs(void);
290+
int smack_initcall(void);
291+
278292
/*
279293
* These functions are in smack_access.c
280294
*/

security/smack/smack_lsm.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5275,6 +5275,14 @@ static __init int smack_init(void)
52755275
return 0;
52765276
}
52775277

5278+
int __init smack_initcall(void)
5279+
{
5280+
int rc_fs = init_smk_fs();
5281+
int rc_nf = smack_nf_ip_init();
5282+
5283+
return rc_fs ? rc_fs : rc_nf;
5284+
}
5285+
52785286
/*
52795287
* Smack requires early initialization in order to label
52805288
* all processes and objects when they are created.
@@ -5284,4 +5292,5 @@ DEFINE_LSM(smack) = {
52845292
.flags = LSM_FLAG_LEGACY_MAJOR | LSM_FLAG_EXCLUSIVE,
52855293
.blobs = &smack_blob_sizes,
52865294
.init = smack_init,
5295+
.initcall_device = smack_initcall,
52875296
};

security/smack/smack_netfilter.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,11 @@ static struct pernet_operations smack_net_ops = {
6868
.exit = smack_nf_unregister,
6969
};
7070

71-
static int __init smack_nf_ip_init(void)
71+
int __init smack_nf_ip_init(void)
7272
{
7373
if (smack_enabled == 0)
7474
return 0;
7575

7676
printk(KERN_DEBUG "Smack: Registering netfilter hooks\n");
7777
return register_pernet_subsys(&smack_net_ops);
7878
}
79-
80-
__initcall(smack_nf_ip_init);

security/smack/smackfs.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,7 +2978,7 @@ static struct vfsmount *smackfs_mount;
29782978
* Returns true if we were not chosen on boot or if
29792979
* we were chosen and filesystem registration succeeded.
29802980
*/
2981-
static int __init init_smk_fs(void)
2981+
int __init init_smk_fs(void)
29822982
{
29832983
int err;
29842984
int rc;
@@ -3021,5 +3021,3 @@ static int __init init_smk_fs(void)
30213021

30223022
return err;
30233023
}
3024-
3025-
__initcall(init_smk_fs);

0 commit comments

Comments
 (0)