blob: 7f91651f2720a5bca32ba73c49d4a490c6d12ecb [file] [log] [blame]
Alex Klyubinf5446eb2017-03-23 14:27:32 -07001typeattribute dumpstate coredomain;
Primiano Tucci2f998092021-01-07 17:12:21 +00002type dumpstate_tmpfs, file_type;
Alex Klyubinf5446eb2017-03-23 14:27:32 -07003
dcashmancc39f632016-07-22 13:13:11 -07004init_daemon_domain(dumpstate)
5
6# Execute and transition to the vdc domain
7domain_auto_trans(dumpstate, vdc_exec, vdc)
dcashman2e00e632016-10-12 14:58:09 -07008
Chris Morin1d88bf52022-02-12 13:52:39 -08009# Create tmpfs files for using memfd descriptors to get output from child
10# processes.
11tmpfs_domain(dumpstate)
12
Joel Scherpelz5e901bb2017-04-25 11:53:51 +090013# Acquire advisory lock on /system/etc/xtables.lock from ip[6]tables
14allow dumpstate system_file:file lock;
15
ynwange68d2d22016-07-01 12:18:54 -070016allow dumpstate storaged_exec:file rx_file_perms;
17
Hongming Jin58f83412021-02-09 12:03:40 -080018# /data/misc/a11ytrace for accessibility traces
19userdebug_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 Nair2d6942d2017-11-17 08:23:32 -080024# /data/misc/wmtrace for wm traces
25userdebug_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 Sharkeyef5e5c82023-02-06 14:25:48 -070030# /data/system/dropbox for dropbox entries
31userdebug_or_eng(`
32 allow dumpstate dropbox_data_file:dir r_dir_perms;
33 allow dumpstate dropbox_data_file:file r_file_perms;
34')
35
Mike Made3a3e42018-12-03 10:35:40 -080036# Allow dumpstate to make binder calls to incidentd
37binder_call(dumpstate, incidentd)
38
ThiƩbaud Weksteen3b1c8432023-01-04 12:57:11 +110039# Kill incident in case of a timeout
40allow dumpstate incident:process { signal sigkill };
41
ynwange68d2d22016-07-01 12:18:54 -070042# Allow dumpstate to make binder calls to storaged service
43binder_call(dumpstate, storaged)
Keun-young Park43e8fae2017-03-03 13:13:25 -080044
Yao Chenb10ff332018-01-17 16:17:28 -080045# Allow dumpstate to make binder calls to statsd
46binder_call(dumpstate, statsd)
47
Joel Galenson7c275a62018-11-13 12:35:17 -080048# Allow dumpstate to talk to gpuservice over binder
49binder_call(dumpstate, gpuservice);
50
Joel Galenson657470a2018-12-05 11:01:04 -080051# Allow dumpstate to talk to idmap over binder
52binder_call(dumpstate, idmap);
53
Alex Hong906c7242020-11-10 14:12:38 +080054# Allow dumpstate to talk to profcollectd over binder
55userdebug_or_eng(`
56 binder_call(dumpstate, profcollectd)
57')
58
Changyeon Jo152a2f12023-09-26 18:44:35 +000059# Allow dumpstate to talk to automotive_display_service over binder
60binder_call(dumpstate, automotive_display_service)
61
Jan Sebechlebskyde644172023-11-30 10:57:16 +010062# Allow dumpstate to talk to virtual_camera service over binder
63binder_call(dumpstate, virtual_camera)
64
Kangping Donge1ee7682023-12-01 13:02:38 +080065# Allow dumpstate to talk to ot_daemon service over binder
66binder_call(dumpstate, ot_daemon)
67
Keun-young Park43e8fae2017-03-03 13:13:25 -080068# Collect metrics on boot time created by init
69get_prop(dumpstate, boottime_prop)
Andreas Gampe7468db62018-01-24 17:56:25 -080070
Steven Moreland9f41fc02024-02-16 22:38:26 +000071get_prop(dumpstate, misctrl_prop)
72
Andreas Gampe7468db62018-01-24 17:56:25 -080073# Signal native processes to dump their stack.
74allow dumpstate {
Chong Zhang81f5b9f2020-10-15 12:38:30 -070075 mediatranscoding
Andreas Gampe7468db62018-01-24 17:56:25 -080076 statsd
Chalard Jeana4c9f7b2019-04-05 17:33:56 +090077 netd
Jan Sebechlebskyde644172023-11-30 10:57:16 +010078 virtual_camera
Kangping Donge1ee7682023-12-01 13:02:38 +080079 ot_daemon
Andreas Gampe7468db62018-01-24 17:56:25 -080080}:process signal;
Joel Galenson03ff9f92018-02-14 14:32:38 -080081
David Drysdalee1075f72023-03-17 12:21:32 +000082# Only allow dumpstate to dump Keystore on debuggable builds.
Eric Biggersf9519a62021-05-04 20:59:32 -070083userdebug_or_eng(`
84 allow dumpstate keystore:process signal;
85')
David Drysdalee1075f72023-03-17 12:21:32 +000086dontaudit dumpstate keystore:process { signal };
Eric Biggersf9519a62021-05-04 20:59:32 -070087
Joel Galenson03ff9f92018-02-14 14:32:38 -080088# For collecting bugreports.
Hridya Valsaraju23f9f512021-05-04 22:01:51 -070089no_debugfs_restriction(`
90 allow dumpstate debugfs_wakeup_sources:file r_file_perms;
91')
92
Joel Galenson03ff9f92018-02-14 14:32:38 -080093allow dumpstate dev_type:blk_file getattr;
94allow dumpstate webview_zygote:process signal;
Hridya Valsaraju6217b662021-01-10 21:09:37 -080095allow dumpstate sysfs_dmabuf_stats:file r_file_perms;
Joel Galenson03ff9f92018-02-14 14:32:38 -080096dontaudit dumpstate update_engine:binder call;
Alistair Delva2bbf1ce2020-12-02 16:04:12 -080097
98# Read files in /proc
99allow dumpstate {
Steven Moreland832dc372023-12-21 01:22:13 +0000100 config_gz
Alistair Delva2bbf1ce2020-12-02 16:04:12 -0800101 proc_net_tcp_udp
102 proc_pid_max
103}:file r_file_perms;
Joe Onorato5536a082018-12-07 17:20:14 -0800104
105# For comminucating with the system process to do confirmation ui.
106binder_call(dumpstate, incidentcompanion_service)
David Andersondc2a7872019-09-06 14:52:21 -0700107
Inseob Kim55e5c9b2020-03-04 17:20:35 +0900108# Set properties.
109# dumpstate_prop is used to share state with the Shell app.
110set_prop(dumpstate, dumpstate_prop)
111set_prop(dumpstate, exported_dumpstate_prop)
112
113# dumpstate_options_prop is used to pass extra command-line args.
114set_prop(dumpstate, dumpstate_options_prop)
115
116# Allow dumpstate to kill vendor dumpstate service by init
117set_prop(dumpstate, ctl_dumpstate_prop)
118
David Andersondc2a7872019-09-06 14:52:21 -0700119# For dumping dynamic partition information.
120set_prop(dumpstate, lpdumpd_prop)
121binder_call(dumpstate, lpdumpd)
David Anderson14eaa6c2019-09-09 17:52:06 -0700122
Enrico Granata645c3902021-10-01 13:11:36 -0600123# For dumping hypervisor information.
124get_prop(dumpstate, hypervisor_prop)
125
David Anderson14eaa6c2019-09-09 17:52:06 -0700126# For dumping device-mapper and snapshot information.
127allow dumpstate gsid_exec:file rx_file_perms;
128set_prop(dumpstate, ctl_gsid_prop)
129binder_call(dumpstate, gsid)
Yifan Hong91709db2019-10-29 14:12:16 -0700130
131r_dir_file(dumpstate, ota_metadata_file)
Primiano Tucci2f998092021-01-07 17:12:21 +0000132
133# For starting (and killing) perfetto --save-for-bugreport. If a labelled trace
134# is being recorded, the command above will serialize it into
135# /data/misc/perfetto-traces/bugreport/*.pftrace .
136domain_auto_trans(dumpstate, perfetto_exec, perfetto)
137allow dumpstate perfetto:process signal;
138allow dumpstate perfetto_traces_data_file:dir { search };
139allow dumpstate perfetto_traces_bugreport_data_file:dir rw_dir_perms;
140allow dumpstate perfetto_traces_bugreport_data_file:file { r_file_perms unlink };
141
142# When exec-ing /system/bin/perfetto, dumpstates redirects stdio to /dev/null
143# (which is labelled as dumpstate_tmpfs) to avoid leaking a FD to the bugreport
144# zip file. These rules are to allow perfetto.te to inherit dumpstate's
145# /dev/null.
146allow perfetto dumpstate_tmpfs:file rw_file_perms;
147allow perfetto dumpstate:fd use;
Ramji Jiyani3b59a532022-03-11 21:21:57 +0000148
149# system_dlkm_file for /system_dlkm partition
150allow dumpstate system_dlkm_file:dir getattr;
MƄrten Kongstad098e9092022-09-20 14:19:30 +0200151
152# Allow dumpstate to execute derive_sdk in its own domain
153domain_auto_trans(dumpstate, derive_sdk_exec, derive_sdk)
Inseob Kim75806ef2024-03-27 17:18:41 +0900154
155net_domain(dumpstate)
156binder_use(dumpstate)
157wakelock_use(dumpstate)
158
159# Allow setting process priority, protect from OOM killer, and dropping
160# privileges by switching UID / GID
161allow dumpstate self:global_capability_class_set { setuid setgid sys_resource };
162
163# Allow dumpstate to scan through /proc/pid for all processes
164r_dir_file(dumpstate, domain)
165
166allow dumpstate self:global_capability_class_set {
167 # Send signals to processes
168 kill
169 # Run iptables
170 net_raw
171 net_admin
172};
173
174# Allow executing files on system, such as:
175# /system/bin/toolbox
176# /system/bin/logcat
177# /system/bin/dumpsys
178allow dumpstate system_file:file execute_no_trans;
179not_full_treble(`allow dumpstate vendor_file:file execute_no_trans;')
180allow dumpstate toolbox_exec:file rx_file_perms;
181
182# hidl searches for files in /system/lib(64)/hw/
183allow dumpstate system_file:dir r_dir_perms;
184
185# Create and write into /data/anr/
186allow dumpstate self:global_capability_class_set { dac_override dac_read_search chown fowner fsetid };
187allow dumpstate anr_data_file:dir rw_dir_perms;
188allow dumpstate anr_data_file:file create_file_perms;
189
190# Allow reading /data/system/uiderrors.txt
191# TODO: scope this down.
192allow dumpstate system_data_file:file r_file_perms;
193
194# Allow dumpstate to append into apps' private files.
195allow dumpstate { privapp_data_file app_data_file }:file append;
196
197# Read dmesg
198allow dumpstate self:global_capability2_class_set syslog;
199allow dumpstate kernel:system syslog_read;
200
201# Read /sys/fs/pstore/console-ramoops
202allow dumpstate pstorefs:dir r_dir_perms;
203allow dumpstate pstorefs:file r_file_perms;
204
205# Get process attributes
206allow dumpstate domain:process getattr;
207
208# Signal java processes to dump their stack
209allow dumpstate { appdomain system_server zygote app_zygote }:process signal;
210
211# Signal native processes to dump their stack.
212allow dumpstate {
213 # This list comes from native_processes_to_dump in dumputils/dump_utils.c
214 audioserver
215 cameraserver
216 drmserver
217 inputflinger
218 mediadrmserver
219 mediaextractor
220 mediametrics
221 mediaserver
222 mediaswcodec
223 sdcardd
224 surfaceflinger
225 vold
226
227 # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.c
228 evsmanagerd
229 hal_audio_server
230 hal_audiocontrol_server
231 hal_bluetooth_server
232 hal_broadcastradio_server
233 hal_camera_server
234 hal_codec2_server
235 hal_drm_server
236 hal_evs_server
237 hal_face_server
238 hal_fingerprint_server
239 hal_graphics_allocator_server
240 hal_graphics_composer_server
241 hal_health_server
242 hal_input_processor_server
243 hal_neuralnetworks_server
244 hal_omx_server
245 hal_power_server
246 hal_power_stats_server
247 hal_sensors_server
248 hal_thermal_server
249 hal_vehicle_server
250 hal_vr_server
251 system_suspend_server
252}:process signal;
253
254# Connect to tombstoned to intercept dumps.
255unix_socket_connect(dumpstate, tombstoned_intercept, tombstoned)
256
257# Access to /sys
258allow dumpstate sysfs_type:dir r_dir_perms;
259
260allow dumpstate {
261 sysfs_devices_block
262 sysfs_dm
263 sysfs_loop
264 sysfs_usb
265 sysfs_zram
266}:file r_file_perms;
267
268# Ignore other file access under /sys.
269dontaudit dumpstate sysfs:file r_file_perms;
270
271# Other random bits of data we want to collect
272no_debugfs_restriction(`
273 allow dumpstate debugfs:file r_file_perms;
274 auditallow dumpstate debugfs:file r_file_perms;
275
276 allow dumpstate debugfs_mmc:file r_file_perms;
277')
278
279# df for
280allow dumpstate {
281 block_device
282 cache_file
283 metadata_file
284 rootfs
285 selinuxfs
286 storage_file
287 tmpfs
288}:dir { search getattr };
289allow dumpstate fuse_device:chr_file getattr;
290allow dumpstate { dm_device cache_block_device }:blk_file getattr;
291allow dumpstate { cache_file rootfs }:lnk_file { getattr read };
292
293# Read /dev/cpuctl and /dev/cpuset
294r_dir_file(dumpstate, cgroup)
295r_dir_file(dumpstate, cgroup_v2)
296
297# Allow dumpstate to make binder calls to any binder service
298binder_call(dumpstate, binderservicedomain)
299binder_call(dumpstate, { appdomain artd netd wificond })
300
301# Allow dumpstate to call dump() on specific hals.
302dump_hal(hal_audio)
303dump_hal(hal_audiocontrol)
304dump_hal(hal_authgraph)
305dump_hal(hal_authsecret)
306dump_hal(hal_bluetooth)
307dump_hal(hal_broadcastradio)
308dump_hal(hal_camera)
309dump_hal(hal_codec2)
310dump_hal(hal_contexthub)
311dump_hal(hal_drm)
312dump_hal(hal_dumpstate)
313dump_hal(hal_evs)
314dump_hal(hal_face)
315dump_hal(hal_fingerprint)
316dump_hal(hal_gnss)
317dump_hal(hal_graphics_allocator)
318dump_hal(hal_graphics_composer)
319dump_hal(hal_health)
320dump_hal(hal_identity)
321dump_hal(hal_input_processor)
322dump_hal(hal_keymint)
323dump_hal(hal_light)
324dump_hal(hal_memtrack)
325dump_hal(hal_neuralnetworks)
326dump_hal(hal_nfc)
327dump_hal(hal_oemlock)
328dump_hal(hal_power)
329dump_hal(hal_power_stats)
330dump_hal(hal_rebootescrow)
331dump_hal(hal_secretkeeper)
332dump_hal(hal_sensors)
333dump_hal(hal_thermal)
334dump_hal(hal_vehicle)
335dump_hal(hal_weaver)
336dump_hal(hal_wifi)
337
338# Vibrate the device after we are done collecting the bugreport
339hal_client_domain(dumpstate, hal_vibrator)
340
341# Reading /proc/PID/maps of other processes
342allow dumpstate self:global_capability_class_set sys_ptrace;
343
344# Allow the bugreport service to create a file in
345# /data/data/com.android.shell/files/bugreports/bugreport
346allow dumpstate shell_data_file:dir create_dir_perms;
347allow dumpstate shell_data_file:file create_file_perms;
348
349# Run a shell.
350allow dumpstate shell_exec:file rx_file_perms;
351
352# For running am and similar framework commands.
353# Run /system/bin/app_process.
354allow dumpstate zygote_exec:file rx_file_perms;
355
356# For Bluetooth
357allow dumpstate bluetooth_data_file:dir search;
358allow dumpstate bluetooth_logs_data_file:dir r_dir_perms;
359allow dumpstate bluetooth_logs_data_file:file r_file_perms;
360
361# For Nfc
362allow dumpstate nfc_logs_data_file:dir r_dir_perms;
363allow dumpstate nfc_logs_data_file:file r_file_perms;
364
365# Dumpstate calls screencap, which grabs a screenshot. Needs gpu access
366allow dumpstate gpu_device:chr_file rw_file_perms;
367allow dumpstate gpu_device:dir r_dir_perms;
368
369# logd access
370read_logd(dumpstate)
371control_logd(dumpstate)
372read_runtime_log_tags(dumpstate)
373
374# Read files in /proc
375allow dumpstate {
376 proc_bootconfig
377 proc_buddyinfo
378 proc_cmdline
379 proc_meminfo
380 proc_modules
381 proc_net_type
382 proc_pipe_conf
383 proc_pagetypeinfo
384 proc_qtaguid_ctrl
385 proc_qtaguid_stat
386 proc_slabinfo
387 proc_version
388 proc_vmallocinfo
389 proc_vmstat
390}:file r_file_perms;
391
392# Read network state info files.
393allow dumpstate net_data_file:dir search;
394allow dumpstate net_data_file:file r_file_perms;
395
396# List sockets via ss.
397allow dumpstate self:netlink_tcpdiag_socket { create_socket_perms_no_ioctl nlmsg_read };
398
399# Access /data/tombstones.
400allow dumpstate tombstone_data_file:dir r_dir_perms;
401allow dumpstate tombstone_data_file:file r_file_perms;
402
403# Access /cache/recovery
404allow dumpstate cache_recovery_file:dir r_dir_perms;
405allow dumpstate cache_recovery_file:file r_file_perms;
406
407# Access /data/misc/recovery
408allow dumpstate recovery_data_file:dir r_dir_perms;
409allow dumpstate recovery_data_file:file r_file_perms;
410
411# Access /data/misc/update_engine & /data/misc/update_engine_log
412allow dumpstate { update_engine_data_file update_engine_log_data_file }:dir r_dir_perms;
413allow dumpstate { update_engine_data_file update_engine_log_data_file }:file r_file_perms;
414# Access /data/misc/snapuserd_log
415allow dumpstate snapuserd_log_data_file:dir r_dir_perms;
416allow dumpstate snapuserd_log_data_file:file r_file_perms;
417
418# Access /data/misc/profiles/{cur,ref}/
419userdebug_or_eng(`
420 allow dumpstate { user_profile_root_file user_profile_data_file}:dir r_dir_perms;
421 allow dumpstate user_profile_data_file:file r_file_perms;
422')
423
424# Access /data/misc/logd
425allow dumpstate misc_logd_file:dir r_dir_perms;
426allow dumpstate misc_logd_file:file r_file_perms;
427
428# Access /data/misc/prereboot
429allow dumpstate prereboot_data_file:dir r_dir_perms;
430allow dumpstate prereboot_data_file:file r_file_perms;
431
432allow dumpstate app_fuse_file:dir r_dir_perms;
433allow dumpstate overlayfs_file:dir r_dir_perms;
434
435allow dumpstate {
436 service_manager_type
437 -apex_service
438 -dumpstate_service
439 -gatekeeper_service
440 -hal_service_type
441 -virtual_touchpad_service
442 -vold_service
443 -default_android_service
444}:service_manager find;
445# suppress denials for services dumpstate should not be accessing.
446dontaudit dumpstate {
447 apex_service
448 dumpstate_service
449 gatekeeper_service
450 hal_service_type
451 virtual_touchpad_service
452 vold_service
453}:service_manager find;
454
455# Most of these are neverallowed.
456dontaudit dumpstate hwservice_manager_type:hwservice_manager find;
457
458allow dumpstate servicemanager:service_manager list;
459allow dumpstate hwservicemanager:hwservice_manager list;
460
461allow dumpstate devpts:chr_file rw_file_perms;
462
463# Read any system properties
464get_prop(dumpstate, property_type)
465
466# Access to /data/media.
467# This should be removed if sdcardfs is modified to alter the secontext for its
468# accesses to the underlying FS.
469allow dumpstate media_rw_data_file:dir getattr;
470allow dumpstate proc_interrupts:file r_file_perms;
471allow dumpstate proc_zoneinfo:file r_file_perms;
472
473# Create a service for talking back to system_server
474add_service(dumpstate, dumpstate_service)
475
476# use /dev/ion for screen capture
477allow dumpstate ion_device:chr_file r_file_perms;
478
479# Allow dumpstate to run top
480allow dumpstate proc_stat:file r_file_perms;
481
482allow dumpstate proc_pressure_cpu:file r_file_perms;
483allow dumpstate proc_pressure_mem:file r_file_perms;
484allow dumpstate proc_pressure_io:file r_file_perms;
485
486# Allow dumpstate to run ps
487allow dumpstate proc_pid_max:file r_file_perms;
488
489# Allow dumpstate to talk to installd over binder
490binder_call(dumpstate, installd);
491
492# Allow dumpstate to run ip xfrm policy
493allow dumpstate self:netlink_xfrm_socket { create_socket_perms_no_ioctl nlmsg_read };
494
495# Allow dumpstate to run iotop
496allow dumpstate self:netlink_socket create_socket_perms_no_ioctl;
497# newer kernels (e.g. 4.4) have a new class for sockets
498allow dumpstate self:netlink_generic_socket create_socket_perms_no_ioctl;
499
500# Allow dumpstate to run ss
501allow dumpstate { domain pdx_channel_socket_type pdx_endpoint_socket_type }:socket_class_set getattr;
502
503# Allow dumpstate to read linkerconfig directory
504allow dumpstate linkerconfig_file:dir { read open };
505
506# For when dumpstate runs df
507dontaudit dumpstate {
508 mnt_vendor_file
509 mirror_data_file
510 mnt_user_file
511 mnt_product_file
512}:dir search;
513dontaudit dumpstate {
514 apex_mnt_dir
515 linkerconfig_file
516 mirror_data_file
517 mnt_user_file
518}:dir getattr;
519
520# Allow dumpstate to talk to bufferhubd over binder
521binder_call(dumpstate, bufferhubd);
522
523# Allow dumpstate to talk to mediaswcodec over binder
524binder_call(dumpstate, mediaswcodec);
525
526#Access /data/misc/snapshotctl_log
527allow dumpstate snapshotctl_log_data_file:dir r_dir_perms;
528allow dumpstate snapshotctl_log_data_file:file r_file_perms;
529
530#Allow access to /dev/binderfs/binder_logs
531allow dumpstate binderfs_logs:dir r_dir_perms;
532allow dumpstate binderfs_logs:file r_file_perms;
533allow dumpstate binderfs_logs_proc:file r_file_perms;
534allow dumpstate binderfs_logs_stats:file r_file_perms;
535
536use_apex_info(dumpstate)
537
538# Allow reading files under /data/system/shutdown-checkpoints/
539allow dumpstate shutdown_checkpoints_system_data_file:dir r_dir_perms;
540allow dumpstate shutdown_checkpoints_system_data_file:file r_file_perms;
541
542###
543### neverallow rules
544###
545
546# dumpstate has capability sys_ptrace, but should only use that capability for
547# accessing sensitive /proc/PID files, never for using ptrace attach.
548neverallow dumpstate *:process ptrace;
549
550# only system_server, dumpstate, traceur_app and shell can find the dumpstate service
551neverallow {
552 domain
553 -system_server
554 -shell
555 -traceur_app
556 -dumpstate
557} dumpstate_service:service_manager find;