tomoyo.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * security/tomoyo/tomoyo.h
  3. *
  4. * Implementation of the Domain-Based Mandatory Access Control.
  5. *
  6. * Copyright (C) 2005-2009 NTT DATA CORPORATION
  7. *
  8. * Version: 2.2.0-pre 2009/02/01
  9. *
  10. */
  11. #ifndef _SECURITY_TOMOYO_TOMOYO_H
  12. #define _SECURITY_TOMOYO_TOMOYO_H
  13. struct tomoyo_path_info;
  14. struct path;
  15. struct inode;
  16. struct linux_binprm;
  17. struct pt_regs;
  18. struct tomoyo_page_buffer;
  19. int tomoyo_check_file_perm(struct tomoyo_domain_info *domain,
  20. const char *filename, const u8 perm);
  21. int tomoyo_check_exec_perm(struct tomoyo_domain_info *domain,
  22. const struct tomoyo_path_info *filename,
  23. struct tomoyo_page_buffer *buf);
  24. int tomoyo_check_open_permission(struct tomoyo_domain_info *domain,
  25. struct path *path, const int flag);
  26. int tomoyo_check_1path_perm(struct tomoyo_domain_info *domain,
  27. const u8 operation, struct path *path);
  28. int tomoyo_check_2path_perm(struct tomoyo_domain_info *domain,
  29. const u8 operation, struct path *path1,
  30. struct path *path2);
  31. int tomoyo_check_rewrite_permission(struct tomoyo_domain_info *domain,
  32. struct file *filp);
  33. int tomoyo_find_next_domain(struct linux_binprm *bprm,
  34. struct tomoyo_domain_info **next_domain);
  35. /* Index numbers for Access Controls. */
  36. #define TOMOYO_TYPE_SINGLE_PATH_ACL 0
  37. #define TOMOYO_TYPE_DOUBLE_PATH_ACL 1
  38. /* Index numbers for File Controls. */
  39. /*
  40. * TYPE_READ_WRITE_ACL is special. TYPE_READ_WRITE_ACL is automatically set
  41. * if both TYPE_READ_ACL and TYPE_WRITE_ACL are set. Both TYPE_READ_ACL and
  42. * TYPE_WRITE_ACL are automatically set if TYPE_READ_WRITE_ACL is set.
  43. * TYPE_READ_WRITE_ACL is automatically cleared if either TYPE_READ_ACL or
  44. * TYPE_WRITE_ACL is cleared. Both TYPE_READ_ACL and TYPE_WRITE_ACL are
  45. * automatically cleared if TYPE_READ_WRITE_ACL is cleared.
  46. */
  47. #define TOMOYO_TYPE_READ_WRITE_ACL 0
  48. #define TOMOYO_TYPE_EXECUTE_ACL 1
  49. #define TOMOYO_TYPE_READ_ACL 2
  50. #define TOMOYO_TYPE_WRITE_ACL 3
  51. #define TOMOYO_TYPE_CREATE_ACL 4
  52. #define TOMOYO_TYPE_UNLINK_ACL 5
  53. #define TOMOYO_TYPE_MKDIR_ACL 6
  54. #define TOMOYO_TYPE_RMDIR_ACL 7
  55. #define TOMOYO_TYPE_MKFIFO_ACL 8
  56. #define TOMOYO_TYPE_MKSOCK_ACL 9
  57. #define TOMOYO_TYPE_MKBLOCK_ACL 10
  58. #define TOMOYO_TYPE_MKCHAR_ACL 11
  59. #define TOMOYO_TYPE_TRUNCATE_ACL 12
  60. #define TOMOYO_TYPE_SYMLINK_ACL 13
  61. #define TOMOYO_TYPE_REWRITE_ACL 14
  62. #define TOMOYO_MAX_SINGLE_PATH_OPERATION 15
  63. #define TOMOYO_TYPE_LINK_ACL 0
  64. #define TOMOYO_TYPE_RENAME_ACL 1
  65. #define TOMOYO_MAX_DOUBLE_PATH_OPERATION 2
  66. #define TOMOYO_DOMAINPOLICY 0
  67. #define TOMOYO_EXCEPTIONPOLICY 1
  68. #define TOMOYO_DOMAIN_STATUS 2
  69. #define TOMOYO_PROCESS_STATUS 3
  70. #define TOMOYO_MEMINFO 4
  71. #define TOMOYO_SELFDOMAIN 5
  72. #define TOMOYO_VERSION 6
  73. #define TOMOYO_PROFILE 7
  74. #define TOMOYO_MANAGER 8
  75. extern struct tomoyo_domain_info tomoyo_kernel_domain;
  76. static inline struct tomoyo_domain_info *tomoyo_domain(void)
  77. {
  78. return current_cred()->security;
  79. }
  80. /* Caller holds tasklist_lock spinlock. */
  81. static inline struct tomoyo_domain_info *tomoyo_real_domain(struct task_struct
  82. *task)
  83. {
  84. /***** CRITICAL SECTION START *****/
  85. const struct cred *cred = get_task_cred(task);
  86. struct tomoyo_domain_info *domain = cred->security;
  87. put_cred(cred);
  88. return domain;
  89. /***** CRITICAL SECTION END *****/
  90. }
  91. #endif /* !defined(_SECURITY_TOMOYO_TOMOYO_H) */