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