Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+36 -6
+1 -2
security/inode.c
··· 368 368 }; 369 369 #endif 370 370 371 - static int __init securityfs_init(void) 371 + int __init securityfs_init(void) 372 372 { 373 373 int retval; 374 374 ··· 387 387 #endif 388 388 return 0; 389 389 } 390 - core_initcall(securityfs_init);
+20
security/lsm.h
··· 35 35 int lsm_cred_alloc(struct cred *cred, gfp_t gfp); 36 36 int lsm_task_alloc(struct task_struct *task); 37 37 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 + 38 58 #endif /* _LSM_H_ */
+12 -2
security/lsm_init.c
··· 488 488 */ 489 489 static int __init security_initcall_pure(void) 490 490 { 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); 492 497 } 493 498 pure_initcall(security_initcall_pure); 494 499 ··· 511 506 */ 512 507 static int __init security_initcall_core(void) 513 508 { 514 - return lsm_initcall(core); 509 + int rc_sfs, rc_lsm; 510 + 511 + rc_sfs = securityfs_init(); 512 + rc_lsm = lsm_initcall(core); 513 + 514 + return (rc_sfs ? rc_sfs : rc_lsm); 515 515 } 516 516 core_initcall(security_initcall_core); 517 517
+3 -2
security/min_addr.c
··· 5 5 #include <linux/sysctl.h> 6 6 #include <linux/minmax.h> 7 7 8 + #include "lsm.h" 9 + 8 10 /* amount of vm to protect from userspace access by both DAC and the LSM*/ 9 11 unsigned long mmap_min_addr; 10 12 /* amount of vm to protect from userspace using CAP_SYS_RAWIO (DAC) */ ··· 54 52 }, 55 53 }; 56 54 57 - static int __init init_mmap_min_addr(void) 55 + int __init min_addr_init(void) 58 56 { 59 57 register_sysctl_init("vm", min_addr_sysctl_table); 60 58 update_mmap_min_addr(); 61 59 62 60 return 0; 63 61 } 64 - pure_initcall(init_mmap_min_addr);