1*e4a36f41SAndroid Build Coastguard Workertypeattribute incidentd coredomain; 2*e4a36f41SAndroid Build Coastguard Workertypeattribute incidentd mlstrustedsubject; 3*e4a36f41SAndroid Build Coastguard Worker 4*e4a36f41SAndroid Build Coastguard Workerinit_daemon_domain(incidentd) 5*e4a36f41SAndroid Build Coastguard Workertype incidentd_exec, system_file_type, exec_type, file_type; 6*e4a36f41SAndroid Build Coastguard Workerbinder_use(incidentd) 7*e4a36f41SAndroid Build Coastguard Workerwakelock_use(incidentd) 8*e4a36f41SAndroid Build Coastguard Worker 9*e4a36f41SAndroid Build Coastguard Worker# Allow incidentd to scan through /proc/pid for all processes 10*e4a36f41SAndroid Build Coastguard Workerr_dir_file(incidentd, domain) 11*e4a36f41SAndroid Build Coastguard Worker 12*e4a36f41SAndroid Build Coastguard Worker# Allow incidentd to kill incident_helper when timeout 13*e4a36f41SAndroid Build Coastguard Workerallow incidentd incident_helper:process sigkill; 14*e4a36f41SAndroid Build Coastguard Worker 15*e4a36f41SAndroid Build Coastguard Worker# Allow executing files on system, such as: 16*e4a36f41SAndroid Build Coastguard Worker# /system/bin/toolbox 17*e4a36f41SAndroid Build Coastguard Worker# /system/bin/logcat 18*e4a36f41SAndroid Build Coastguard Worker# /system/bin/dumpsys 19*e4a36f41SAndroid Build Coastguard Workerallow incidentd system_file:file execute_no_trans; 20*e4a36f41SAndroid Build Coastguard Workerallow incidentd toolbox_exec:file rx_file_perms; 21*e4a36f41SAndroid Build Coastguard Worker 22*e4a36f41SAndroid Build Coastguard Worker# section id 1002, allow reading kernel version /proc/version 23*e4a36f41SAndroid Build Coastguard Workerallow incidentd proc_version:file r_file_perms; 24*e4a36f41SAndroid Build Coastguard Worker 25*e4a36f41SAndroid Build Coastguard Worker# section id 2001, allow reading /proc/pagetypeinfo 26*e4a36f41SAndroid Build Coastguard Workerallow incidentd proc_pagetypeinfo:file r_file_perms; 27*e4a36f41SAndroid Build Coastguard Worker 28*e4a36f41SAndroid Build Coastguard Worker# section id 2002, allow reading /d/wakeup_sources 29*e4a36f41SAndroid Build Coastguard Workerallow incidentd debugfs_wakeup_sources:file r_file_perms; 30*e4a36f41SAndroid Build Coastguard Worker 31*e4a36f41SAndroid Build Coastguard Worker# section id 2003, allow executing top 32*e4a36f41SAndroid Build Coastguard Workerallow incidentd proc_meminfo:file { open read }; 33*e4a36f41SAndroid Build Coastguard Worker 34*e4a36f41SAndroid Build Coastguard Worker# section id 2004, allow reading /sys/devices/system/cpu/cpufreq/all_time_in_state 35*e4a36f41SAndroid Build Coastguard Workerallow incidentd sysfs_devices_system_cpu:file r_file_perms; 36*e4a36f41SAndroid Build Coastguard Worker 37*e4a36f41SAndroid Build Coastguard Worker# section id 2005, allow reading ps dump in full 38*e4a36f41SAndroid Build Coastguard Workerallow incidentd domain:process getattr; 39*e4a36f41SAndroid Build Coastguard Worker 40*e4a36f41SAndroid Build Coastguard Worker# section id 2006, allow reading /sys/class/power_supply/bms/battery_type 41*e4a36f41SAndroid Build Coastguard Workerallow incidentd sysfs_batteryinfo:dir { search }; 42*e4a36f41SAndroid Build Coastguard Workerallow incidentd sysfs_batteryinfo:file r_file_perms; 43*e4a36f41SAndroid Build Coastguard Worker 44*e4a36f41SAndroid Build Coastguard Worker# section id 2007, allow reading LAST_KMSG /sys/fs/pstore/console-ramoops 45*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`allow incidentd pstorefs:dir search'); 46*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`allow incidentd pstorefs:file r_file_perms'); 47*e4a36f41SAndroid Build Coastguard Worker 48*e4a36f41SAndroid Build Coastguard Worker# section id 3023, allow obtaining stats report 49*e4a36f41SAndroid Build Coastguard Workerallow incidentd stats_service:service_manager find; 50*e4a36f41SAndroid Build Coastguard Workerbinder_call(incidentd, statsd) 51*e4a36f41SAndroid Build Coastguard Worker 52*e4a36f41SAndroid Build Coastguard Worker# section id 3026, allow reading /data/misc/perfetto-traces. 53*e4a36f41SAndroid Build Coastguard Workerallow incidentd perfetto_traces_data_file:dir r_dir_perms; 54*e4a36f41SAndroid Build Coastguard Workerallow incidentd perfetto_traces_data_file:file r_file_perms; 55*e4a36f41SAndroid Build Coastguard Worker 56*e4a36f41SAndroid Build Coastguard Worker# Create and write into /data/misc/incidents 57*e4a36f41SAndroid Build Coastguard Workerallow incidentd incident_data_file:dir rw_dir_perms; 58*e4a36f41SAndroid Build Coastguard Workerallow incidentd incident_data_file:file create_file_perms; 59*e4a36f41SAndroid Build Coastguard Worker 60*e4a36f41SAndroid Build Coastguard Worker# Enable incidentd to get stack traces. 61*e4a36f41SAndroid Build Coastguard Workerbinder_use(incidentd) 62*e4a36f41SAndroid Build Coastguard Workerhwbinder_use(incidentd) 63*e4a36f41SAndroid Build Coastguard Workerallow incidentd hwservicemanager:hwservice_manager { list }; 64*e4a36f41SAndroid Build Coastguard Workerget_prop(incidentd, hwservicemanager_prop) 65*e4a36f41SAndroid Build Coastguard Workerallow incidentd hidl_manager_hwservice:hwservice_manager { find }; 66*e4a36f41SAndroid Build Coastguard Worker 67*e4a36f41SAndroid Build Coastguard Worker# Read files in /proc 68*e4a36f41SAndroid Build Coastguard Workerallow incidentd { 69*e4a36f41SAndroid Build Coastguard Worker proc_cmdline 70*e4a36f41SAndroid Build Coastguard Worker proc_pipe_conf 71*e4a36f41SAndroid Build Coastguard Worker proc_stat 72*e4a36f41SAndroid Build Coastguard Worker}:file r_file_perms; 73*e4a36f41SAndroid Build Coastguard Worker 74*e4a36f41SAndroid Build Coastguard Worker# Signal java processes to dump their stack and get the results 75*e4a36f41SAndroid Build Coastguard Workerallow incidentd { appdomain ephemeral_app system_server }:process signal; 76*e4a36f41SAndroid Build Coastguard Worker 77*e4a36f41SAndroid Build Coastguard Worker# Signal native processes to dump their stack. 78*e4a36f41SAndroid Build Coastguard Worker# This list comes from native_processes_to_dump in incidentd/utils.c 79*e4a36f41SAndroid Build Coastguard Workerallow incidentd { 80*e4a36f41SAndroid Build Coastguard Worker # This list comes from native_processes_to_dump in dumputils/dump_utils.cpp 81*e4a36f41SAndroid Build Coastguard Worker audioserver 82*e4a36f41SAndroid Build Coastguard Worker cameraserver 83*e4a36f41SAndroid Build Coastguard Worker drmserver 84*e4a36f41SAndroid Build Coastguard Worker inputflinger 85*e4a36f41SAndroid Build Coastguard Worker mediadrmserver 86*e4a36f41SAndroid Build Coastguard Worker mediaextractor 87*e4a36f41SAndroid Build Coastguard Worker mediametrics 88*e4a36f41SAndroid Build Coastguard Worker mediaserver 89*e4a36f41SAndroid Build Coastguard Worker sdcardd 90*e4a36f41SAndroid Build Coastguard Worker statsd 91*e4a36f41SAndroid Build Coastguard Worker surfaceflinger 92*e4a36f41SAndroid Build Coastguard Worker 93*e4a36f41SAndroid Build Coastguard Worker # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.cpp 94*e4a36f41SAndroid Build Coastguard Worker hal_audio_server 95*e4a36f41SAndroid Build Coastguard Worker hal_bluetooth_server 96*e4a36f41SAndroid Build Coastguard Worker hal_camera_server 97*e4a36f41SAndroid Build Coastguard Worker hal_codec2_server 98*e4a36f41SAndroid Build Coastguard Worker hal_face_server 99*e4a36f41SAndroid Build Coastguard Worker hal_graphics_allocator_server 100*e4a36f41SAndroid Build Coastguard Worker hal_graphics_composer_server 101*e4a36f41SAndroid Build Coastguard Worker hal_health_server 102*e4a36f41SAndroid Build Coastguard Worker hal_omx_server 103*e4a36f41SAndroid Build Coastguard Worker hal_sensors_server 104*e4a36f41SAndroid Build Coastguard Worker hal_vr_server 105*e4a36f41SAndroid Build Coastguard Worker}:process signal; 106*e4a36f41SAndroid Build Coastguard Worker 107*e4a36f41SAndroid Build Coastguard Worker# Allow incidentd to make binder calls to any binder service 108*e4a36f41SAndroid Build Coastguard Workerbinder_call(incidentd, system_server) 109*e4a36f41SAndroid Build Coastguard Workerbinder_call(incidentd, appdomain) 110*e4a36f41SAndroid Build Coastguard Worker 111*e4a36f41SAndroid Build Coastguard Worker# Reading /proc/PID/maps of other processes 112*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`allow incidentd self:global_capability_class_set { sys_ptrace }'); 113*e4a36f41SAndroid Build Coastguard Worker# incidentd has capability sys_ptrace, but should only use that capability for 114*e4a36f41SAndroid Build Coastguard Worker# accessing sensitive /proc/PID files, never for using ptrace attach. 115*e4a36f41SAndroid Build Coastguard Workerneverallow incidentd *:process ptrace; 116*e4a36f41SAndroid Build Coastguard Worker 117*e4a36f41SAndroid Build Coastguard Workerallow incidentd self:global_capability_class_set { 118*e4a36f41SAndroid Build Coastguard Worker # Send signals to processes 119*e4a36f41SAndroid Build Coastguard Worker kill 120*e4a36f41SAndroid Build Coastguard Worker}; 121*e4a36f41SAndroid Build Coastguard Worker 122*e4a36f41SAndroid Build Coastguard Worker# Connect to tombstoned to intercept dumps. 123*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(incidentd, tombstoned_intercept, tombstoned) 124*e4a36f41SAndroid Build Coastguard Worker 125*e4a36f41SAndroid Build Coastguard Worker# Run a shell. 126*e4a36f41SAndroid Build Coastguard Workerallow incidentd shell_exec:file rx_file_perms; 127*e4a36f41SAndroid Build Coastguard Worker 128*e4a36f41SAndroid Build Coastguard Worker# For running am, incident-helper-cmd and similar framework commands. 129*e4a36f41SAndroid Build Coastguard Worker# Run /system/bin/app_process. 130*e4a36f41SAndroid Build Coastguard Workerallow incidentd zygote_exec:file { rx_file_perms }; 131*e4a36f41SAndroid Build Coastguard Worker# Access the runtime feature flag properties. 132*e4a36f41SAndroid Build Coastguard Workerget_prop(incidentd, device_config_runtime_native_prop) 133*e4a36f41SAndroid Build Coastguard Workerget_prop(incidentd, device_config_runtime_native_boot_prop) 134*e4a36f41SAndroid Build Coastguard Worker# ART locks profile files. 135*e4a36f41SAndroid Build Coastguard Workerallow incidentd system_file:file lock; 136*e4a36f41SAndroid Build Coastguard Worker# Incidentd should never exec from the memory (e.g. JIT cache). These denials are expected. 137*e4a36f41SAndroid Build Coastguard Workerdontaudit incidentd dalvikcache_data_file:dir r_dir_perms; 138*e4a36f41SAndroid Build Coastguard Workerdontaudit incidentd tmpfs:file rwx_file_perms; 139*e4a36f41SAndroid Build Coastguard Worker 140*e4a36f41SAndroid Build Coastguard Worker# logd access - work to be done is a PII safe log (possibly an event log?) 141*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`read_logd(incidentd)') 142*e4a36f41SAndroid Build Coastguard Worker# TODO control_logd(incidentd) 143*e4a36f41SAndroid Build Coastguard Worker 144*e4a36f41SAndroid Build Coastguard Worker# Access /data/misc/logd 145*e4a36f41SAndroid Build Coastguard Workerr_dir_file(incidentd, misc_logd_file) 146*e4a36f41SAndroid Build Coastguard Worker 147*e4a36f41SAndroid Build Coastguard Worker# Allow incidentd to find these standard groups of services. 148*e4a36f41SAndroid Build Coastguard Worker# Others can be allowlisted individually. 149*e4a36f41SAndroid Build Coastguard Workerallow incidentd { 150*e4a36f41SAndroid Build Coastguard Worker system_server_service 151*e4a36f41SAndroid Build Coastguard Worker app_api_service 152*e4a36f41SAndroid Build Coastguard Worker system_api_service 153*e4a36f41SAndroid Build Coastguard Worker}:service_manager find; 154*e4a36f41SAndroid Build Coastguard Worker 155*e4a36f41SAndroid Build Coastguard Worker# Only incidentd can publish the binder service 156*e4a36f41SAndroid Build Coastguard Workeradd_service(incidentd, incident_service) 157*e4a36f41SAndroid Build Coastguard Worker 158*e4a36f41SAndroid Build Coastguard Worker# Allow pipes only from dumpstate and incident 159*e4a36f41SAndroid Build Coastguard Workerallow incidentd { dumpstate incident }:fd use; 160*e4a36f41SAndroid Build Coastguard Workerallow incidentd { dumpstate incident }:fifo_file write; 161*e4a36f41SAndroid Build Coastguard Worker 162*e4a36f41SAndroid Build Coastguard Worker# Allow incident to call back to incident with status updates. 163*e4a36f41SAndroid Build Coastguard Workerbinder_call(incidentd, incident) 164*e4a36f41SAndroid Build Coastguard Worker 165*e4a36f41SAndroid Build Coastguard Worker# Read device serial number from system properties 166*e4a36f41SAndroid Build Coastguard Worker# This is used to track reports from lab testing devices 167*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 168*e4a36f41SAndroid Build Coastguard Worker get_prop(incidentd, serialno_prop) 169*e4a36f41SAndroid Build Coastguard Worker') 170*e4a36f41SAndroid Build Coastguard Worker 171*e4a36f41SAndroid Build Coastguard Worker# Read ro.boot.bootreason, persist.sys.boot.bootreason 172*e4a36f41SAndroid Build Coastguard Worker# This is used to track reports from lab testing devices 173*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 174*e4a36f41SAndroid Build Coastguard Worker get_prop(incidentd, bootloader_boot_reason_prop); 175*e4a36f41SAndroid Build Coastguard Worker get_prop(incidentd, system_boot_reason_prop); 176*e4a36f41SAndroid Build Coastguard Worker get_prop(incidentd, last_boot_reason_prop); 177*e4a36f41SAndroid Build Coastguard Worker') 178*e4a36f41SAndroid Build Coastguard Worker 179*e4a36f41SAndroid Build Coastguard Worker### 180*e4a36f41SAndroid Build Coastguard Worker### neverallow rules 181*e4a36f41SAndroid Build Coastguard Worker### 182*e4a36f41SAndroid Build Coastguard Worker# only incidentd and the other root services in limited circumstances 183*e4a36f41SAndroid Build Coastguard Worker# can get to the files in /data/misc/incidents 184*e4a36f41SAndroid Build Coastguard Worker# 185*e4a36f41SAndroid Build Coastguard Worker# write, execute, append are forbidden almost everywhere 186*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -incidentd -init -vold } incident_data_file:file { 187*e4a36f41SAndroid Build Coastguard Worker w_file_perms 188*e4a36f41SAndroid Build Coastguard Worker x_file_perms 189*e4a36f41SAndroid Build Coastguard Worker create 190*e4a36f41SAndroid Build Coastguard Worker rename 191*e4a36f41SAndroid Build Coastguard Worker setattr 192*e4a36f41SAndroid Build Coastguard Worker unlink 193*e4a36f41SAndroid Build Coastguard Worker append 194*e4a36f41SAndroid Build Coastguard Worker}; 195*e4a36f41SAndroid Build Coastguard Worker# read is also allowed by system_server, for when the file is handed to dropbox 196*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -incidentd -init -vold -system_server } incident_data_file:file r_file_perms; 197*e4a36f41SAndroid Build Coastguard Worker# limited access to the directory itself 198*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -incidentd -init -vold } incident_data_file:dir create_dir_perms; 199*e4a36f41SAndroid Build Coastguard Worker 200