atop.te 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. policy_module(atop, 0.1.25)
  2. ########################################
  3. #
  4. # Declarations
  5. #
  6. require {
  7. type var_t;
  8. }
  9. attribute_role atop_roles;
  10. type atop_t;
  11. type atop_exec_t;
  12. init_daemon_domain(atop_t, atop_exec_t)
  13. role atop_roles types atop_t;
  14. type atopacct_t;
  15. type atopacct_exec_t;
  16. init_daemon_domain(atopacct_t, atopacct_exec_t)
  17. type atop_initrc_exec_t;
  18. init_script_file(atop_initrc_exec_t)
  19. type atopacct_initrc_exec_t;
  20. init_script_file(atopacct_initrc_exec_t)
  21. type atop_var_log_t;
  22. logging_log_file(atop_var_log_t)
  23. type atop_var_run_t;
  24. files_pid_file(atop_var_run_t)
  25. type atopacct_var_run_t;
  26. files_pid_file(atopacct_var_run_t)
  27. type atop_var_cache_t;
  28. files_type(atop_var_cache_t)
  29. type atop_unit_t;
  30. init_unit_file(atop_unit_t)
  31. ########################################
  32. #
  33. # Local policy
  34. #
  35. allow atop_t atop_exec_t:file execute_no_trans;
  36. allow atop_t self:capability { setuid sys_nice sys_resource ipc_lock sys_pacct dac_override net_raw sys_ptrace };
  37. allow atop_t self:process { setsched sigkill setrlimit setpgid signal };
  38. allow atop_t self:sem { write read create unix_write unix_read };
  39. allow atop_t self:udp_socket { create ioctl };
  40. allow atop_t self:sem associate;
  41. allow atop_t self:rawip_socket { create getopt };
  42. allow atop_t self:fifo_file { getattr ioctl read write };
  43. allow atop_t atopacct_t:sem { associate read unix_write write };
  44. manage_dirs_pattern(atop_t, atop_var_log_t, atop_var_log_t)
  45. manage_files_pattern(atop_t, atop_var_log_t, atop_var_log_t)
  46. logging_log_filetrans(atop_t, atop_var_log_t, file)
  47. manage_dirs_pattern(atop_t, atop_var_cache_t, atop_var_cache_t)
  48. manage_files_pattern(atop_t, atop_var_cache_t, atop_var_cache_t)
  49. filetrans_pattern(atop_t, var_t, atop_var_cache_t, { file dir lnk_file })
  50. manage_dirs_pattern(atop_t, atop_var_run_t, atop_var_run_t)
  51. manage_files_pattern(atop_t, atop_var_run_t, atop_var_run_t)
  52. files_pid_filetrans(atop_t, atop_var_run_t, { file dir })
  53. read_files_pattern(atop_t, atopacct_var_run_t, atopacct_var_run_t)
  54. corecmd_exec_bin(atop_t)
  55. optional_policy(`
  56. gen_require(`
  57. type initrc_t;
  58. ')
  59. allow atop_t initrc_t:sem { read unix_write write associate };
  60. ')
  61. userdom_getattr_user_home_dirs(atop_t)
  62. kernel_getattr_proc(atop_t)
  63. kernel_search_proc(atop_t)
  64. kernel_list_proc(atop_t)
  65. kernel_getattr_proc_files(atop_t)
  66. kernel_read_proc_symlinks(atop_t)
  67. kernel_read_system_state(atop_t)
  68. kernel_get_sysvipc_info(atop_t)
  69. kernel_read_kernel_sysctls(atop_t)
  70. kernel_read_rpc_sysctls(atop_t)
  71. domain_read_all_domains_state(atop_t)
  72. corecmd_shell_entry_type(atop_t)
  73. kernel_read_network_state(atop_t)
  74. fs_getattr_tmpfs(atop_t)
  75. fs_getattr_xattr_fs(atop_t)
  76. auth_use_nsswitch(atop_t)
  77. storage_getattr_fixed_disk_dev(atop_t)
  78. miscfiles_read_localization(atop_t)
  79. dev_getattr_lvm_control(atop_t)
  80. cron_system_entry(atop_t, atop_exec_t)
  81. init_read_utmp(atop_t)
  82. dontaudit atop_t self:capability dac_read_search;
  83. ### atopacct policy
  84. allow atopacct_t self:capability { net_admin sys_nice sys_pacct };
  85. allow atopacct_t self:netlink_generic_socket { bind create read setopt write };
  86. allow atopacct_t self:process { setsched signal };
  87. allow atopacct_t self:unix_dgram_socket { connect create write };
  88. allow atopacct_t self:sem { read unix_read };
  89. manage_dirs_pattern(atopacct_t, atopacct_var_run_t, atopacct_var_run_t)
  90. manage_files_pattern(atopacct_t, atopacct_var_run_t, atopacct_var_run_t)
  91. files_pid_filetrans(atopacct_t, atopacct_var_run_t, { file dir })
  92. logging_send_syslog_msg(atopacct_t)
  93. miscfiles_read_localization(atopacct_t)
  94. kernel_read_system_state(atopacct_t)
  95. fs_getattr_tmpfs(atopacct_t)
  96. optional_policy(`
  97. gen_require(`
  98. type initrc_t;
  99. ')
  100. allow atopacct_t initrc_t:sem { associate read unix_read unix_write write };
  101. ')