coredomain.te 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. get_prop(coredomain, pm_prop)
  2. get_prop(coredomain, exported_pm_prop)
  3. full_treble_only(`
  4. neverallow {
  5. coredomain
  6. # for chowning
  7. -init
  8. # generic access to sysfs_type
  9. -ueventd
  10. -vold
  11. } sysfs_leds:file *;
  12. ')
  13. # On TREBLE devices, a limited set of files in /vendor are accessible to
  14. # only a few whitelisted coredomains to keep system/vendor separation.
  15. full_treble_only(`
  16. # Limit access to /vendor/app
  17. neverallow {
  18. coredomain
  19. -appdomain
  20. -dex2oat
  21. -idmap
  22. -init
  23. -installd
  24. userdebug_or_eng(`-perfprofd')
  25. userdebug_or_eng(`-heapprofd')
  26. -postinstall_dexopt
  27. -rs # spawned by appdomain, so carryover the exception above
  28. -system_server
  29. } vendor_app_file:dir { open read getattr search };
  30. ')
  31. full_treble_only(`
  32. neverallow {
  33. coredomain
  34. -appdomain
  35. -dex2oat
  36. -idmap
  37. -init
  38. -installd
  39. userdebug_or_eng(`-perfprofd')
  40. userdebug_or_eng(`-heapprofd')
  41. -postinstall_dexopt
  42. -rs # spawned by appdomain, so carryover the exception above
  43. -system_server
  44. -mediaserver
  45. } vendor_app_file:file r_file_perms;
  46. ')
  47. full_treble_only(`
  48. # Limit access to /vendor/overlay
  49. neverallow {
  50. coredomain
  51. -appdomain
  52. -idmap
  53. -init
  54. -installd
  55. -postinstall_dexopt
  56. -rs # spawned by appdomain, so carryover the exception above
  57. -system_server
  58. -app_zygote
  59. -webview_zygote
  60. -zygote
  61. userdebug_or_eng(`-heapprofd')
  62. } vendor_overlay_file:dir { getattr open read search };
  63. ')
  64. full_treble_only(`
  65. neverallow {
  66. coredomain
  67. -appdomain
  68. -idmap
  69. -init
  70. -installd
  71. -postinstall_dexopt
  72. -rs # spawned by appdomain, so carryover the exception above
  73. -system_server
  74. -app_zygote
  75. -webview_zygote
  76. -zygote
  77. userdebug_or_eng(`-heapprofd')
  78. } vendor_overlay_file:file r_file_perms;
  79. ')
  80. # Core domains are not permitted to use kernel interfaces which are not
  81. # explicitly labeled.
  82. # TODO(b/65643247): Apply these neverallow rules to all coredomain.
  83. full_treble_only(`
  84. # /proc
  85. neverallow {
  86. coredomain
  87. -init
  88. -vold
  89. } proc:file no_rw_file_perms;
  90. # /sys
  91. neverallow {
  92. coredomain
  93. -init
  94. -ueventd
  95. -vold
  96. } sysfs:file no_rw_file_perms;
  97. # /dev
  98. neverallow {
  99. coredomain
  100. -fsck
  101. -init
  102. -ueventd
  103. } device:{ blk_file file } no_rw_file_perms;
  104. # debugfs
  105. neverallow {
  106. coredomain
  107. -dumpstate
  108. -init
  109. -system_server
  110. } debugfs:file no_rw_file_perms;
  111. # tracefs
  112. neverallow {
  113. coredomain
  114. -atrace
  115. -dumpstate
  116. -init
  117. userdebug_or_eng(`-perfprofd')
  118. -traced_probes
  119. -shell
  120. -traceur_app
  121. } debugfs_tracing:file no_rw_file_perms;
  122. # inotifyfs
  123. neverallow {
  124. coredomain
  125. -init
  126. } inotify:file no_rw_file_perms;
  127. # pstorefs
  128. neverallow {
  129. coredomain
  130. -bootstat
  131. -charger
  132. -dumpstate
  133. -healthd
  134. userdebug_or_eng(`-incidentd')
  135. -init
  136. -logd
  137. -logpersist
  138. -recovery_persist
  139. -recovery_refresh
  140. -shell
  141. -system_server
  142. } pstorefs:file no_rw_file_perms;
  143. # configfs
  144. neverallow {
  145. coredomain
  146. -init
  147. -system_server
  148. } configfs:file no_rw_file_perms;
  149. # functionfs
  150. neverallow {
  151. coredomain
  152. -adbd
  153. -init
  154. -mediaprovider
  155. -system_server
  156. } functionfs:file no_rw_file_perms;
  157. # usbfs and binfmt_miscfs
  158. neverallow {
  159. coredomain
  160. -init
  161. }{ usbfs binfmt_miscfs }:file no_rw_file_perms;
  162. ')
  163. # Following /dev nodes must not be directly accessed by coredomain, but should
  164. # instead be wrapped by HALs.
  165. neverallow coredomain {
  166. iio_device
  167. radio_device
  168. }:chr_file { open read append write ioctl };
  169. # TODO(b/120243891): HAL permission to tee_device is included into coredomain
  170. # on non-Treble devices.
  171. full_treble_only(`
  172. neverallow coredomain tee_device:chr_file { open read append write ioctl };
  173. ')
  174. # Allow access to ashmemd to request /dev/ashmem fds.
  175. allow {
  176. coredomain
  177. -init
  178. -iorapd
  179. -perfprofd
  180. } ashmem_device_service:service_manager find;
  181. binder_call({
  182. coredomain
  183. -init
  184. -iorapd
  185. -perfprofd
  186. }, ashmemd)