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