1*e4a36f41SAndroid Build Coastguard Worker# dumpstate 2*e4a36f41SAndroid Build Coastguard Workertype dumpstate, domain, mlstrustedsubject; 3*e4a36f41SAndroid Build Coastguard Workertype dumpstate_exec, system_file_type, exec_type, file_type; 4*e4a36f41SAndroid Build Coastguard Worker 5*e4a36f41SAndroid Build Coastguard Workernet_domain(dumpstate) 6*e4a36f41SAndroid Build Coastguard Workerbinder_use(dumpstate) 7*e4a36f41SAndroid Build Coastguard Workerwakelock_use(dumpstate) 8*e4a36f41SAndroid Build Coastguard Worker 9*e4a36f41SAndroid Build Coastguard Worker# Allow setting process priority, protect from OOM killer, and dropping 10*e4a36f41SAndroid Build Coastguard Worker# privileges by switching UID / GID 11*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:global_capability_class_set { setuid setgid sys_resource }; 12*e4a36f41SAndroid Build Coastguard Worker 13*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to scan through /proc/pid for all processes 14*e4a36f41SAndroid Build Coastguard Workerr_dir_file(dumpstate, domain) 15*e4a36f41SAndroid Build Coastguard Worker 16*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:global_capability_class_set { 17*e4a36f41SAndroid Build Coastguard Worker # Send signals to processes 18*e4a36f41SAndroid Build Coastguard Worker kill 19*e4a36f41SAndroid Build Coastguard Worker # Run iptables 20*e4a36f41SAndroid Build Coastguard Worker net_raw 21*e4a36f41SAndroid Build Coastguard Worker net_admin 22*e4a36f41SAndroid Build Coastguard Worker}; 23*e4a36f41SAndroid Build Coastguard Worker 24*e4a36f41SAndroid Build Coastguard Worker# Allow executing files on system, such as: 25*e4a36f41SAndroid Build Coastguard Worker# /system/bin/toolbox 26*e4a36f41SAndroid Build Coastguard Worker# /system/bin/logcat 27*e4a36f41SAndroid Build Coastguard Worker# /system/bin/dumpsys 28*e4a36f41SAndroid Build Coastguard Workerallow dumpstate system_file:file execute_no_trans; 29*e4a36f41SAndroid Build Coastguard Workernot_full_treble(`allow dumpstate vendor_file:file execute_no_trans;') 30*e4a36f41SAndroid Build Coastguard Workerallow dumpstate toolbox_exec:file rx_file_perms; 31*e4a36f41SAndroid Build Coastguard Worker 32*e4a36f41SAndroid Build Coastguard Worker# hidl searches for files in /system/lib(64)/hw/ 33*e4a36f41SAndroid Build Coastguard Workerallow dumpstate system_file:dir r_dir_perms; 34*e4a36f41SAndroid Build Coastguard Worker 35*e4a36f41SAndroid Build Coastguard Worker# Create and write into /data/anr/ 36*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:global_capability_class_set { dac_override dac_read_search chown fowner fsetid }; 37*e4a36f41SAndroid Build Coastguard Workerallow dumpstate anr_data_file:dir rw_dir_perms; 38*e4a36f41SAndroid Build Coastguard Workerallow dumpstate anr_data_file:file create_file_perms; 39*e4a36f41SAndroid Build Coastguard Worker 40*e4a36f41SAndroid Build Coastguard Worker# Allow reading /data/system/uiderrors.txt 41*e4a36f41SAndroid Build Coastguard Worker# TODO: scope this down. 42*e4a36f41SAndroid Build Coastguard Workerallow dumpstate system_data_file:file r_file_perms; 43*e4a36f41SAndroid Build Coastguard Worker 44*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to append into privileged apps private files. 45*e4a36f41SAndroid Build Coastguard Workerallow dumpstate privapp_data_file:file append; 46*e4a36f41SAndroid Build Coastguard Worker 47*e4a36f41SAndroid Build Coastguard Worker# Read dmesg 48*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:global_capability2_class_set syslog; 49*e4a36f41SAndroid Build Coastguard Workerallow dumpstate kernel:system syslog_read; 50*e4a36f41SAndroid Build Coastguard Worker 51*e4a36f41SAndroid Build Coastguard Worker# Read /sys/fs/pstore/console-ramoops 52*e4a36f41SAndroid Build Coastguard Workerallow dumpstate pstorefs:dir r_dir_perms; 53*e4a36f41SAndroid Build Coastguard Workerallow dumpstate pstorefs:file r_file_perms; 54*e4a36f41SAndroid Build Coastguard Worker 55*e4a36f41SAndroid Build Coastguard Worker# Get process attributes 56*e4a36f41SAndroid Build Coastguard Workerallow dumpstate domain:process getattr; 57*e4a36f41SAndroid Build Coastguard Worker 58*e4a36f41SAndroid Build Coastguard Worker# Signal java processes to dump their stack 59*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { appdomain system_server zygote }:process signal; 60*e4a36f41SAndroid Build Coastguard Worker 61*e4a36f41SAndroid Build Coastguard Worker# Signal native processes to dump their stack. 62*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { 63*e4a36f41SAndroid Build Coastguard Worker # This list comes from native_processes_to_dump in dumputils/dump_utils.c 64*e4a36f41SAndroid Build Coastguard Worker audioserver 65*e4a36f41SAndroid Build Coastguard Worker cameraserver 66*e4a36f41SAndroid Build Coastguard Worker drmserver 67*e4a36f41SAndroid Build Coastguard Worker inputflinger 68*e4a36f41SAndroid Build Coastguard Worker mediadrmserver 69*e4a36f41SAndroid Build Coastguard Worker mediaextractor 70*e4a36f41SAndroid Build Coastguard Worker mediametrics 71*e4a36f41SAndroid Build Coastguard Worker mediaserver 72*e4a36f41SAndroid Build Coastguard Worker mediaswcodec 73*e4a36f41SAndroid Build Coastguard Worker sdcardd 74*e4a36f41SAndroid Build Coastguard Worker surfaceflinger 75*e4a36f41SAndroid Build Coastguard Worker vold 76*e4a36f41SAndroid Build Coastguard Worker 77*e4a36f41SAndroid Build Coastguard Worker # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.c 78*e4a36f41SAndroid Build Coastguard Worker hal_audio_server 79*e4a36f41SAndroid Build Coastguard Worker hal_bluetooth_server 80*e4a36f41SAndroid Build Coastguard Worker hal_camera_server 81*e4a36f41SAndroid Build Coastguard Worker hal_codec2_server 82*e4a36f41SAndroid Build Coastguard Worker hal_drm_server 83*e4a36f41SAndroid Build Coastguard Worker hal_face_server 84*e4a36f41SAndroid Build Coastguard Worker hal_fingerprint_server 85*e4a36f41SAndroid Build Coastguard Worker hal_graphics_allocator_server 86*e4a36f41SAndroid Build Coastguard Worker hal_graphics_composer_server 87*e4a36f41SAndroid Build Coastguard Worker hal_health_server 88*e4a36f41SAndroid Build Coastguard Worker hal_neuralnetworks_server 89*e4a36f41SAndroid Build Coastguard Worker hal_omx_server 90*e4a36f41SAndroid Build Coastguard Worker hal_power_server 91*e4a36f41SAndroid Build Coastguard Worker hal_power_stats_server 92*e4a36f41SAndroid Build Coastguard Worker hal_sensors_server 93*e4a36f41SAndroid Build Coastguard Worker hal_thermal_server 94*e4a36f41SAndroid Build Coastguard Worker hal_vr_server 95*e4a36f41SAndroid Build Coastguard Worker system_suspend_server 96*e4a36f41SAndroid Build Coastguard Worker}:process signal; 97*e4a36f41SAndroid Build Coastguard Worker 98*e4a36f41SAndroid Build Coastguard Worker# Connect to tombstoned to intercept dumps. 99*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(dumpstate, tombstoned_intercept, tombstoned) 100*e4a36f41SAndroid Build Coastguard Worker 101*e4a36f41SAndroid Build Coastguard Worker# Access to /sys 102*e4a36f41SAndroid Build Coastguard Workerallow dumpstate sysfs_type:dir r_dir_perms; 103*e4a36f41SAndroid Build Coastguard Worker 104*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { 105*e4a36f41SAndroid Build Coastguard Worker sysfs_devices_block 106*e4a36f41SAndroid Build Coastguard Worker sysfs_dm 107*e4a36f41SAndroid Build Coastguard Worker sysfs_loop 108*e4a36f41SAndroid Build Coastguard Worker sysfs_usb 109*e4a36f41SAndroid Build Coastguard Worker sysfs_zram 110*e4a36f41SAndroid Build Coastguard Worker}:file r_file_perms; 111*e4a36f41SAndroid Build Coastguard Worker 112*e4a36f41SAndroid Build Coastguard Worker# Other random bits of data we want to collect 113*e4a36f41SAndroid Build Coastguard Workerallow dumpstate debugfs:file r_file_perms; 114*e4a36f41SAndroid Build Coastguard Workerauditallow dumpstate debugfs:file r_file_perms; 115*e4a36f41SAndroid Build Coastguard Worker 116*e4a36f41SAndroid Build Coastguard Workerallow dumpstate debugfs_mmc:file r_file_perms; 117*e4a36f41SAndroid Build Coastguard Worker 118*e4a36f41SAndroid Build Coastguard Worker# df for 119*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { 120*e4a36f41SAndroid Build Coastguard Worker block_device 121*e4a36f41SAndroid Build Coastguard Worker cache_file 122*e4a36f41SAndroid Build Coastguard Worker metadata_file 123*e4a36f41SAndroid Build Coastguard Worker rootfs 124*e4a36f41SAndroid Build Coastguard Worker selinuxfs 125*e4a36f41SAndroid Build Coastguard Worker storage_file 126*e4a36f41SAndroid Build Coastguard Worker tmpfs 127*e4a36f41SAndroid Build Coastguard Worker}:dir { search getattr }; 128*e4a36f41SAndroid Build Coastguard Workerallow dumpstate fuse_device:chr_file getattr; 129*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { dm_device cache_block_device }:blk_file getattr; 130*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { cache_file rootfs }:lnk_file { getattr read }; 131*e4a36f41SAndroid Build Coastguard Worker 132*e4a36f41SAndroid Build Coastguard Worker# Read /dev/cpuctl and /dev/cpuset 133*e4a36f41SAndroid Build Coastguard Workerr_dir_file(dumpstate, cgroup) 134*e4a36f41SAndroid Build Coastguard Worker 135*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to make binder calls to any binder service 136*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, binderservicedomain) 137*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, { appdomain netd wificond }) 138*e4a36f41SAndroid Build Coastguard Worker 139*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_identity) 140*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_dumpstate) 141*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_wifi) 142*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_graphics_allocator) 143*e4a36f41SAndroid Build Coastguard Workerdump_hal(hal_neuralnetworks) 144*e4a36f41SAndroid Build Coastguard Worker# Vibrate the device after we are done collecting the bugreport 145*e4a36f41SAndroid Build Coastguard Workerhal_client_domain(dumpstate, hal_vibrator) 146*e4a36f41SAndroid Build Coastguard Worker 147*e4a36f41SAndroid Build Coastguard Worker# Reading /proc/PID/maps of other processes 148*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:global_capability_class_set sys_ptrace; 149*e4a36f41SAndroid Build Coastguard Worker 150*e4a36f41SAndroid Build Coastguard Worker# Allow the bugreport service to create a file in 151*e4a36f41SAndroid Build Coastguard Worker# /data/data/com.android.shell/files/bugreports/bugreport 152*e4a36f41SAndroid Build Coastguard Workerallow dumpstate shell_data_file:dir create_dir_perms; 153*e4a36f41SAndroid Build Coastguard Workerallow dumpstate shell_data_file:file create_file_perms; 154*e4a36f41SAndroid Build Coastguard Worker 155*e4a36f41SAndroid Build Coastguard Worker# Run a shell. 156*e4a36f41SAndroid Build Coastguard Workerallow dumpstate shell_exec:file rx_file_perms; 157*e4a36f41SAndroid Build Coastguard Worker 158*e4a36f41SAndroid Build Coastguard Worker# For running am and similar framework commands. 159*e4a36f41SAndroid Build Coastguard Worker# Run /system/bin/app_process. 160*e4a36f41SAndroid Build Coastguard Workerallow dumpstate zygote_exec:file rx_file_perms; 161*e4a36f41SAndroid Build Coastguard Worker 162*e4a36f41SAndroid Build Coastguard Worker# For Bluetooth 163*e4a36f41SAndroid Build Coastguard Workerallow dumpstate bluetooth_data_file:dir search; 164*e4a36f41SAndroid Build Coastguard Workerallow dumpstate bluetooth_logs_data_file:dir r_dir_perms; 165*e4a36f41SAndroid Build Coastguard Workerallow dumpstate bluetooth_logs_data_file:file r_file_perms; 166*e4a36f41SAndroid Build Coastguard Worker 167*e4a36f41SAndroid Build Coastguard Worker# Dumpstate calls screencap, which grabs a screenshot. Needs gpu access 168*e4a36f41SAndroid Build Coastguard Workerallow dumpstate gpu_device:chr_file rw_file_perms; 169*e4a36f41SAndroid Build Coastguard Worker 170*e4a36f41SAndroid Build Coastguard Worker# logd access 171*e4a36f41SAndroid Build Coastguard Workerread_logd(dumpstate) 172*e4a36f41SAndroid Build Coastguard Workercontrol_logd(dumpstate) 173*e4a36f41SAndroid Build Coastguard Workerread_runtime_log_tags(dumpstate) 174*e4a36f41SAndroid Build Coastguard Worker 175*e4a36f41SAndroid Build Coastguard Worker# Read files in /proc 176*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { 177*e4a36f41SAndroid Build Coastguard Worker proc_buddyinfo 178*e4a36f41SAndroid Build Coastguard Worker proc_cmdline 179*e4a36f41SAndroid Build Coastguard Worker proc_meminfo 180*e4a36f41SAndroid Build Coastguard Worker proc_modules 181*e4a36f41SAndroid Build Coastguard Worker proc_net_type 182*e4a36f41SAndroid Build Coastguard Worker proc_pipe_conf 183*e4a36f41SAndroid Build Coastguard Worker proc_pagetypeinfo 184*e4a36f41SAndroid Build Coastguard Worker proc_qtaguid_ctrl 185*e4a36f41SAndroid Build Coastguard Worker proc_qtaguid_stat 186*e4a36f41SAndroid Build Coastguard Worker proc_slabinfo 187*e4a36f41SAndroid Build Coastguard Worker proc_version 188*e4a36f41SAndroid Build Coastguard Worker proc_vmallocinfo 189*e4a36f41SAndroid Build Coastguard Worker proc_vmstat 190*e4a36f41SAndroid Build Coastguard Worker}:file r_file_perms; 191*e4a36f41SAndroid Build Coastguard Worker 192*e4a36f41SAndroid Build Coastguard Worker# Read network state info files. 193*e4a36f41SAndroid Build Coastguard Workerallow dumpstate net_data_file:dir search; 194*e4a36f41SAndroid Build Coastguard Workerallow dumpstate net_data_file:file r_file_perms; 195*e4a36f41SAndroid Build Coastguard Worker 196*e4a36f41SAndroid Build Coastguard Worker# List sockets via ss. 197*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:netlink_tcpdiag_socket { create_socket_perms_no_ioctl nlmsg_read }; 198*e4a36f41SAndroid Build Coastguard Worker 199*e4a36f41SAndroid Build Coastguard Worker# Access /data/tombstones. 200*e4a36f41SAndroid Build Coastguard Workerallow dumpstate tombstone_data_file:dir r_dir_perms; 201*e4a36f41SAndroid Build Coastguard Workerallow dumpstate tombstone_data_file:file r_file_perms; 202*e4a36f41SAndroid Build Coastguard Worker 203*e4a36f41SAndroid Build Coastguard Worker# Access /cache/recovery 204*e4a36f41SAndroid Build Coastguard Workerallow dumpstate cache_recovery_file:dir r_dir_perms; 205*e4a36f41SAndroid Build Coastguard Workerallow dumpstate cache_recovery_file:file r_file_perms; 206*e4a36f41SAndroid Build Coastguard Worker 207*e4a36f41SAndroid Build Coastguard Worker# Access /data/misc/recovery 208*e4a36f41SAndroid Build Coastguard Workerallow dumpstate recovery_data_file:dir r_dir_perms; 209*e4a36f41SAndroid Build Coastguard Workerallow dumpstate recovery_data_file:file r_file_perms; 210*e4a36f41SAndroid Build Coastguard Worker 211*e4a36f41SAndroid Build Coastguard Worker#Access /data/misc/update_engine_log 212*e4a36f41SAndroid Build Coastguard Workerallow dumpstate update_engine_log_data_file:dir r_dir_perms; 213*e4a36f41SAndroid Build Coastguard Workerallow dumpstate update_engine_log_data_file:file r_file_perms; 214*e4a36f41SAndroid Build Coastguard Worker 215*e4a36f41SAndroid Build Coastguard Worker# Access /data/misc/profiles/{cur,ref}/ 216*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 217*e4a36f41SAndroid Build Coastguard Worker allow dumpstate user_profile_data_file:dir r_dir_perms; 218*e4a36f41SAndroid Build Coastguard Worker allow dumpstate user_profile_data_file:file r_file_perms; 219*e4a36f41SAndroid Build Coastguard Worker') 220*e4a36f41SAndroid Build Coastguard Worker 221*e4a36f41SAndroid Build Coastguard Worker# Access /data/misc/logd 222*e4a36f41SAndroid Build Coastguard Workerallow dumpstate misc_logd_file:dir r_dir_perms; 223*e4a36f41SAndroid Build Coastguard Workerallow dumpstate misc_logd_file:file r_file_perms; 224*e4a36f41SAndroid Build Coastguard Worker 225*e4a36f41SAndroid Build Coastguard Worker# Access /data/misc/prereboot 226*e4a36f41SAndroid Build Coastguard Workerallow dumpstate prereboot_data_file:dir r_dir_perms; 227*e4a36f41SAndroid Build Coastguard Workerallow dumpstate prereboot_data_file:file r_file_perms; 228*e4a36f41SAndroid Build Coastguard Worker 229*e4a36f41SAndroid Build Coastguard Workerallow dumpstate app_fuse_file:dir r_dir_perms; 230*e4a36f41SAndroid Build Coastguard Workerallow dumpstate overlayfs_file:dir r_dir_perms; 231*e4a36f41SAndroid Build Coastguard Worker 232*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { 233*e4a36f41SAndroid Build Coastguard Worker service_manager_type 234*e4a36f41SAndroid Build Coastguard Worker -apex_service 235*e4a36f41SAndroid Build Coastguard Worker -dumpstate_service 236*e4a36f41SAndroid Build Coastguard Worker -gatekeeper_service 237*e4a36f41SAndroid Build Coastguard Worker -virtual_touchpad_service 238*e4a36f41SAndroid Build Coastguard Worker -vold_service 239*e4a36f41SAndroid Build Coastguard Worker -vr_hwc_service 240*e4a36f41SAndroid Build Coastguard Worker -default_android_service 241*e4a36f41SAndroid Build Coastguard Worker}:service_manager find; 242*e4a36f41SAndroid Build Coastguard Worker# suppress denials for services dumpstate should not be accessing. 243*e4a36f41SAndroid Build Coastguard Workerdontaudit dumpstate { 244*e4a36f41SAndroid Build Coastguard Worker apex_service 245*e4a36f41SAndroid Build Coastguard Worker dumpstate_service 246*e4a36f41SAndroid Build Coastguard Worker gatekeeper_service 247*e4a36f41SAndroid Build Coastguard Worker virtual_touchpad_service 248*e4a36f41SAndroid Build Coastguard Worker vold_service 249*e4a36f41SAndroid Build Coastguard Worker vr_hwc_service 250*e4a36f41SAndroid Build Coastguard Worker}:service_manager find; 251*e4a36f41SAndroid Build Coastguard Worker 252*e4a36f41SAndroid Build Coastguard Worker# Most of these are neverallowed. 253*e4a36f41SAndroid Build Coastguard Workerdontaudit dumpstate hwservice_manager_type:hwservice_manager find; 254*e4a36f41SAndroid Build Coastguard Worker 255*e4a36f41SAndroid Build Coastguard Workerallow dumpstate servicemanager:service_manager list; 256*e4a36f41SAndroid Build Coastguard Workerallow dumpstate hwservicemanager:hwservice_manager list; 257*e4a36f41SAndroid Build Coastguard Worker 258*e4a36f41SAndroid Build Coastguard Workerallow dumpstate devpts:chr_file rw_file_perms; 259*e4a36f41SAndroid Build Coastguard Worker 260*e4a36f41SAndroid Build Coastguard Worker# Set properties. 261*e4a36f41SAndroid Build Coastguard Worker# dumpstate_prop is used to share state with the Shell app. 262*e4a36f41SAndroid Build Coastguard Workerset_prop(dumpstate, dumpstate_prop) 263*e4a36f41SAndroid Build Coastguard Workerset_prop(dumpstate, exported_dumpstate_prop) 264*e4a36f41SAndroid Build Coastguard Worker# dumpstate_options_prop is used to pass extra command-line args. 265*e4a36f41SAndroid Build Coastguard Workerset_prop(dumpstate, dumpstate_options_prop) 266*e4a36f41SAndroid Build Coastguard Worker 267*e4a36f41SAndroid Build Coastguard Worker# Read any system properties 268*e4a36f41SAndroid Build Coastguard Workerget_prop(dumpstate, property_type) 269*e4a36f41SAndroid Build Coastguard Worker 270*e4a36f41SAndroid Build Coastguard Worker# Access to /data/media. 271*e4a36f41SAndroid Build Coastguard Worker# This should be removed if sdcardfs is modified to alter the secontext for its 272*e4a36f41SAndroid Build Coastguard Worker# accesses to the underlying FS. 273*e4a36f41SAndroid Build Coastguard Workerallow dumpstate media_rw_data_file:dir getattr; 274*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_interrupts:file r_file_perms; 275*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_zoneinfo:file r_file_perms; 276*e4a36f41SAndroid Build Coastguard Worker 277*e4a36f41SAndroid Build Coastguard Worker# Create a service for talking back to system_server 278*e4a36f41SAndroid Build Coastguard Workeradd_service(dumpstate, dumpstate_service) 279*e4a36f41SAndroid Build Coastguard Worker 280*e4a36f41SAndroid Build Coastguard Worker# use /dev/ion for screen capture 281*e4a36f41SAndroid Build Coastguard Workerallow dumpstate ion_device:chr_file r_file_perms; 282*e4a36f41SAndroid Build Coastguard Worker 283*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to run top 284*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_stat:file r_file_perms; 285*e4a36f41SAndroid Build Coastguard Worker 286*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_pressure_cpu:file r_file_perms; 287*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_pressure_mem:file r_file_perms; 288*e4a36f41SAndroid Build Coastguard Workerallow dumpstate proc_pressure_io:file r_file_perms; 289*e4a36f41SAndroid Build Coastguard Worker 290*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to talk to installd over binder 291*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, installd); 292*e4a36f41SAndroid Build Coastguard Worker 293*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to talk to iorapd over binder. 294*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, iorapd) 295*e4a36f41SAndroid Build Coastguard Worker 296*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to run ip xfrm policy 297*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:netlink_xfrm_socket { create_socket_perms_no_ioctl nlmsg_read }; 298*e4a36f41SAndroid Build Coastguard Worker 299*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to run iotop 300*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:netlink_socket create_socket_perms_no_ioctl; 301*e4a36f41SAndroid Build Coastguard Worker# newer kernels (e.g. 4.4) have a new class for sockets 302*e4a36f41SAndroid Build Coastguard Workerallow dumpstate self:netlink_generic_socket create_socket_perms_no_ioctl; 303*e4a36f41SAndroid Build Coastguard Worker 304*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to run ss 305*e4a36f41SAndroid Build Coastguard Workerallow dumpstate { domain pdx_channel_socket_type pdx_endpoint_socket_type }:socket_class_set getattr; 306*e4a36f41SAndroid Build Coastguard Worker 307*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to read linkerconfig directory 308*e4a36f41SAndroid Build Coastguard Workerallow dumpstate linkerconfig_file:dir { read open }; 309*e4a36f41SAndroid Build Coastguard Worker 310*e4a36f41SAndroid Build Coastguard Worker# For when dumpstate runs df 311*e4a36f41SAndroid Build Coastguard Workerdontaudit dumpstate { 312*e4a36f41SAndroid Build Coastguard Worker mnt_vendor_file 313*e4a36f41SAndroid Build Coastguard Worker mirror_data_file 314*e4a36f41SAndroid Build Coastguard Worker mnt_user_file 315*e4a36f41SAndroid Build Coastguard Worker}:dir search; 316*e4a36f41SAndroid Build Coastguard Workerdontaudit dumpstate { 317*e4a36f41SAndroid Build Coastguard Worker apex_mnt_dir 318*e4a36f41SAndroid Build Coastguard Worker linkerconfig_file 319*e4a36f41SAndroid Build Coastguard Worker mirror_data_file 320*e4a36f41SAndroid Build Coastguard Worker mnt_user_file 321*e4a36f41SAndroid Build Coastguard Worker}:dir getattr; 322*e4a36f41SAndroid Build Coastguard Worker 323*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to talk to bufferhubd over binder 324*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, bufferhubd); 325*e4a36f41SAndroid Build Coastguard Worker 326*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to talk to mediaswcodec over binder 327*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, mediaswcodec); 328*e4a36f41SAndroid Build Coastguard Worker 329*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to talk to these stable AIDL services over binder 330*e4a36f41SAndroid Build Coastguard Workerbinder_call(dumpstate, hal_rebootescrow_server) 331*e4a36f41SAndroid Build Coastguard Workerallow hal_rebootescrow_server dumpstate:fifo_file write; 332*e4a36f41SAndroid Build Coastguard Workerallow hal_rebootescrow_server dumpstate:fd use; 333*e4a36f41SAndroid Build Coastguard Worker 334*e4a36f41SAndroid Build Coastguard Worker# Allow dumpstate to kill vendor dumpstate service by init 335*e4a36f41SAndroid Build Coastguard Workerset_prop(dumpstate, ctl_dumpstate_prop) 336*e4a36f41SAndroid Build Coastguard Worker 337*e4a36f41SAndroid Build Coastguard Worker#Access /data/misc/snapshotctl_log 338*e4a36f41SAndroid Build Coastguard Workerallow dumpstate snapshotctl_log_data_file:dir r_dir_perms; 339*e4a36f41SAndroid Build Coastguard Workerallow dumpstate snapshotctl_log_data_file:file r_file_perms; 340*e4a36f41SAndroid Build Coastguard Worker 341*e4a36f41SAndroid Build Coastguard Worker#Allow access to /dev/binderfs/binder_logs 342*e4a36f41SAndroid Build Coastguard Workerallow dumpstate binderfs_logs:dir r_dir_perms; 343*e4a36f41SAndroid Build Coastguard Workerallow dumpstate binderfs_logs:file r_file_perms; 344*e4a36f41SAndroid Build Coastguard Worker 345*e4a36f41SAndroid Build Coastguard Worker### 346*e4a36f41SAndroid Build Coastguard Worker### neverallow rules 347*e4a36f41SAndroid Build Coastguard Worker### 348*e4a36f41SAndroid Build Coastguard Worker 349*e4a36f41SAndroid Build Coastguard Worker# dumpstate has capability sys_ptrace, but should only use that capability for 350*e4a36f41SAndroid Build Coastguard Worker# accessing sensitive /proc/PID files, never for using ptrace attach. 351*e4a36f41SAndroid Build Coastguard Workerneverallow dumpstate *:process ptrace; 352*e4a36f41SAndroid Build Coastguard Worker 353*e4a36f41SAndroid Build Coastguard Worker# only system_server, dumpstate, traceur_app and shell can find the dumpstate service 354*e4a36f41SAndroid Build Coastguard Workerneverallow { 355*e4a36f41SAndroid Build Coastguard Worker domain 356*e4a36f41SAndroid Build Coastguard Worker -system_server 357*e4a36f41SAndroid Build Coastguard Worker -shell 358*e4a36f41SAndroid Build Coastguard Worker -traceur_app 359*e4a36f41SAndroid Build Coastguard Worker -dumpstate 360*e4a36f41SAndroid Build Coastguard Worker} dumpstate_service:service_manager find; 361