heapprofd.te 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Android heap profiling daemon. go/heapprofd.
  2. #
  3. # On user builds, this daemon is responsible for receiving the initial
  4. # profiling configuration, finding matching target processes (if profiling by
  5. # process name), and sending the activation signal to them (+ setting system
  6. # properties for new processes to start profiling from startup). When profiling
  7. # is triggered in a process, it spawns a private heapprofd subprocess (in its
  8. # own SELinux domain), which will exclusively handle profiling of its parent.
  9. #
  10. # On debug builds, this central daemon performs profiling for all target
  11. # processes (which talk directly to this daemon).
  12. type heapprofd_exec, exec_type, file_type, system_file_type;
  13. type heapprofd_tmpfs, file_type;
  14. init_daemon_domain(heapprofd)
  15. tmpfs_domain(heapprofd)
  16. # Allow apps in other MLS contexts (for multi-user) to access
  17. # shared memory buffers created by heapprofd.
  18. typeattribute heapprofd_tmpfs mlstrustedobject;
  19. set_prop(heapprofd, heapprofd_prop);
  20. # Necessary for /proc/[pid]/cmdline access & sending signals.
  21. typeattribute heapprofd mlstrustedsubject;
  22. # Allow sending signals to processes. This excludes SIGKILL, SIGSTOP and
  23. # SIGCHLD, which are controlled by separate permissions.
  24. allow heapprofd self:capability kill;
  25. # When scanning /proc/[pid]/cmdline to find matching processes for by-name
  26. # profiling, only whitelisted domains will be allowed by SELinux. Avoid
  27. # spamming logs with denials for entries that we can not access.
  28. dontaudit heapprofd domain:dir { search open };
  29. # Write trace data to the Perfetto traced daemon. This requires connecting to
  30. # its producer socket and obtaining a (per-process) tmpfs fd.
  31. allow heapprofd traced:fd use;
  32. allow heapprofd traced_tmpfs:file { read write getattr map };
  33. unix_socket_connect(heapprofd, traced_producer, traced)
  34. # When handling profiling for all processes, heapprofd needs to read
  35. # executables/libraries/etc to do stack unwinding.
  36. userdebug_or_eng(`
  37. r_dir_file(heapprofd, nativetest_data_file)
  38. r_dir_file(heapprofd, system_file_type)
  39. r_dir_file(heapprofd, apk_data_file)
  40. r_dir_file(heapprofd, dalvikcache_data_file)
  41. r_dir_file(heapprofd, vendor_file_type)
  42. # Some dex files are not world-readable.
  43. # We are still constrained by the SELinux rules above.
  44. allow heapprofd self:global_capability_class_set dac_read_search;
  45. ')
  46. # This is going to happen on user but is benign because central heapprofd
  47. # does not actually need these permission.
  48. # If the dac_read_search capability check is rejected, the kernel then tries
  49. # to perform a dac_override capability check, so we need to dontaudit that
  50. # as well.
  51. dontaudit heapprofd self:global_capability_class_set { dac_read_search dac_override };
  52. never_profile_heap(`{
  53. bpfloader
  54. init
  55. kernel
  56. keystore
  57. llkd
  58. logd
  59. ueventd
  60. vendor_init
  61. vold
  62. }')
  63. full_treble_only(`
  64. neverallow heapprofd vendor_file:file { no_w_file_perms no_x_file_perms };
  65. ')