1# dumpstate 2type dumpstate, domain, mlstrustedsubject; 3type dumpstate_exec, exec_type, file_type; 4 5init_daemon_domain(dumpstate) 6net_domain(dumpstate) 7binder_use(dumpstate) 8 9# Allow setting process priority, protect from OOM killer, and dropping 10# privileges by switching UID / GID 11allow dumpstate self:capability { setuid setgid sys_resource }; 12 13# Allow dumpstate to scan through /proc/pid for all processes 14r_dir_file(dumpstate, domain) 15 16# Send signals to processes 17allow dumpstate self:capability kill; 18 19# Allow executing files on system, such as: 20# /system/bin/toolbox 21# /system/bin/logcat 22# /system/bin/dumpsys 23allow dumpstate system_file:file execute_no_trans; 24 25# Create and write into /data/anr/ 26allow dumpstate self:capability { dac_override chown fowner fsetid }; 27allow dumpstate anr_data_file:dir { rw_dir_perms relabelto }; 28allow dumpstate anr_data_file:file create_file_perms; 29allow dumpstate system_data_file:dir { create_dir_perms relabelfrom }; 30 31# Allow reading /data/system/uiderrors.txt 32# TODO: scope this down. 33allow dumpstate system_data_file:file r_file_perms; 34 35# Read dmesg 36allow dumpstate self:capability2 syslog; 37allow dumpstate kernel:system syslog_read; 38 39# Read /sys/fs/pstore/console-ramoops 40allow dumpstate pstorefs:dir r_dir_perms; 41allow dumpstate pstorefs:file r_file_perms; 42 43# Get process attributes 44allow dumpstate domain:process getattr; 45 46# Signal java processes to dump their stack 47allow dumpstate { appdomain system_server }:process signal; 48 49# Signal native processes to dump their stack. 50# This list comes from native_processes_to_dump in dumpstate/utils.c 51allow dumpstate { drmserver mediaserver sdcardd surfaceflinger }:process signal; 52# Ask debuggerd for the backtraces of these processes. 53allow dumpstate { drmserver mediaserver sdcardd surfaceflinger }:debuggerd dump_backtrace; 54 55# Execute and transition to the vdc domain 56domain_auto_trans(dumpstate, vdc_exec, vdc) 57 58# Vibrate the device after we're done collecting the bugreport 59# /sys/class/timed_output/vibrator/enable 60# TODO: create a new file class, instead of allowing write access to all of /sys 61allow dumpstate sysfs:file w_file_perms; 62 63# Other random bits of data we want to collect 64allow dumpstate qtaguid_proc:file r_file_perms; 65allow dumpstate debugfs:file r_file_perms; 66# df for /storage/emulated needs search 67allow dumpstate storage_file:dir search; 68 69# Allow dumpstate to make binder calls to any binder service 70binder_call(dumpstate, binderservicedomain) 71binder_call(dumpstate, appdomain) 72 73# Reading /proc/PID/maps of other processes 74allow dumpstate self:capability sys_ptrace; 75 76# Allow the bugreport service to create a file in 77# /data/data/com.android.shell/files/bugreports/bugreport 78allow dumpstate shell_data_file:dir create_dir_perms; 79allow dumpstate shell_data_file:file create_file_perms; 80 81# Run a shell. 82allow dumpstate shell_exec:file rx_file_perms; 83 84# For running am and similar framework commands. 85# Run /system/bin/app_process. 86allow dumpstate zygote_exec:file rx_file_perms; 87# Dalvik Compiler JIT. 88allow dumpstate ashmem_device:chr_file execute; 89allow dumpstate dumpstate_tmpfs:file execute; 90allow dumpstate self:process execmem; 91# For art. 92allow dumpstate dalvikcache_data_file:file execute; 93allow dumpstate dalvikcache_data_file:lnk_file r_file_perms; 94 95# Dumpstate calls screencap, which grabs a screenshot. Needs gpu access 96allow dumpstate gpu_device:chr_file rw_file_perms; 97 98# logd access 99read_logd(dumpstate) 100control_logd(dumpstate) 101 102# Read network state info files. 103allow dumpstate net_data_file:dir search; 104allow dumpstate net_data_file:file r_file_perms; 105 106# Access /data/tombstones. 107allow dumpstate tombstone_data_file:dir r_dir_perms; 108allow dumpstate tombstone_data_file:file r_file_perms; 109 110allow dumpstate { service_manager_type -gatekeeper_service }:service_manager find; 111allow dumpstate servicemanager:service_manager list; 112 113allow dumpstate devpts:chr_file rw_file_perms; 114