@@ -2092,6 +2092,4 @@ static inline void security_delete_hooks(struct security_hook_list *hooks,
#define __lsm_ro_after_init __ro_after_init
#endif /* CONFIG_SECURITY_WRITABLE_HOOKS */
-extern void __init capability_add_hooks(void);
-
#endif /* ! __LINUX_LSM_HOOKS_H */
@@ -1366,10 +1366,17 @@ struct security_hook_list capability_hooks[] __lsm_ro_after_init = {
LSM_HOOK_INIT(vm_enough_memory, cap_vm_enough_memory),
};
-void __init capability_add_hooks(void)
+static int __init capability_init(void)
{
security_add_hooks(capability_hooks, ARRAY_SIZE(capability_hooks),
"capability");
+ return 0;
}
+DEFINE_LSM(capability) = {
+ .name = "capability",
+ .order = LSM_ORDER_FIRST,
+ .init = capability_init,
+};
+
#endif /* CONFIG_SECURITY */
@@ -62,6 +62,10 @@ static __initdata bool debug;
static bool __init is_enabled(struct lsm_info *lsm)
{
+ /* LSM_ORDER_FIRST is always enabled. */
+ if (lsm->order == LSM_ORDER_FIRST)
+ return true;
+
if (WARN_ON(!lsm->enabled))
return false;
@@ -306,11 +310,6 @@ int __init security_init(void)
/* Figure out which LSMs are enabled and disabled. */
prepare_lsm_enable();
- /*
- * Load minor LSMs, with the capability module always first.
- */
- capability_add_hooks();
-
/* Load LSMs in specified order. */
prepare_lsm_order();
ordered_lsm_init();