setup.c 944 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Landlock LSM - Security framework setup
  4. *
  5. * Copyright © 2016-2020 Mickaël Salaün <[email protected]>
  6. * Copyright © 2018-2020 ANSSI
  7. */
  8. #include <linux/init.h>
  9. #include <linux/lsm_hooks.h>
  10. #include "common.h"
  11. #include "cred.h"
  12. #include "fs.h"
  13. #include "ptrace.h"
  14. #include "setup.h"
  15. bool landlock_initialized __lsm_ro_after_init = false;
  16. struct lsm_blob_sizes landlock_blob_sizes __lsm_ro_after_init = {
  17. .lbs_cred = sizeof(struct landlock_cred_security),
  18. .lbs_inode = sizeof(struct landlock_inode_security),
  19. .lbs_superblock = sizeof(struct landlock_superblock_security),
  20. };
  21. static int __init landlock_init(void)
  22. {
  23. landlock_add_cred_hooks();
  24. landlock_add_ptrace_hooks();
  25. landlock_add_fs_hooks();
  26. landlock_initialized = true;
  27. pr_info("Up and running.\n");
  28. return 0;
  29. }
  30. DEFINE_LSM(LANDLOCK_NAME) = {
  31. .name = LANDLOCK_NAME,
  32. .init = landlock_init,
  33. .blobs = &landlock_blob_sizes,
  34. };