Remove caitsith_exports.add_hooks
@@ -54,9 +54,6 @@ | ||
54 | 54 | /* For exporting variables and functions. */ |
55 | 55 | struct caitsith_exports { |
56 | 56 | void (*load_policy)(const char *filename); |
57 | -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) && defined(CONFIG_SECURITY) | |
58 | - void (*add_hooks)(void); | |
59 | -#endif | |
60 | 57 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) |
61 | 58 | char * (*d_absolute_path)(const struct path *, char *, int); |
62 | 59 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) |
@@ -234,9 +234,6 @@ | ||
234 | 234 | #ifndef CONFIG_CAITSITH_OMIT_USERSPACE_LOADER |
235 | 235 | .load_policy = cs_load_policy, |
236 | 236 | #endif |
237 | -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) && defined(CONFIG_SECURITY) | |
238 | - .add_hooks = cs_add_hooks, | |
239 | -#endif | |
240 | 237 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) |
241 | 238 | .d_absolute_path = d_absolute_path, |
242 | 239 | #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) |
@@ -266,18 +266,17 @@ | ||
266 | 266 | #endif |
267 | 267 | }; |
268 | 268 | |
269 | -static void cs_add_hooks(void) | |
269 | +static int __init cs_add_hooks(void) | |
270 | 270 | { |
271 | + if (caitsith_ops.disabled) | |
272 | + return 0; | |
271 | 273 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) |
272 | - int i; | |
273 | - | |
274 | - for (i = 0; i < ARRAY_SIZE(caitsith_hooks); i++) { | |
275 | - caitsith_hooks[i].lsm = "caitsith"; | |
276 | - list_add_tail_rcu(&caitsith_hooks[i].list, | |
277 | - caitsith_hooks[i].head); | |
278 | - } | |
274 | + security_add_hooks(caitsith_hooks, ARRAY_SIZE(caitsith_hooks), | |
275 | + "caitsith"); | |
279 | 276 | #else |
280 | 277 | security_add_hooks(caitsith_hooks, ARRAY_SIZE(caitsith_hooks)); |
281 | 278 | #endif |
279 | + return 0; | |
282 | 280 | } |
281 | +late_initcall(cs_add_hooks); | |
283 | 282 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) && defined(CONFIG_SECURITY) */ |
@@ -2245,9 +2245,6 @@ | ||
2245 | 2245 | cs_policy_loaded = true; |
2246 | 2246 | printk(KERN_INFO "CaitSith: 0.2.1 2017/02/20\n"); |
2247 | 2247 | if (cs_policy_version == 20120401) { |
2248 | -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) && defined(CONFIG_SECURITY) | |
2249 | - caitsith_exports.add_hooks(); | |
2250 | -#endif | |
2251 | 2248 | printk(KERN_INFO "CaitSith module activated.\n"); |
2252 | 2249 | return; |
2253 | 2250 | } |