zygote.te 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. # zygote
  2. typeattribute zygote coredomain;
  3. typeattribute zygote mlstrustedsubject;
  4. init_daemon_domain(zygote)
  5. read_runtime_log_tags(zygote)
  6. # Override DAC on files and switch uid/gid.
  7. allow zygote self:global_capability_class_set { dac_override dac_read_search setgid setuid fowner chown };
  8. # Drop capabilities from bounding set.
  9. allow zygote self:global_capability_class_set setpcap;
  10. # Switch SELinux context to app domains.
  11. allow zygote self:process setcurrent;
  12. allow zygote system_server_startup:process dyntransition;
  13. allow zygote appdomain:process dyntransition;
  14. allow zygote webview_zygote:process dyntransition;
  15. allow zygote app_zygote:process dyntransition;
  16. # Allow zygote to read app /proc/pid dirs (b/10455872).
  17. allow zygote appdomain:dir { getattr search };
  18. allow zygote appdomain:file { r_file_perms };
  19. # Move children into the peer process group.
  20. allow zygote system_server:process { getpgid setpgid };
  21. allow zygote appdomain:process { getpgid setpgid };
  22. allow zygote webview_zygote:process { getpgid setpgid };
  23. allow zygote app_zygote:process { getpgid setpgid };
  24. # Read system data.
  25. allow zygote system_data_file:dir r_dir_perms;
  26. allow zygote system_data_file:file r_file_perms;
  27. # Write to /data/dalvik-cache.
  28. allow zygote dalvikcache_data_file:dir create_dir_perms;
  29. allow zygote dalvikcache_data_file:file create_file_perms;
  30. # Create symlinks in /data/dalvik-cache.
  31. allow zygote dalvikcache_data_file:lnk_file create_file_perms;
  32. # Write to /data/resource-cache.
  33. allow zygote resourcecache_data_file:dir rw_dir_perms;
  34. allow zygote resourcecache_data_file:file create_file_perms;
  35. # For updateability, the zygote may fetch the current boot
  36. # classpath from the dalvik cache. Integrity of the files
  37. # is ensured by fsverity protection (checked in art_apex_boot_integrity).
  38. allow zygote dalvikcache_data_file:file execute;
  39. # Allow zygote to create JIT memory.
  40. allow zygote self:process execmem;
  41. # Execute idmap and dex2oat within zygote's own domain.
  42. # TODO: Should either of these be transitioned to the same domain
  43. # used by installd or stay in-domain for zygote?
  44. allow zygote idmap_exec:file rx_file_perms;
  45. allow zygote dex2oat_exec:file rx_file_perms;
  46. # Allow apps access to /vendor/overlay
  47. r_dir_file(zygote, vendor_overlay_file)
  48. # Control cgroups.
  49. allow zygote cgroup:dir create_dir_perms;
  50. allow zygote cgroup:{ file lnk_file } r_file_perms;
  51. allow zygote self:global_capability_class_set sys_admin;
  52. # Allow zygote to stat the files that it opens. The zygote must
  53. # be able to inspect them so that it can reopen them on fork
  54. # if necessary: b/30963384.
  55. allow zygote pmsg_device:chr_file getattr;
  56. allow zygote debugfs_trace_marker:file getattr;
  57. # Get seapp_contexts
  58. allow zygote seapp_contexts_file:file r_file_perms;
  59. # Check validity of SELinux context before use.
  60. selinux_check_context(zygote)
  61. # Check SELinux permissions.
  62. selinux_check_access(zygote)
  63. # Native bridge functionality requires that zygote replaces
  64. # /proc/cpuinfo with /system/lib/<ISA>/cpuinfo using a bind mount
  65. allow zygote proc_cpuinfo:file mounton;
  66. # Allow remounting rootfs as MS_SLAVE.
  67. allow zygote rootfs:dir mounton;
  68. allow zygote tmpfs:filesystem { mount unmount };
  69. allow zygote fuse:filesystem { unmount };
  70. allow zygote sdcardfs:filesystem { unmount };
  71. # Allow creating user-specific storage source if started before vold.
  72. allow zygote mnt_user_file:dir { create_dir_perms mounton };
  73. allow zygote mnt_user_file:lnk_file create_file_perms;
  74. allow zygote mnt_user_file:file create_file_perms;
  75. # Allowed to mount user-specific storage into place
  76. allow zygote storage_file:dir { search mounton };
  77. # Allow mounting and creating files, dirs on sdcardfs.
  78. # TODO: reduce this back to only sdcardfs once b/123533205 is root-caused
  79. # (Technically "sdcardfs" and "media_rw_data_file" are equivalent, since
  80. # sdcardfs simply wraps files stored under /data/media.)
  81. allow zygote { sdcard_type media_rw_data_file }:dir { create_dir_perms mounton };
  82. allow zygote { sdcard_type media_rw_data_file }:file { create_file_perms };
  83. # Allow zygote to expand app files while preloading libraries
  84. allow zygote mnt_expand_file:dir getattr;
  85. # Handle --invoke-with command when launching Zygote with a wrapper command.
  86. allow zygote zygote_exec:file rx_file_perms;
  87. # Allow zygote to write to statsd.
  88. unix_socket_send(zygote, statsdw, statsd)
  89. # Root fs.
  90. r_dir_file(zygote, rootfs)
  91. # System file accesses.
  92. r_dir_file(zygote, system_file)
  93. # /oem accesses.
  94. allow zygote oemfs:dir search;
  95. userdebug_or_eng(`
  96. # Allow zygote to create and write method traces in /data/misc/trace.
  97. allow zygote method_trace_data_file:dir w_dir_perms;
  98. allow zygote method_trace_data_file:file { create w_file_perms };
  99. ')
  100. allow zygote ion_device:chr_file r_file_perms;
  101. allow zygote tmpfs:dir r_dir_perms;
  102. allow zygote same_process_hal_file:file { execute read open getattr map };
  103. # Let the zygote access overlays so it can initialize the AssetManager.
  104. get_prop(zygote, overlay_prop)
  105. get_prop(zygote, exported_overlay_prop)
  106. # Allow the zygote to access the runtime feature flag properties.
  107. get_prop(zygote, device_config_runtime_native_prop)
  108. get_prop(zygote, device_config_runtime_native_boot_prop)
  109. # ingore spurious denials
  110. dontaudit zygote self:global_capability_class_set sys_resource;
  111. ###
  112. ### neverallow rules
  113. ###
  114. # Ensure that all types assigned to app processes are included
  115. # in the appdomain attribute, so that all allow and neverallow rules
  116. # written on appdomain are applied to all app processes.
  117. # This is achieved by ensuring that it is impossible for zygote to
  118. # setcon (dyntransition) to any types other than those associated
  119. # with appdomain plus system_server_startup, webview_zygote and
  120. # app_zygote.
  121. neverallow zygote ~{
  122. appdomain
  123. system_server_startup
  124. webview_zygote
  125. app_zygote
  126. }:process dyntransition;
  127. # Zygote should never execute anything from /data except for /data/dalvik-cache files.
  128. neverallow zygote {
  129. data_file_type
  130. -dalvikcache_data_file # map PROT_EXEC
  131. }:file no_x_file_perms;
  132. # Do not allow access to Bluetooth-related system properties and files
  133. neverallow zygote {
  134. bluetooth_a2dp_offload_prop
  135. bluetooth_audio_hal_prop
  136. bluetooth_prop
  137. exported_bluetooth_prop
  138. }:file create_file_perms;