1typeattribute incidentd coredomain; 2typeattribute incidentd mlstrustedsubject; 3 4init_daemon_domain(incidentd) 5type incidentd_exec, exec_type, file_type; 6binder_use(incidentd) 7wakelock_use(incidentd) 8 9# Allow incidentd to scan through /proc/pid for all processes 10r_dir_file(incidentd, domain) 11 12# Allow incidentd to kill incident_helper when timeout 13allow incidentd incident_helper:process sigkill; 14 15# Allow executing files on system, such as: 16# /system/bin/toolbox 17# /system/bin/logcat 18# /system/bin/dumpsys 19allow incidentd system_file:file execute_no_trans; 20allow incidentd toolbox_exec:file rx_file_perms; 21 22# section id 2001, allow reading /proc/pagetypeinfo 23allow incidentd proc_pagetypeinfo:file r_file_perms; 24 25# section id 2002, allow reading /d/wakeup_sources 26allow incidentd debugfs_wakeup_sources:file r_file_perms; 27 28# section id 2003, allow executing top 29allow incidentd proc_meminfo:file { open read }; 30 31# section id 2004, allow reading /sys/devices/system/cpu/cpufreq/all_time_in_state 32allow incidentd sysfs_devices_system_cpu:file r_file_perms; 33 34# section id 2005, allow reading ps dump in full 35allow incidentd domain:process getattr; 36 37# section id 2006, allow reading /sys/class/power_supply/bms/battery_type 38allow incidentd sysfs_batteryinfo:dir { search }; 39allow incidentd sysfs_batteryinfo:file r_file_perms; 40 41# section id 2007, allow reading LAST_KMSG /sys/fs/pstore/console-ramoops 42userdebug_or_eng(`allow incidentd pstorefs:dir search'); 43userdebug_or_eng(`allow incidentd pstorefs:file r_file_perms'); 44 45# Create and write into /data/misc/incidents 46allow incidentd incident_data_file:dir rw_dir_perms; 47allow incidentd incident_data_file:file create_file_perms; 48 49# Enable incidentd to get stack traces. 50binder_use(incidentd) 51hwbinder_use(incidentd) 52allow incidentd hwservicemanager:hwservice_manager { list }; 53get_prop(incidentd, hwservicemanager_prop) 54allow incidentd hidl_manager_hwservice:hwservice_manager { find }; 55 56# Read files in /proc 57allow incidentd { 58 proc_cmdline 59 proc_pipe_conf 60 proc_stat 61}:file r_file_perms; 62 63# Signal java processes to dump their stack and get the results 64allow incidentd { appdomain ephemeral_app system_server }:process signal; 65 66# Signal native processes to dump their stack. 67# This list comes from native_processes_to_dump in incidentd/utils.c 68allow incidentd { 69 # This list comes from native_processes_to_dump in dumputils/dump_utils.cpp 70 audioserver 71 cameraserver 72 drmserver 73 inputflinger 74 mediadrmserver 75 mediaextractor 76 mediametrics 77 mediaserver 78 sdcardd 79 statsd 80 surfaceflinger 81 82 # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.cpp 83 hal_audio_server 84 hal_bluetooth_server 85 hal_camera_server 86 hal_graphics_composer_server 87 hal_sensors_server 88 hal_vr_server 89 mediacodec # TODO(b/36375899): hal_omx_server 90}:process signal; 91 92# Allow incidentd to make binder calls to any binder service 93binder_call(incidentd, system_server) 94binder_call(incidentd, appdomain) 95 96# Reading /proc/PID/maps of other processes 97userdebug_or_eng(`allow incidentd self:global_capability_class_set { sys_ptrace }'); 98# incidentd has capability sys_ptrace, but should only use that capability for 99# accessing sensitive /proc/PID files, never for using ptrace attach. 100neverallow incidentd *:process ptrace; 101 102allow incidentd self:global_capability_class_set { 103 # Send signals to processes 104 kill 105}; 106 107# Connect to tombstoned to intercept dumps. 108unix_socket_connect(incidentd, tombstoned_intercept, tombstoned) 109 110# Run a shell. 111allow incidentd shell_exec:file rx_file_perms; 112 113# logd access - work to be done is a PII safe log (possibly an event log?) 114userdebug_or_eng(`read_logd(incidentd)') 115# TODO control_logd(incidentd) 116 117# Allow incidentd to find these standard groups of services. 118# Others can be allowlisted individually. 119allow incidentd { 120 system_server_service 121 app_api_service 122 system_api_service 123}:service_manager find; 124 125# Only incidentd can publish the binder service 126add_service(incidentd, incident_service) 127 128# Allow pipes from (and only from) incident 129allow incidentd incident:fd use; 130allow incidentd incident:fifo_file write; 131 132# Allow incident to call back to incident with status updates. 133binder_call(incidentd, incident) 134 135### 136### neverallow rules 137### 138 139# only system_server, system_app and incident command can find the incident service 140neverallow { 141 domain 142 -incident 143 -incidentd 144 -statsd 145 -system_app 146 -system_server 147} incident_service:service_manager find; 148 149# only incidentd and the other root services in limited circumstances 150# can get to the files in /data/misc/incidents 151# 152# write, execute, append are forbidden almost everywhere 153neverallow { domain -incidentd -init -vold } incident_data_file:file { 154 w_file_perms 155 x_file_perms 156 create 157 rename 158 setattr 159 unlink 160 append 161}; 162# read is also allowed by system_server, for when the file is handed to dropbox 163neverallow { domain -incidentd -init -vold -system_server } incident_data_file:file r_file_perms; 164# limited access to the directory itself 165neverallow { domain -incidentd -init -vold } incident_data_file:dir create_dir_perms; 166 167