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 1116, allow accessing statsd socket 26unix_socket_send(incidentd, statsdw, statsd) 27 28# section id 1116, allow using userfaultfd 29userfaultfd_use(incidentd) 30 31# section id 2001, allow reading /proc/pagetypeinfo 32allow incidentd proc_pagetypeinfo:file r_file_perms; 33 34# section id 2002, allow reading /d/wakeup_sources 35userdebug_or_eng(`allow incidentd debugfs_wakeup_sources:file r_file_perms'); 36 37# section id 2003, allow executing top 38allow incidentd proc_meminfo:file { open read }; 39 40# section id 2004, allow reading /sys/devices/system/cpu/cpufreq/all_time_in_state 41allow incidentd sysfs_devices_system_cpu:file r_file_perms; 42 43# section id 2005, allow reading ps dump in full 44allow incidentd domain:process getattr; 45 46# section id 2006, allow reading /sys/class/power_supply/bms/battery_type 47allow incidentd sysfs_batteryinfo:dir { search }; 48allow incidentd sysfs_batteryinfo:file r_file_perms; 49 50# section id 2007, allow reading LAST_KMSG /sys/fs/pstore/console-ramoops 51userdebug_or_eng(`allow incidentd pstorefs:dir search'); 52userdebug_or_eng(`allow incidentd pstorefs:file r_file_perms'); 53 54# section id 3023, allow obtaining stats report 55allow incidentd stats_service:service_manager find; 56binder_call(incidentd, statsd) 57 58# section id 3026, allow reading /data/misc/perfetto-traces. 59allow incidentd perfetto_traces_data_file:dir r_dir_perms; 60allow incidentd perfetto_traces_data_file:file r_file_perms; 61 62# section id 3052, allow accessing nfc_service 63allow incidentd nfc_service:service_manager find; 64 65# Create and write into /data/misc/incidents 66allow incidentd incident_data_file:dir rw_dir_perms; 67allow incidentd incident_data_file:file create_file_perms; 68 69# Enable incidentd to get stack traces. 70binder_use(incidentd) 71hwbinder_use(incidentd) 72allow incidentd hwservicemanager:hwservice_manager { list }; 73get_prop(incidentd, hwservicemanager_prop) 74allow incidentd hidl_manager_hwservice:hwservice_manager { find }; 75 76# Read files in /proc 77allow incidentd { 78 proc_cmdline 79 proc_pid_max 80 proc_pipe_conf 81 proc_stat 82}:file r_file_perms; 83 84# Signal java processes to dump their stack and get the results 85allow incidentd { appdomain ephemeral_app system_server }:process signal; 86 87# Signal native processes to dump their stack. 88# This list comes from native_processes_to_dump in incidentd/utils.c 89allow incidentd { 90 # This list comes from native_processes_to_dump in dumputils/dump_utils.cpp 91 audioserver 92 cameraserver 93 drmserver 94 inputflinger 95 mediadrmserver 96 mediaextractor 97 mediametrics 98 mediaserver 99 sdcardd 100 statsd 101 surfaceflinger 102 103 # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.cpp 104 hal_audio_server 105 hal_bluetooth_server 106 hal_camera_server 107 hal_codec2_server 108 hal_face_server 109 hal_graphics_allocator_server 110 hal_graphics_composer_server 111 hal_health_server 112 hal_omx_server 113 hal_sensors_server 114 hal_vr_server 115}:process signal; 116 117# Allow incidentd to make binder calls to any binder service 118binder_call(incidentd, system_server) 119binder_call(incidentd, appdomain) 120 121# Reading /proc/PID/maps of other processes 122userdebug_or_eng(`allow incidentd self:global_capability_class_set { sys_ptrace }'); 123# incidentd has capability sys_ptrace, but should only use that capability for 124# accessing sensitive /proc/PID files, never for using ptrace attach. 125neverallow incidentd *:process ptrace; 126 127allow incidentd self:global_capability_class_set { 128 # Send signals to processes 129 kill 130}; 131 132# Connect to tombstoned to intercept dumps. 133unix_socket_connect(incidentd, tombstoned_intercept, tombstoned) 134 135# Run a shell. 136allow incidentd shell_exec:file rx_file_perms; 137 138# For running am, incident-helper-cmd and similar framework commands. 139# Run /system/bin/app_process. 140allow incidentd zygote_exec:file { rx_file_perms }; 141# Access the runtime feature flag properties. 142get_prop(incidentd, device_config_runtime_native_prop) 143get_prop(incidentd, device_config_runtime_native_boot_prop) 144# Access odsign verification status. 145get_prop(incidentd, odsign_prop) 146# ART locks profile files. 147allow incidentd system_file:file lock; 148# Incidentd should never exec from the memory (e.g. JIT cache). These denials are expected. 149dontaudit incidentd dalvikcache_data_file:dir r_dir_perms; 150dontaudit incidentd apex_module_data_file:dir r_dir_perms; 151dontaudit incidentd apex_art_data_file:dir r_dir_perms; 152dontaudit incidentd tmpfs:file rwx_file_perms; 153 154# Allow incidentd to read /apex/apex-info-list.xml 155allow incidentd apex_info_file:file r_file_perms; 156 157# logd access - work to be done is a PII safe log (possibly an event log?) 158userdebug_or_eng(`read_logd(incidentd)') 159# TODO control_logd(incidentd) 160 161# Access /data/misc/logd 162r_dir_file(incidentd, misc_logd_file) 163 164# Allow incidentd to find these standard groups of services. 165# Others can be allowlisted individually. 166allow incidentd { 167 system_server_service 168 app_api_service 169 system_api_service 170 -tracingproxy_service 171}:service_manager find; 172 173# Only incidentd can publish the binder service 174add_service(incidentd, incident_service) 175 176# Allow pipes only from dumpstate and incident 177allow incidentd { dumpstate incident }:fd use; 178allow incidentd { dumpstate incident }:fifo_file write; 179 180# Allow incident to call back to incident with status updates. 181binder_call(incidentd, incident) 182 183# Read device serial number from system properties 184# This is used to track reports from lab testing devices 185userdebug_or_eng(` 186 get_prop(incidentd, serialno_prop) 187') 188 189# Read ro.boot.bootreason, persist.sys.boot.bootreason 190# This is used to track reports from lab testing devices 191userdebug_or_eng(` 192 get_prop(incidentd, bootloader_boot_reason_prop); 193 get_prop(incidentd, system_boot_reason_prop); 194 get_prop(incidentd, last_boot_reason_prop); 195') 196 197# Allow incident to read the build properties for attestation feature 198get_prop(incidentd, build_attestation_prop); 199 200### 201### neverallow rules 202### 203# only incidentd and the other root services in limited circumstances 204# can get to the files in /data/misc/incidents 205# 206# write, execute, append are forbidden almost everywhere 207neverallow { domain -incidentd -init -vold } incident_data_file:file { 208 w_file_perms 209 x_file_perms 210 create 211 rename 212 setattr 213 unlink 214 append 215}; 216# read is also allowed by system_server, for when the file is handed to dropbox 217neverallow { domain -incidentd -init -vold -system_server } incident_data_file:file r_file_perms; 218# limited access to the directory itself 219neverallow { domain -incidentd -init -vold } incident_data_file:dir create_dir_perms; 220 221