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