Skip to content

Commit 3d6e5f6

Browse files
keesJames Morris
authored andcommitted
LSM: Convert security_initcall() into DEFINE_LSM()
Instead of using argument-based initializers, switch to defining the contents of struct lsm_info on a per-LSM basis. This also drops the final use of the now inaccurate "initcall" naming. Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Casey Schaufler <casey@schaufler-ca.com> Reviewed-by: James Morris <james.morris@microsoft.com> Signed-off-by: James Morris <james.morris@microsoft.com>
1 parent 3ac946d commit 3d6e5f6

File tree

6 files changed

+17
-8
lines changed

6 files changed

+17
-8
lines changed

include/linux/lsm_hooks.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,11 +2045,10 @@ struct lsm_info {
20452045

20462046
extern struct lsm_info __start_lsm_info[], __end_lsm_info[];
20472047

2048-
#define security_initcall(lsm) \
2048+
#define DEFINE_LSM(lsm) \
20492049
static struct lsm_info __lsm_##lsm \
20502050
__used __section(.lsm_info.init) \
2051-
__aligned(sizeof(unsigned long)) \
2052-
= { .init = lsm, }
2051+
__aligned(sizeof(unsigned long))
20532052

20542053
#ifdef CONFIG_SECURITY_SELINUX_DISABLE
20552054
/*

security/apparmor/lsm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,4 +1606,6 @@ static int __init apparmor_init(void)
16061606
return error;
16071607
}
16081608

1609-
security_initcall(apparmor_init);
1609+
DEFINE_LSM(apparmor) = {
1610+
.init = apparmor_init,
1611+
};

security/integrity/iint.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ static int __init integrity_iintcache_init(void)
175175
0, SLAB_PANIC, init_once);
176176
return 0;
177177
}
178-
security_initcall(integrity_iintcache_init);
178+
DEFINE_LSM(integrity) = {
179+
.init = integrity_iintcache_init,
180+
};
179181

180182

181183
/*

security/selinux/hooks.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7202,7 +7202,9 @@ void selinux_complete_init(void)
72027202

72037203
/* SELinux requires early initialization in order to label
72047204
all processes and objects when they are created. */
7205-
security_initcall(selinux_init);
7205+
DEFINE_LSM(selinux) = {
7206+
.init = selinux_init,
7207+
};
72067208

72077209
#if defined(CONFIG_NETFILTER)
72087210

security/smack/smack_lsm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4882,4 +4882,6 @@ static __init int smack_init(void)
48824882
* Smack requires early initialization in order to label
48834883
* all processes and objects when they are created.
48844884
*/
4885-
security_initcall(smack_init);
4885+
DEFINE_LSM(smack) = {
4886+
.init = smack_init,
4887+
};

security/tomoyo/tomoyo.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,4 +550,6 @@ static int __init tomoyo_init(void)
550550
return 0;
551551
}
552552

553-
security_initcall(tomoyo_init);
553+
DEFINE_LSM(tomoyo) = {
554+
.init = tomoyo_init,
555+
};

0 commit comments

Comments
 (0)