Skip to content

Commit 4ab5efc

Browse files
committed
lsm: consolidate all of the LSM framework initcalls
The LSM framework itself registers a small number of initcalls, this patch converts these initcalls into the new initcall mechanism. Reviewed-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 3156bc8 commit 4ab5efc

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

security/inode.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ static const struct file_operations lsm_ops = {
368368
};
369369
#endif
370370

371-
static int __init securityfs_init(void)
371+
int __init securityfs_init(void)
372372
{
373373
int retval;
374374

@@ -387,4 +387,3 @@ static int __init securityfs_init(void)
387387
#endif
388388
return 0;
389389
}
390-
core_initcall(securityfs_init);

security/lsm.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,24 @@ extern struct kmem_cache *lsm_inode_cache;
3535
int lsm_cred_alloc(struct cred *cred, gfp_t gfp);
3636
int lsm_task_alloc(struct task_struct *task);
3737

38+
/* LSM framework initializers */
39+
40+
#ifdef CONFIG_MMU
41+
int min_addr_init(void);
42+
#else
43+
static inline int min_addr_init(void)
44+
{
45+
return 0;
46+
}
47+
#endif /* CONFIG_MMU */
48+
49+
#ifdef CONFIG_SECURITYFS
50+
int securityfs_init(void);
51+
#else
52+
static inline int securityfs_init(void)
53+
{
54+
return 0;
55+
}
56+
#endif /* CONFIG_SECURITYFS */
57+
3858
#endif /* _LSM_H_ */

security/lsm_init.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,12 @@ int __init security_init(void)
488488
*/
489489
static int __init security_initcall_pure(void)
490490
{
491-
return lsm_initcall(pure);
491+
int rc_adr, rc_lsm;
492+
493+
rc_adr = min_addr_init();
494+
rc_lsm = lsm_initcall(pure);
495+
496+
return (rc_adr ? rc_adr : rc_lsm);
492497
}
493498
pure_initcall(security_initcall_pure);
494499

@@ -506,7 +511,12 @@ early_initcall(security_initcall_early);
506511
*/
507512
static int __init security_initcall_core(void)
508513
{
509-
return lsm_initcall(core);
514+
int rc_sfs, rc_lsm;
515+
516+
rc_sfs = securityfs_init();
517+
rc_lsm = lsm_initcall(core);
518+
519+
return (rc_sfs ? rc_sfs : rc_lsm);
510520
}
511521
core_initcall(security_initcall_core);
512522

security/min_addr.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <linux/sysctl.h>
66
#include <linux/minmax.h>
77

8+
#include "lsm.h"
9+
810
/* amount of vm to protect from userspace access by both DAC and the LSM*/
911
unsigned long mmap_min_addr;
1012
/* amount of vm to protect from userspace using CAP_SYS_RAWIO (DAC) */
@@ -52,11 +54,10 @@ static const struct ctl_table min_addr_sysctl_table[] = {
5254
},
5355
};
5456

55-
static int __init init_mmap_min_addr(void)
57+
int __init min_addr_init(void)
5658
{
5759
register_sysctl_init("vm", min_addr_sysctl_table);
5860
update_mmap_min_addr();
5961

6062
return 0;
6163
}
62-
pure_initcall(init_mmap_min_addr);

0 commit comments

Comments
 (0)