dumpstate.te 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. # dumpstate
  2. type dumpstate, domain, mlstrustedsubject;
  3. type dumpstate_exec, system_file_type, exec_type, file_type;
  4. net_domain(dumpstate)
  5. binder_use(dumpstate)
  6. wakelock_use(dumpstate)
  7. # Allow setting process priority, protect from OOM killer, and dropping
  8. # privileges by switching UID / GID
  9. allow dumpstate self:global_capability_class_set { setuid setgid sys_resource };
  10. # Allow dumpstate to scan through /proc/pid for all processes
  11. r_dir_file(dumpstate, domain)
  12. allow dumpstate self:global_capability_class_set {
  13. # Send signals to processes
  14. kill
  15. # Run iptables
  16. net_raw
  17. net_admin
  18. };
  19. # Allow executing files on system, such as:
  20. # /system/bin/toolbox
  21. # /system/bin/logcat
  22. # /system/bin/dumpsys
  23. allow dumpstate system_file:file execute_no_trans;
  24. not_full_treble(`allow dumpstate vendor_file:file execute_no_trans;')
  25. allow dumpstate toolbox_exec:file rx_file_perms;
  26. # hidl searches for files in /system/lib(64)/hw/
  27. allow dumpstate system_file:dir r_dir_perms;
  28. # Create and write into /data/anr/
  29. allow dumpstate self:global_capability_class_set { dac_override dac_read_search chown fowner fsetid };
  30. allow dumpstate anr_data_file:dir rw_dir_perms;
  31. allow dumpstate anr_data_file:file create_file_perms;
  32. # Allow reading /data/system/uiderrors.txt
  33. # TODO: scope this down.
  34. allow dumpstate system_data_file:file r_file_perms;
  35. # Allow dumpstate to append into privileged apps private files.
  36. allow dumpstate privapp_data_file:file append;
  37. # Read dmesg
  38. allow dumpstate self:global_capability2_class_set syslog;
  39. allow dumpstate kernel:system syslog_read;
  40. # Read /sys/fs/pstore/console-ramoops
  41. allow dumpstate pstorefs:dir r_dir_perms;
  42. allow dumpstate pstorefs:file r_file_perms;
  43. # Get process attributes
  44. allow dumpstate domain:process getattr;
  45. # Signal java processes to dump their stack
  46. allow dumpstate { appdomain system_server zygote }:process signal;
  47. # Signal native processes to dump their stack.
  48. allow dumpstate {
  49. # This list comes from native_processes_to_dump in dumputils/dump_utils.c
  50. audioserver
  51. cameraserver
  52. drmserver
  53. inputflinger
  54. mediadrmserver
  55. mediaextractor
  56. mediametrics
  57. mediaserver
  58. mediaswcodec
  59. sdcardd
  60. surfaceflinger
  61. vold
  62. # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.c
  63. hal_audio_server
  64. hal_bluetooth_server
  65. hal_camera_server
  66. hal_codec2_server
  67. hal_drm_server
  68. hal_face_server
  69. hal_graphics_allocator_server
  70. hal_graphics_composer_server
  71. hal_health_server
  72. hal_omx_server
  73. hal_power_server
  74. hal_power_stats_server
  75. hal_sensors_server
  76. hal_thermal_server
  77. hal_vr_server
  78. }:process signal;
  79. # Connect to tombstoned to intercept dumps.
  80. unix_socket_connect(dumpstate, tombstoned_intercept, tombstoned)
  81. # Access to /sys
  82. allow dumpstate sysfs_type:dir r_dir_perms;
  83. allow dumpstate {
  84. sysfs_devices_block
  85. sysfs_dm
  86. sysfs_loop
  87. sysfs_usb
  88. sysfs_zram
  89. }:file r_file_perms;
  90. # Other random bits of data we want to collect
  91. allow dumpstate debugfs:file r_file_perms;
  92. auditallow dumpstate debugfs:file r_file_perms;
  93. allow dumpstate debugfs_mmc:file r_file_perms;
  94. # df for
  95. allow dumpstate {
  96. block_device
  97. cache_file
  98. metadata_file
  99. rootfs
  100. selinuxfs
  101. storage_file
  102. tmpfs
  103. }:dir { search getattr };
  104. allow dumpstate fuse_device:chr_file getattr;
  105. allow dumpstate { dm_device cache_block_device }:blk_file getattr;
  106. allow dumpstate { cache_file rootfs }:lnk_file { getattr read };
  107. # Read /dev/cpuctl and /dev/cpuset
  108. r_dir_file(dumpstate, cgroup)
  109. # Allow dumpstate to make binder calls to any binder service
  110. binder_call(dumpstate, binderservicedomain)
  111. binder_call(dumpstate, { appdomain netd wificond })
  112. hal_client_domain(dumpstate, hal_dumpstate)
  113. hal_client_domain(dumpstate, hal_wifi)
  114. hal_client_domain(dumpstate, hal_graphics_allocator)
  115. # Vibrate the device after we are done collecting the bugreport
  116. hal_client_domain(dumpstate, hal_vibrator)
  117. # Reading /proc/PID/maps of other processes
  118. allow dumpstate self:global_capability_class_set sys_ptrace;
  119. # Allow the bugreport service to create a file in
  120. # /data/data/com.android.shell/files/bugreports/bugreport
  121. allow dumpstate shell_data_file:dir create_dir_perms;
  122. allow dumpstate shell_data_file:file create_file_perms;
  123. # Run a shell.
  124. allow dumpstate shell_exec:file rx_file_perms;
  125. # For running am and similar framework commands.
  126. # Run /system/bin/app_process.
  127. allow dumpstate zygote_exec:file rx_file_perms;
  128. # For Bluetooth
  129. allow dumpstate bluetooth_data_file:dir search;
  130. allow dumpstate bluetooth_logs_data_file:dir r_dir_perms;
  131. allow dumpstate bluetooth_logs_data_file:file r_file_perms;
  132. # Dumpstate calls screencap, which grabs a screenshot. Needs gpu access
  133. allow dumpstate gpu_device:chr_file rw_file_perms;
  134. # logd access
  135. read_logd(dumpstate)
  136. control_logd(dumpstate)
  137. read_runtime_log_tags(dumpstate)
  138. # Read files in /proc
  139. allow dumpstate {
  140. proc_buddyinfo
  141. proc_cmdline
  142. proc_meminfo
  143. proc_modules
  144. proc_net_type
  145. proc_pipe_conf
  146. proc_pagetypeinfo
  147. proc_qtaguid_ctrl
  148. proc_qtaguid_stat
  149. proc_slabinfo
  150. proc_version
  151. proc_vmallocinfo
  152. proc_vmstat
  153. }:file r_file_perms;
  154. # Read network state info files.
  155. allow dumpstate net_data_file:dir search;
  156. allow dumpstate net_data_file:file r_file_perms;
  157. # List sockets via ss.
  158. allow dumpstate self:netlink_tcpdiag_socket { create_socket_perms_no_ioctl nlmsg_read };
  159. # Access /data/tombstones.
  160. allow dumpstate tombstone_data_file:dir r_dir_perms;
  161. allow dumpstate tombstone_data_file:file r_file_perms;
  162. # Access /cache/recovery
  163. allow dumpstate cache_recovery_file:dir r_dir_perms;
  164. allow dumpstate cache_recovery_file:file r_file_perms;
  165. # Access /data/misc/recovery
  166. allow dumpstate recovery_data_file:dir r_dir_perms;
  167. allow dumpstate recovery_data_file:file r_file_perms;
  168. #Access /data/misc/update_engine_log
  169. allow dumpstate update_engine_log_data_file:dir r_dir_perms;
  170. allow dumpstate update_engine_log_data_file:file r_file_perms;
  171. # Access /data/misc/profiles/{cur,ref}/
  172. userdebug_or_eng(`
  173. allow dumpstate user_profile_data_file:dir r_dir_perms;
  174. allow dumpstate user_profile_data_file:file r_file_perms;
  175. ')
  176. # Access /data/misc/logd
  177. userdebug_or_eng(`
  178. allow dumpstate misc_logd_file:dir r_dir_perms;
  179. allow dumpstate misc_logd_file:file r_file_perms;
  180. ')
  181. allow dumpstate app_fuse_file:dir r_dir_perms;
  182. allow dumpstate overlayfs_file:dir r_dir_perms;
  183. allow dumpstate {
  184. service_manager_type
  185. -apex_service
  186. -dumpstate_service
  187. -gatekeeper_service
  188. -iorapd_service
  189. -virtual_touchpad_service
  190. -vold_service
  191. -vr_hwc_service
  192. }:service_manager find;
  193. # suppress denials for services dumpstate should not be accessing.
  194. dontaudit dumpstate {
  195. apex_service
  196. dumpstate_service
  197. gatekeeper_service
  198. iorapd_service
  199. virtual_touchpad_service
  200. vold_service
  201. vr_hwc_service
  202. }:service_manager find;
  203. # Most of these are neverallowed.
  204. dontaudit dumpstate hwservice_manager_type:hwservice_manager find;
  205. allow dumpstate servicemanager:service_manager list;
  206. allow dumpstate hwservicemanager:hwservice_manager list;
  207. allow dumpstate devpts:chr_file rw_file_perms;
  208. # Set properties.
  209. # dumpstate_prop is used to share state with the Shell app.
  210. set_prop(dumpstate, dumpstate_prop)
  211. set_prop(dumpstate, exported_dumpstate_prop)
  212. # dumpstate_options_prop is used to pass extra command-line args.
  213. set_prop(dumpstate, dumpstate_options_prop)
  214. # Read any system properties
  215. get_prop(dumpstate, property_type)
  216. # Access to /data/media.
  217. # This should be removed if sdcardfs is modified to alter the secontext for its
  218. # accesses to the underlying FS.
  219. allow dumpstate media_rw_data_file:dir getattr;
  220. allow dumpstate proc_interrupts:file r_file_perms;
  221. allow dumpstate proc_zoneinfo:file r_file_perms;
  222. # Create a service for talking back to system_server
  223. add_service(dumpstate, dumpstate_service)
  224. # use /dev/ion for screen capture
  225. allow dumpstate ion_device:chr_file r_file_perms;
  226. # Allow dumpstate to run top
  227. allow dumpstate proc_stat:file r_file_perms;
  228. # Allow dumpstate to talk to installd over binder
  229. binder_call(dumpstate, installd);
  230. # Allow dumpstate to run ip xfrm policy
  231. allow dumpstate self:netlink_xfrm_socket { create_socket_perms_no_ioctl nlmsg_read };
  232. # Allow dumpstate to run iotop
  233. allow dumpstate self:netlink_socket create_socket_perms_no_ioctl;
  234. # newer kernels (e.g. 4.4) have a new class for sockets
  235. allow dumpstate self:netlink_generic_socket create_socket_perms_no_ioctl;
  236. # Allow dumpstate to run ss
  237. allow dumpstate { domain pdx_channel_socket_type pdx_endpoint_socket_type }:socket_class_set getattr;
  238. # For when dumpstate runs df
  239. dontaudit dumpstate mnt_vendor_file:dir search;
  240. dontaudit dumpstate apex_mnt_dir:dir getattr;
  241. # Allow dumpstate to talk to bufferhubd over binder
  242. binder_call(dumpstate, bufferhubd);
  243. # Allow dumpstate to talk to mediaswcodec over binder
  244. binder_call(dumpstate, mediaswcodec);
  245. # Allow dumpstate to kill vendor dumpstate service by init
  246. set_prop(dumpstate, ctl_dumpstate_prop)
  247. ###
  248. ### neverallow rules
  249. ###
  250. # dumpstate has capability sys_ptrace, but should only use that capability for
  251. # accessing sensitive /proc/PID files, never for using ptrace attach.
  252. neverallow dumpstate *:process ptrace;
  253. # only system_server, dumpstate, traceur_app and shell can find the dumpstate service
  254. neverallow {
  255. domain
  256. -system_server
  257. -shell
  258. -traceur_app
  259. -dumpstate
  260. } dumpstate_service:service_manager find;