Alex Klyubin | f5446eb | 2017-03-23 14:27:32 -0700 | [diff] [blame] | 1 | typeattribute dumpstate coredomain; |
Primiano Tucci | 2f99809 | 2021-01-07 17:12:21 +0000 | [diff] [blame] | 2 | type dumpstate_tmpfs, file_type; |
Alex Klyubin | f5446eb | 2017-03-23 14:27:32 -0700 | [diff] [blame] | 3 | |
dcashman | cc39f63 | 2016-07-22 13:13:11 -0700 | [diff] [blame] | 4 | init_daemon_domain(dumpstate) |
| 5 | |
| 6 | # Execute and transition to the vdc domain |
| 7 | domain_auto_trans(dumpstate, vdc_exec, vdc) |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 8 | |
Chris Morin | 1d88bf5 | 2022-02-12 13:52:39 -0800 | [diff] [blame] | 9 | # Create tmpfs files for using memfd descriptors to get output from child |
| 10 | # processes. |
| 11 | tmpfs_domain(dumpstate) |
| 12 | |
Joel Scherpelz | 5e901bb | 2017-04-25 11:53:51 +0900 | [diff] [blame] | 13 | # Acquire advisory lock on /system/etc/xtables.lock from ip[6]tables |
| 14 | allow dumpstate system_file:file lock; |
| 15 | |
ynwang | e68d2d2 | 2016-07-01 12:18:54 -0700 | [diff] [blame] | 16 | allow dumpstate storaged_exec:file rx_file_perms; |
| 17 | |
Hongming Jin | 58f8341 | 2021-02-09 12:03:40 -0800 | [diff] [blame] | 18 | # /data/misc/a11ytrace for accessibility traces |
| 19 | userdebug_or_eng(` |
| 20 | allow dumpstate accessibility_trace_data_file:dir r_dir_perms; |
| 21 | allow dumpstate accessibility_trace_data_file:file r_file_perms; |
| 22 | ') |
| 23 | |
Vishnu Nair | 2d6942d | 2017-11-17 08:23:32 -0800 | [diff] [blame] | 24 | # /data/misc/wmtrace for wm traces |
| 25 | userdebug_or_eng(` |
| 26 | allow dumpstate wm_trace_data_file:dir r_dir_perms; |
| 27 | allow dumpstate wm_trace_data_file:file r_file_perms; |
| 28 | ') |
| 29 | |
Jeff Sharkey | ef5e5c8 | 2023-02-06 14:25:48 -0700 | [diff] [blame] | 30 | # /data/system/dropbox for dropbox entries |
| 31 | userdebug_or_eng(` |
| 32 | allow dumpstate dropbox_data_file:dir r_dir_perms; |
| 33 | allow dumpstate dropbox_data_file:file r_file_perms; |
| 34 | ') |
| 35 | |
Ted Bauer | eaeb65f | 2024-07-01 19:36:21 +0000 | [diff] [blame] | 36 | r_dir_file(dumpstate, aconfig_storage_metadata_file); |
| 37 | r_dir_file(dumpstate, aconfig_test_mission_files); |
| 38 | |
Mike Ma | de3a3e4 | 2018-12-03 10:35:40 -0800 | [diff] [blame] | 39 | # Allow dumpstate to make binder calls to incidentd |
| 40 | binder_call(dumpstate, incidentd) |
| 41 | |
ThiƩbaud Weksteen | 3b1c843 | 2023-01-04 12:57:11 +1100 | [diff] [blame] | 42 | # Kill incident in case of a timeout |
| 43 | allow dumpstate incident:process { signal sigkill }; |
| 44 | |
ynwang | e68d2d2 | 2016-07-01 12:18:54 -0700 | [diff] [blame] | 45 | # Allow dumpstate to make binder calls to storaged service |
| 46 | binder_call(dumpstate, storaged) |
Keun-young Park | 43e8fae | 2017-03-03 13:13:25 -0800 | [diff] [blame] | 47 | |
Yao Chen | b10ff33 | 2018-01-17 16:17:28 -0800 | [diff] [blame] | 48 | # Allow dumpstate to make binder calls to statsd |
| 49 | binder_call(dumpstate, statsd) |
| 50 | |
Joel Galenson | 7c275a6 | 2018-11-13 12:35:17 -0800 | [diff] [blame] | 51 | # Allow dumpstate to talk to gpuservice over binder |
| 52 | binder_call(dumpstate, gpuservice); |
| 53 | |
Joel Galenson | 657470a | 2018-12-05 11:01:04 -0800 | [diff] [blame] | 54 | # Allow dumpstate to talk to idmap over binder |
| 55 | binder_call(dumpstate, idmap); |
| 56 | |
Alex Hong | 906c724 | 2020-11-10 14:12:38 +0800 | [diff] [blame] | 57 | # Allow dumpstate to talk to profcollectd over binder |
| 58 | userdebug_or_eng(` |
| 59 | binder_call(dumpstate, profcollectd) |
| 60 | ') |
| 61 | |
Changyeon Jo | 152a2f1 | 2023-09-26 18:44:35 +0000 | [diff] [blame] | 62 | # Allow dumpstate to talk to automotive_display_service over binder |
| 63 | binder_call(dumpstate, automotive_display_service) |
| 64 | |
Jan Sebechlebsky | de64417 | 2023-11-30 10:57:16 +0100 | [diff] [blame] | 65 | # Allow dumpstate to talk to virtual_camera service over binder |
| 66 | binder_call(dumpstate, virtual_camera) |
| 67 | |
Kangping Dong | e1ee768 | 2023-12-01 13:02:38 +0800 | [diff] [blame] | 68 | # Allow dumpstate to talk to ot_daemon service over binder |
| 69 | binder_call(dumpstate, ot_daemon) |
| 70 | |
Keun-young Park | 43e8fae | 2017-03-03 13:13:25 -0800 | [diff] [blame] | 71 | # Collect metrics on boot time created by init |
| 72 | get_prop(dumpstate, boottime_prop) |
Andreas Gampe | 7468db6 | 2018-01-24 17:56:25 -0800 | [diff] [blame] | 73 | |
Steven Moreland | 9f41fc0 | 2024-02-16 22:38:26 +0000 | [diff] [blame] | 74 | get_prop(dumpstate, misctrl_prop) |
| 75 | |
Andreas Gampe | 7468db6 | 2018-01-24 17:56:25 -0800 | [diff] [blame] | 76 | # Signal native processes to dump their stack. |
| 77 | allow dumpstate { |
Chong Zhang | 81f5b9f | 2020-10-15 12:38:30 -0700 | [diff] [blame] | 78 | mediatranscoding |
Andreas Gampe | 7468db6 | 2018-01-24 17:56:25 -0800 | [diff] [blame] | 79 | statsd |
Chalard Jean | a4c9f7b | 2019-04-05 17:33:56 +0900 | [diff] [blame] | 80 | netd |
Jan Sebechlebsky | de64417 | 2023-11-30 10:57:16 +0100 | [diff] [blame] | 81 | virtual_camera |
Kangping Dong | e1ee768 | 2023-12-01 13:02:38 +0800 | [diff] [blame] | 82 | ot_daemon |
Andreas Gampe | 7468db6 | 2018-01-24 17:56:25 -0800 | [diff] [blame] | 83 | }:process signal; |
Joel Galenson | 03ff9f9 | 2018-02-14 14:32:38 -0800 | [diff] [blame] | 84 | |
David Drysdale | e1075f7 | 2023-03-17 12:21:32 +0000 | [diff] [blame] | 85 | # Only allow dumpstate to dump Keystore on debuggable builds. |
Eric Biggers | f9519a6 | 2021-05-04 20:59:32 -0700 | [diff] [blame] | 86 | userdebug_or_eng(` |
| 87 | allow dumpstate keystore:process signal; |
| 88 | ') |
David Drysdale | e1075f7 | 2023-03-17 12:21:32 +0000 | [diff] [blame] | 89 | dontaudit dumpstate keystore:process { signal }; |
Eric Biggers | f9519a6 | 2021-05-04 20:59:32 -0700 | [diff] [blame] | 90 | |
Joel Galenson | 03ff9f9 | 2018-02-14 14:32:38 -0800 | [diff] [blame] | 91 | # For collecting bugreports. |
Hridya Valsaraju | 23f9f51 | 2021-05-04 22:01:51 -0700 | [diff] [blame] | 92 | no_debugfs_restriction(` |
| 93 | allow dumpstate debugfs_wakeup_sources:file r_file_perms; |
| 94 | ') |
| 95 | |
Joel Galenson | 03ff9f9 | 2018-02-14 14:32:38 -0800 | [diff] [blame] | 96 | allow dumpstate dev_type:blk_file getattr; |
| 97 | allow dumpstate webview_zygote:process signal; |
Hridya Valsaraju | 6217b66 | 2021-01-10 21:09:37 -0800 | [diff] [blame] | 98 | allow dumpstate sysfs_dmabuf_stats:file r_file_perms; |
Joel Galenson | 03ff9f9 | 2018-02-14 14:32:38 -0800 | [diff] [blame] | 99 | dontaudit dumpstate update_engine:binder call; |
Alistair Delva | 2bbf1ce | 2020-12-02 16:04:12 -0800 | [diff] [blame] | 100 | |
| 101 | # Read files in /proc |
| 102 | allow dumpstate { |
Steven Moreland | 832dc37 | 2023-12-21 01:22:13 +0000 | [diff] [blame] | 103 | config_gz |
Alistair Delva | 2bbf1ce | 2020-12-02 16:04:12 -0800 | [diff] [blame] | 104 | proc_net_tcp_udp |
| 105 | proc_pid_max |
| 106 | }:file r_file_perms; |
Joe Onorato | 5536a08 | 2018-12-07 17:20:14 -0800 | [diff] [blame] | 107 | |
| 108 | # For comminucating with the system process to do confirmation ui. |
| 109 | binder_call(dumpstate, incidentcompanion_service) |
David Anderson | dc2a787 | 2019-09-06 14:52:21 -0700 | [diff] [blame] | 110 | |
Inseob Kim | 55e5c9b | 2020-03-04 17:20:35 +0900 | [diff] [blame] | 111 | # Set properties. |
| 112 | # dumpstate_prop is used to share state with the Shell app. |
| 113 | set_prop(dumpstate, dumpstate_prop) |
| 114 | set_prop(dumpstate, exported_dumpstate_prop) |
| 115 | |
| 116 | # dumpstate_options_prop is used to pass extra command-line args. |
| 117 | set_prop(dumpstate, dumpstate_options_prop) |
| 118 | |
| 119 | # Allow dumpstate to kill vendor dumpstate service by init |
| 120 | set_prop(dumpstate, ctl_dumpstate_prop) |
| 121 | |
David Anderson | dc2a787 | 2019-09-06 14:52:21 -0700 | [diff] [blame] | 122 | # For dumping dynamic partition information. |
| 123 | set_prop(dumpstate, lpdumpd_prop) |
| 124 | binder_call(dumpstate, lpdumpd) |
David Anderson | 14eaa6c | 2019-09-09 17:52:06 -0700 | [diff] [blame] | 125 | |
Enrico Granata | 645c390 | 2021-10-01 13:11:36 -0600 | [diff] [blame] | 126 | # For dumping hypervisor information. |
| 127 | get_prop(dumpstate, hypervisor_prop) |
| 128 | |
David Anderson | 14eaa6c | 2019-09-09 17:52:06 -0700 | [diff] [blame] | 129 | # For dumping device-mapper and snapshot information. |
| 130 | allow dumpstate gsid_exec:file rx_file_perms; |
| 131 | set_prop(dumpstate, ctl_gsid_prop) |
| 132 | binder_call(dumpstate, gsid) |
Yifan Hong | 91709db | 2019-10-29 14:12:16 -0700 | [diff] [blame] | 133 | |
Devin Moore | 9645657 | 2024-01-31 17:48:43 +0000 | [diff] [blame] | 134 | #Allow access to /dev/binderfs/binder_logs |
Steven Moreland | 248f0e0 | 2024-05-17 22:30:40 +0000 | [diff] [blame] | 135 | userdebug_or_eng(` |
| 136 | allow dumpstate binderfs_logs_transactions:file r_file_perms; |
| 137 | ') |
Steven Moreland | 496f08d | 2024-06-03 19:30:04 +0000 | [diff] [blame] | 138 | dontaudit dumpstate binderfs_logs_transactions:file r_file_perms; |
Steven Moreland | 9956cdf | 2024-05-23 19:38:57 +0000 | [diff] [blame] | 139 | allow dumpstate binderfs_logs_transaction_history:file r_file_perms; |
Devin Moore | 9645657 | 2024-01-31 17:48:43 +0000 | [diff] [blame] | 140 | |
Yifan Hong | 91709db | 2019-10-29 14:12:16 -0700 | [diff] [blame] | 141 | r_dir_file(dumpstate, ota_metadata_file) |
Primiano Tucci | 2f99809 | 2021-01-07 17:12:21 +0000 | [diff] [blame] | 142 | |
| 143 | # For starting (and killing) perfetto --save-for-bugreport. If a labelled trace |
| 144 | # is being recorded, the command above will serialize it into |
| 145 | # /data/misc/perfetto-traces/bugreport/*.pftrace . |
| 146 | domain_auto_trans(dumpstate, perfetto_exec, perfetto) |
| 147 | allow dumpstate perfetto:process signal; |
| 148 | allow dumpstate perfetto_traces_data_file:dir { search }; |
| 149 | allow dumpstate perfetto_traces_bugreport_data_file:dir rw_dir_perms; |
| 150 | allow dumpstate perfetto_traces_bugreport_data_file:file { r_file_perms unlink }; |
| 151 | |
| 152 | # When exec-ing /system/bin/perfetto, dumpstates redirects stdio to /dev/null |
| 153 | # (which is labelled as dumpstate_tmpfs) to avoid leaking a FD to the bugreport |
| 154 | # zip file. These rules are to allow perfetto.te to inherit dumpstate's |
| 155 | # /dev/null. |
| 156 | allow perfetto dumpstate_tmpfs:file rw_file_perms; |
| 157 | allow perfetto dumpstate:fd use; |
Ramji Jiyani | 3b59a53 | 2022-03-11 21:21:57 +0000 | [diff] [blame] | 158 | |
| 159 | # system_dlkm_file for /system_dlkm partition |
| 160 | allow dumpstate system_dlkm_file:dir getattr; |
MƄrten Kongstad | 098e909 | 2022-09-20 14:19:30 +0200 | [diff] [blame] | 161 | |
| 162 | # Allow dumpstate to execute derive_sdk in its own domain |
| 163 | domain_auto_trans(dumpstate, derive_sdk_exec, derive_sdk) |
Inseob Kim | 75806ef | 2024-03-27 17:18:41 +0900 | [diff] [blame] | 164 | |
| 165 | net_domain(dumpstate) |
| 166 | binder_use(dumpstate) |
| 167 | wakelock_use(dumpstate) |
| 168 | |
| 169 | # Allow setting process priority, protect from OOM killer, and dropping |
| 170 | # privileges by switching UID / GID |
| 171 | allow dumpstate self:global_capability_class_set { setuid setgid sys_resource }; |
| 172 | |
| 173 | # Allow dumpstate to scan through /proc/pid for all processes |
| 174 | r_dir_file(dumpstate, domain) |
| 175 | |
| 176 | allow dumpstate self:global_capability_class_set { |
| 177 | # Send signals to processes |
| 178 | kill |
| 179 | # Run iptables |
| 180 | net_raw |
| 181 | net_admin |
| 182 | }; |
| 183 | |
| 184 | # Allow executing files on system, such as: |
| 185 | # /system/bin/toolbox |
| 186 | # /system/bin/logcat |
| 187 | # /system/bin/dumpsys |
| 188 | allow dumpstate system_file:file execute_no_trans; |
| 189 | not_full_treble(`allow dumpstate vendor_file:file execute_no_trans;') |
| 190 | allow dumpstate toolbox_exec:file rx_file_perms; |
| 191 | |
| 192 | # hidl searches for files in /system/lib(64)/hw/ |
| 193 | allow dumpstate system_file:dir r_dir_perms; |
| 194 | |
| 195 | # Create and write into /data/anr/ |
| 196 | allow dumpstate self:global_capability_class_set { dac_override dac_read_search chown fowner fsetid }; |
| 197 | allow dumpstate anr_data_file:dir rw_dir_perms; |
| 198 | allow dumpstate anr_data_file:file create_file_perms; |
| 199 | |
| 200 | # Allow reading /data/system/uiderrors.txt |
| 201 | # TODO: scope this down. |
| 202 | allow dumpstate system_data_file:file r_file_perms; |
| 203 | |
| 204 | # Allow dumpstate to append into apps' private files. |
ThiƩbaud Weksteen | 76f7261 | 2024-05-15 10:43:45 +1000 | [diff] [blame] | 205 | allow dumpstate app_data_file_type:file append; |
Inseob Kim | 75806ef | 2024-03-27 17:18:41 +0900 | [diff] [blame] | 206 | |
| 207 | # Read dmesg |
| 208 | allow dumpstate self:global_capability2_class_set syslog; |
| 209 | allow dumpstate kernel:system syslog_read; |
| 210 | |
| 211 | # Read /sys/fs/pstore/console-ramoops |
| 212 | allow dumpstate pstorefs:dir r_dir_perms; |
| 213 | allow dumpstate pstorefs:file r_file_perms; |
| 214 | |
| 215 | # Get process attributes |
| 216 | allow dumpstate domain:process getattr; |
| 217 | |
| 218 | # Signal java processes to dump their stack |
| 219 | allow dumpstate { appdomain system_server zygote app_zygote }:process signal; |
| 220 | |
| 221 | # Signal native processes to dump their stack. |
| 222 | allow dumpstate { |
| 223 | # This list comes from native_processes_to_dump in dumputils/dump_utils.c |
| 224 | audioserver |
| 225 | cameraserver |
| 226 | drmserver |
| 227 | inputflinger |
| 228 | mediadrmserver |
| 229 | mediaextractor |
| 230 | mediametrics |
| 231 | mediaserver |
| 232 | mediaswcodec |
| 233 | sdcardd |
| 234 | surfaceflinger |
| 235 | vold |
| 236 | |
| 237 | # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.c |
| 238 | evsmanagerd |
| 239 | hal_audio_server |
| 240 | hal_audiocontrol_server |
| 241 | hal_bluetooth_server |
| 242 | hal_broadcastradio_server |
| 243 | hal_camera_server |
| 244 | hal_codec2_server |
| 245 | hal_drm_server |
| 246 | hal_evs_server |
| 247 | hal_face_server |
| 248 | hal_fingerprint_server |
| 249 | hal_graphics_allocator_server |
| 250 | hal_graphics_composer_server |
| 251 | hal_health_server |
| 252 | hal_input_processor_server |
| 253 | hal_neuralnetworks_server |
| 254 | hal_omx_server |
| 255 | hal_power_server |
| 256 | hal_power_stats_server |
| 257 | hal_sensors_server |
| 258 | hal_thermal_server |
| 259 | hal_vehicle_server |
| 260 | hal_vr_server |
| 261 | system_suspend_server |
| 262 | }:process signal; |
| 263 | |
ThiƩbaud Weksteen | 4164a5a | 2024-06-13 12:04:53 +1000 | [diff] [blame] | 264 | # On userdebug, dumpstate may fork and execute a command as su. Make sure the |
| 265 | # timeout logic is allowed to terminate the child process if necessary. |
| 266 | userdebug_or_eng(` |
| 267 | allow dumpstate su:process { signal sigkill }; |
| 268 | ') |
| 269 | |
Inseob Kim | 75806ef | 2024-03-27 17:18:41 +0900 | [diff] [blame] | 270 | # Connect to tombstoned to intercept dumps. |
| 271 | unix_socket_connect(dumpstate, tombstoned_intercept, tombstoned) |
| 272 | |
| 273 | # Access to /sys |
| 274 | allow dumpstate sysfs_type:dir r_dir_perms; |
| 275 | |
| 276 | allow dumpstate { |
| 277 | sysfs_devices_block |
| 278 | sysfs_dm |
| 279 | sysfs_loop |
| 280 | sysfs_usb |
| 281 | sysfs_zram |
| 282 | }:file r_file_perms; |
| 283 | |
| 284 | # Ignore other file access under /sys. |
| 285 | dontaudit dumpstate sysfs:file r_file_perms; |
| 286 | |
| 287 | # Other random bits of data we want to collect |
| 288 | no_debugfs_restriction(` |
| 289 | allow dumpstate debugfs:file r_file_perms; |
| 290 | auditallow dumpstate debugfs:file r_file_perms; |
| 291 | |
| 292 | allow dumpstate debugfs_mmc:file r_file_perms; |
| 293 | ') |
| 294 | |
| 295 | # df for |
| 296 | allow dumpstate { |
| 297 | block_device |
| 298 | cache_file |
| 299 | metadata_file |
| 300 | rootfs |
| 301 | selinuxfs |
| 302 | storage_file |
| 303 | tmpfs |
| 304 | }:dir { search getattr }; |
| 305 | allow dumpstate fuse_device:chr_file getattr; |
| 306 | allow dumpstate { dm_device cache_block_device }:blk_file getattr; |
| 307 | allow dumpstate { cache_file rootfs }:lnk_file { getattr read }; |
| 308 | |
| 309 | # Read /dev/cpuctl and /dev/cpuset |
| 310 | r_dir_file(dumpstate, cgroup) |
| 311 | r_dir_file(dumpstate, cgroup_v2) |
| 312 | |
| 313 | # Allow dumpstate to make binder calls to any binder service |
| 314 | binder_call(dumpstate, binderservicedomain) |
| 315 | binder_call(dumpstate, { appdomain artd netd wificond }) |
| 316 | |
| 317 | # Allow dumpstate to call dump() on specific hals. |
| 318 | dump_hal(hal_audio) |
| 319 | dump_hal(hal_audiocontrol) |
| 320 | dump_hal(hal_authgraph) |
| 321 | dump_hal(hal_authsecret) |
| 322 | dump_hal(hal_bluetooth) |
| 323 | dump_hal(hal_broadcastradio) |
| 324 | dump_hal(hal_camera) |
| 325 | dump_hal(hal_codec2) |
| 326 | dump_hal(hal_contexthub) |
| 327 | dump_hal(hal_drm) |
| 328 | dump_hal(hal_dumpstate) |
| 329 | dump_hal(hal_evs) |
| 330 | dump_hal(hal_face) |
| 331 | dump_hal(hal_fingerprint) |
| 332 | dump_hal(hal_gnss) |
| 333 | dump_hal(hal_graphics_allocator) |
| 334 | dump_hal(hal_graphics_composer) |
| 335 | dump_hal(hal_health) |
| 336 | dump_hal(hal_identity) |
| 337 | dump_hal(hal_input_processor) |
| 338 | dump_hal(hal_keymint) |
| 339 | dump_hal(hal_light) |
| 340 | dump_hal(hal_memtrack) |
| 341 | dump_hal(hal_neuralnetworks) |
| 342 | dump_hal(hal_nfc) |
| 343 | dump_hal(hal_oemlock) |
| 344 | dump_hal(hal_power) |
| 345 | dump_hal(hal_power_stats) |
| 346 | dump_hal(hal_rebootescrow) |
| 347 | dump_hal(hal_secretkeeper) |
| 348 | dump_hal(hal_sensors) |
| 349 | dump_hal(hal_thermal) |
| 350 | dump_hal(hal_vehicle) |
| 351 | dump_hal(hal_weaver) |
| 352 | dump_hal(hal_wifi) |
| 353 | |
| 354 | # Vibrate the device after we are done collecting the bugreport |
| 355 | hal_client_domain(dumpstate, hal_vibrator) |
| 356 | |
| 357 | # Reading /proc/PID/maps of other processes |
| 358 | allow dumpstate self:global_capability_class_set sys_ptrace; |
| 359 | |
| 360 | # Allow the bugreport service to create a file in |
| 361 | # /data/data/com.android.shell/files/bugreports/bugreport |
| 362 | allow dumpstate shell_data_file:dir create_dir_perms; |
| 363 | allow dumpstate shell_data_file:file create_file_perms; |
| 364 | |
| 365 | # Run a shell. |
| 366 | allow dumpstate shell_exec:file rx_file_perms; |
| 367 | |
| 368 | # For running am and similar framework commands. |
| 369 | # Run /system/bin/app_process. |
| 370 | allow dumpstate zygote_exec:file rx_file_perms; |
| 371 | |
| 372 | # For Bluetooth |
| 373 | allow dumpstate bluetooth_data_file:dir search; |
| 374 | allow dumpstate bluetooth_logs_data_file:dir r_dir_perms; |
| 375 | allow dumpstate bluetooth_logs_data_file:file r_file_perms; |
| 376 | |
| 377 | # For Nfc |
| 378 | allow dumpstate nfc_logs_data_file:dir r_dir_perms; |
| 379 | allow dumpstate nfc_logs_data_file:file r_file_perms; |
| 380 | |
Nattharat Jariyanuntanaet | dd2e2ba | 2024-05-15 08:16:16 +0000 | [diff] [blame] | 381 | # For uwb |
| 382 | allow dumpstate apex_module_data_file:dir search; |
| 383 | allow dumpstate apex_system_server_data_file:dir search; |
| 384 | allow dumpstate apex_uwb_data_file:dir r_dir_perms; |
| 385 | allow dumpstate apex_uwb_data_file:file r_file_perms; |
| 386 | |
Inseob Kim | 75806ef | 2024-03-27 17:18:41 +0900 | [diff] [blame] | 387 | # Dumpstate calls screencap, which grabs a screenshot. Needs gpu access |
| 388 | allow dumpstate gpu_device:chr_file rw_file_perms; |
| 389 | allow dumpstate gpu_device:dir r_dir_perms; |
| 390 | |
| 391 | # logd access |
| 392 | read_logd(dumpstate) |
| 393 | control_logd(dumpstate) |
| 394 | read_runtime_log_tags(dumpstate) |
| 395 | |
| 396 | # Read files in /proc |
| 397 | allow dumpstate { |
| 398 | proc_bootconfig |
| 399 | proc_buddyinfo |
| 400 | proc_cmdline |
| 401 | proc_meminfo |
| 402 | proc_modules |
| 403 | proc_net_type |
| 404 | proc_pipe_conf |
| 405 | proc_pagetypeinfo |
Bart Sears | dbca625 | 2024-08-04 23:06:24 +0000 | [diff] [blame] | 406 | proc_qtaguid_ctrl |
| 407 | proc_qtaguid_stat |
Inseob Kim | 75806ef | 2024-03-27 17:18:41 +0900 | [diff] [blame] | 408 | proc_slabinfo |
| 409 | proc_version |
| 410 | proc_vmallocinfo |
| 411 | proc_vmstat |
| 412 | }:file r_file_perms; |
| 413 | |
| 414 | # Read network state info files. |
| 415 | allow dumpstate net_data_file:dir search; |
| 416 | allow dumpstate net_data_file:file r_file_perms; |
| 417 | |
| 418 | # List sockets via ss. |
ThiƩbaud Weksteen | 67c1b35 | 2024-10-18 14:27:13 +1100 | [diff] [blame] | 419 | allow dumpstate self:netlink_tcpdiag_socket create_socket_perms_no_ioctl; |
| 420 | # For kernel < 6.13 |
| 421 | allow dumpstate self:netlink_tcpdiag_socket nlmsg_read; |
| 422 | # For kernel >= 6.13 |
| 423 | allow dumpstate self:netlink_tcpdiag_socket nlmsg; |
| 424 | allowxperm dumpstate self:netlink_tcpdiag_socket nlmsg SOCK_DIAG_BY_FAMILY; |
Inseob Kim | 75806ef | 2024-03-27 17:18:41 +0900 | [diff] [blame] | 425 | |
| 426 | # Access /data/tombstones. |
| 427 | allow dumpstate tombstone_data_file:dir r_dir_perms; |
| 428 | allow dumpstate tombstone_data_file:file r_file_perms; |
| 429 | |
| 430 | # Access /cache/recovery |
| 431 | allow dumpstate cache_recovery_file:dir r_dir_perms; |
| 432 | allow dumpstate cache_recovery_file:file r_file_perms; |
| 433 | |
| 434 | # Access /data/misc/recovery |
| 435 | allow dumpstate recovery_data_file:dir r_dir_perms; |
| 436 | allow dumpstate recovery_data_file:file r_file_perms; |
| 437 | |
| 438 | # Access /data/misc/update_engine & /data/misc/update_engine_log |
| 439 | allow dumpstate { update_engine_data_file update_engine_log_data_file }:dir r_dir_perms; |
| 440 | allow dumpstate { update_engine_data_file update_engine_log_data_file }:file r_file_perms; |
| 441 | # Access /data/misc/snapuserd_log |
| 442 | allow dumpstate snapuserd_log_data_file:dir r_dir_perms; |
| 443 | allow dumpstate snapuserd_log_data_file:file r_file_perms; |
| 444 | |
| 445 | # Access /data/misc/profiles/{cur,ref}/ |
| 446 | userdebug_or_eng(` |
| 447 | allow dumpstate { user_profile_root_file user_profile_data_file}:dir r_dir_perms; |
| 448 | allow dumpstate user_profile_data_file:file r_file_perms; |
| 449 | ') |
| 450 | |
| 451 | # Access /data/misc/logd |
| 452 | allow dumpstate misc_logd_file:dir r_dir_perms; |
| 453 | allow dumpstate misc_logd_file:file r_file_perms; |
| 454 | |
| 455 | # Access /data/misc/prereboot |
| 456 | allow dumpstate prereboot_data_file:dir r_dir_perms; |
| 457 | allow dumpstate prereboot_data_file:file r_file_perms; |
| 458 | |
| 459 | allow dumpstate app_fuse_file:dir r_dir_perms; |
| 460 | allow dumpstate overlayfs_file:dir r_dir_perms; |
| 461 | |
| 462 | allow dumpstate { |
| 463 | service_manager_type |
| 464 | -apex_service |
| 465 | -dumpstate_service |
| 466 | -gatekeeper_service |
| 467 | -hal_service_type |
| 468 | -virtual_touchpad_service |
| 469 | -vold_service |
| 470 | -default_android_service |
| 471 | }:service_manager find; |
| 472 | # suppress denials for services dumpstate should not be accessing. |
| 473 | dontaudit dumpstate { |
| 474 | apex_service |
| 475 | dumpstate_service |
| 476 | gatekeeper_service |
| 477 | hal_service_type |
| 478 | virtual_touchpad_service |
| 479 | vold_service |
| 480 | }:service_manager find; |
| 481 | |
| 482 | # Most of these are neverallowed. |
| 483 | dontaudit dumpstate hwservice_manager_type:hwservice_manager find; |
| 484 | |
| 485 | allow dumpstate servicemanager:service_manager list; |
| 486 | allow dumpstate hwservicemanager:hwservice_manager list; |
| 487 | |
| 488 | allow dumpstate devpts:chr_file rw_file_perms; |
| 489 | |
| 490 | # Read any system properties |
| 491 | get_prop(dumpstate, property_type) |
| 492 | |
| 493 | # Access to /data/media. |
| 494 | # This should be removed if sdcardfs is modified to alter the secontext for its |
| 495 | # accesses to the underlying FS. |
| 496 | allow dumpstate media_rw_data_file:dir getattr; |
| 497 | allow dumpstate proc_interrupts:file r_file_perms; |
| 498 | allow dumpstate proc_zoneinfo:file r_file_perms; |
| 499 | |
| 500 | # Create a service for talking back to system_server |
| 501 | add_service(dumpstate, dumpstate_service) |
| 502 | |
| 503 | # use /dev/ion for screen capture |
| 504 | allow dumpstate ion_device:chr_file r_file_perms; |
| 505 | |
| 506 | # Allow dumpstate to run top |
| 507 | allow dumpstate proc_stat:file r_file_perms; |
| 508 | |
| 509 | allow dumpstate proc_pressure_cpu:file r_file_perms; |
| 510 | allow dumpstate proc_pressure_mem:file r_file_perms; |
| 511 | allow dumpstate proc_pressure_io:file r_file_perms; |
| 512 | |
| 513 | # Allow dumpstate to run ps |
| 514 | allow dumpstate proc_pid_max:file r_file_perms; |
| 515 | |
| 516 | # Allow dumpstate to talk to installd over binder |
| 517 | binder_call(dumpstate, installd); |
| 518 | |
| 519 | # Allow dumpstate to run ip xfrm policy |
Bo Hu | b55aaff | 2024-12-01 21:14:32 +0000 | [diff] [blame^] | 520 | allow dumpstate self:netlink_xfrm_socket { create_socket_perms_no_ioctl nlmsg_read }; |
Inseob Kim | 75806ef | 2024-03-27 17:18:41 +0900 | [diff] [blame] | 521 | |
| 522 | # Allow dumpstate to run iotop |
| 523 | allow dumpstate self:netlink_socket create_socket_perms_no_ioctl; |
| 524 | # newer kernels (e.g. 4.4) have a new class for sockets |
| 525 | allow dumpstate self:netlink_generic_socket create_socket_perms_no_ioctl; |
| 526 | |
| 527 | # Allow dumpstate to run ss |
| 528 | allow dumpstate { domain pdx_channel_socket_type pdx_endpoint_socket_type }:socket_class_set getattr; |
| 529 | |
| 530 | # Allow dumpstate to read linkerconfig directory |
| 531 | allow dumpstate linkerconfig_file:dir { read open }; |
| 532 | |
| 533 | # For when dumpstate runs df |
| 534 | dontaudit dumpstate { |
| 535 | mnt_vendor_file |
| 536 | mirror_data_file |
| 537 | mnt_user_file |
| 538 | mnt_product_file |
| 539 | }:dir search; |
| 540 | dontaudit dumpstate { |
| 541 | apex_mnt_dir |
| 542 | linkerconfig_file |
| 543 | mirror_data_file |
| 544 | mnt_user_file |
Inseob Kim | 0b9625d | 2024-07-31 17:42:23 +0900 | [diff] [blame] | 545 | vm_data_file |
Inseob Kim | 75806ef | 2024-03-27 17:18:41 +0900 | [diff] [blame] | 546 | }:dir getattr; |
| 547 | |
| 548 | # Allow dumpstate to talk to bufferhubd over binder |
| 549 | binder_call(dumpstate, bufferhubd); |
| 550 | |
| 551 | # Allow dumpstate to talk to mediaswcodec over binder |
| 552 | binder_call(dumpstate, mediaswcodec); |
| 553 | |
| 554 | #Access /data/misc/snapshotctl_log |
| 555 | allow dumpstate snapshotctl_log_data_file:dir r_dir_perms; |
| 556 | allow dumpstate snapshotctl_log_data_file:file r_file_perms; |
| 557 | |
| 558 | #Allow access to /dev/binderfs/binder_logs |
| 559 | allow dumpstate binderfs_logs:dir r_dir_perms; |
| 560 | allow dumpstate binderfs_logs:file r_file_perms; |
| 561 | allow dumpstate binderfs_logs_proc:file r_file_perms; |
| 562 | allow dumpstate binderfs_logs_stats:file r_file_perms; |
| 563 | |
| 564 | use_apex_info(dumpstate) |
| 565 | |
| 566 | # Allow reading files under /data/system/shutdown-checkpoints/ |
| 567 | allow dumpstate shutdown_checkpoints_system_data_file:dir r_dir_perms; |
| 568 | allow dumpstate shutdown_checkpoints_system_data_file:file r_file_perms; |
| 569 | |
| 570 | ### |
| 571 | ### neverallow rules |
| 572 | ### |
| 573 | |
| 574 | # dumpstate has capability sys_ptrace, but should only use that capability for |
| 575 | # accessing sensitive /proc/PID files, never for using ptrace attach. |
| 576 | neverallow dumpstate *:process ptrace; |
| 577 | |
| 578 | # only system_server, dumpstate, traceur_app and shell can find the dumpstate service |
| 579 | neverallow { |
| 580 | domain |
| 581 | -system_server |
| 582 | -shell |
| 583 | -traceur_app |
| 584 | -dumpstate |
| 585 | } dumpstate_service:service_manager find; |
Nattharat Jariyanuntanaet | dd2e2ba | 2024-05-15 08:16:16 +0000 | [diff] [blame] | 586 | |
| 587 | # only dumpstate, system_server and related others to access apex_uwb_data_file |
| 588 | neverallow { |
| 589 | domain |
| 590 | -dumpstate |
| 591 | -system_server |
| 592 | -apexd |
| 593 | -init |
| 594 | -vold_prepare_subdirs |
| 595 | } apex_uwb_data_file:dir no_rw_file_perms; |
| 596 | neverallow { |
| 597 | domain |
| 598 | -dumpstate |
| 599 | -system_server |
| 600 | -apexd |
| 601 | -init |
| 602 | -vold_prepare_subdirs |
| 603 | } apex_uwb_data_file:file no_rw_file_perms; |