xref: /aosp_15_r20/system/sepolicy/prebuilts/api/29.0/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 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# Create and write into /data/misc/incidents
53*e4a36f41SAndroid Build Coastguard Workerallow incidentd incident_data_file:dir rw_dir_perms;
54*e4a36f41SAndroid Build Coastguard Workerallow incidentd incident_data_file:file create_file_perms;
55*e4a36f41SAndroid Build Coastguard Worker
56*e4a36f41SAndroid Build Coastguard Worker# Enable incidentd to get stack traces.
57*e4a36f41SAndroid Build Coastguard Workerbinder_use(incidentd)
58*e4a36f41SAndroid Build Coastguard Workerhwbinder_use(incidentd)
59*e4a36f41SAndroid Build Coastguard Workerallow incidentd hwservicemanager:hwservice_manager { list };
60*e4a36f41SAndroid Build Coastguard Workerget_prop(incidentd, hwservicemanager_prop)
61*e4a36f41SAndroid Build Coastguard Workerallow incidentd hidl_manager_hwservice:hwservice_manager { find };
62*e4a36f41SAndroid Build Coastguard Worker
63*e4a36f41SAndroid Build Coastguard Worker# Read files in /proc
64*e4a36f41SAndroid Build Coastguard Workerallow incidentd {
65*e4a36f41SAndroid Build Coastguard Worker  proc_cmdline
66*e4a36f41SAndroid Build Coastguard Worker  proc_pipe_conf
67*e4a36f41SAndroid Build Coastguard Worker  proc_stat
68*e4a36f41SAndroid Build Coastguard Worker}:file r_file_perms;
69*e4a36f41SAndroid Build Coastguard Worker
70*e4a36f41SAndroid Build Coastguard Worker# Signal java processes to dump their stack and get the results
71*e4a36f41SAndroid Build Coastguard Workerallow incidentd { appdomain ephemeral_app system_server }:process signal;
72*e4a36f41SAndroid Build Coastguard Worker
73*e4a36f41SAndroid Build Coastguard Worker# Signal native processes to dump their stack.
74*e4a36f41SAndroid Build Coastguard Worker# This list comes from native_processes_to_dump in incidentd/utils.c
75*e4a36f41SAndroid Build Coastguard Workerallow incidentd {
76*e4a36f41SAndroid Build Coastguard Worker  # This list comes from native_processes_to_dump in dumputils/dump_utils.cpp
77*e4a36f41SAndroid Build Coastguard Worker  audioserver
78*e4a36f41SAndroid Build Coastguard Worker  cameraserver
79*e4a36f41SAndroid Build Coastguard Worker  drmserver
80*e4a36f41SAndroid Build Coastguard Worker  inputflinger
81*e4a36f41SAndroid Build Coastguard Worker  mediadrmserver
82*e4a36f41SAndroid Build Coastguard Worker  mediaextractor
83*e4a36f41SAndroid Build Coastguard Worker  mediametrics
84*e4a36f41SAndroid Build Coastguard Worker  mediaserver
85*e4a36f41SAndroid Build Coastguard Worker  sdcardd
86*e4a36f41SAndroid Build Coastguard Worker  statsd
87*e4a36f41SAndroid Build Coastguard Worker  surfaceflinger
88*e4a36f41SAndroid Build Coastguard Worker
89*e4a36f41SAndroid Build Coastguard Worker  # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.cpp
90*e4a36f41SAndroid Build Coastguard Worker  hal_audio_server
91*e4a36f41SAndroid Build Coastguard Worker  hal_bluetooth_server
92*e4a36f41SAndroid Build Coastguard Worker  hal_camera_server
93*e4a36f41SAndroid Build Coastguard Worker  hal_codec2_server
94*e4a36f41SAndroid Build Coastguard Worker  hal_face_server
95*e4a36f41SAndroid Build Coastguard Worker  hal_graphics_allocator_server
96*e4a36f41SAndroid Build Coastguard Worker  hal_graphics_composer_server
97*e4a36f41SAndroid Build Coastguard Worker  hal_health_server
98*e4a36f41SAndroid Build Coastguard Worker  hal_omx_server
99*e4a36f41SAndroid Build Coastguard Worker  hal_sensors_server
100*e4a36f41SAndroid Build Coastguard Worker  hal_vr_server
101*e4a36f41SAndroid Build Coastguard Worker}:process signal;
102*e4a36f41SAndroid Build Coastguard Worker
103*e4a36f41SAndroid Build Coastguard Worker# Allow incidentd to make binder calls to any binder service
104*e4a36f41SAndroid Build Coastguard Workerbinder_call(incidentd, system_server)
105*e4a36f41SAndroid Build Coastguard Workerbinder_call(incidentd, appdomain)
106*e4a36f41SAndroid Build Coastguard Worker
107*e4a36f41SAndroid Build Coastguard Worker# Reading /proc/PID/maps of other processes
108*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`allow incidentd self:global_capability_class_set { sys_ptrace }');
109*e4a36f41SAndroid Build Coastguard Worker# incidentd has capability sys_ptrace, but should only use that capability for
110*e4a36f41SAndroid Build Coastguard Worker# accessing sensitive /proc/PID files, never for using ptrace attach.
111*e4a36f41SAndroid Build Coastguard Workerneverallow incidentd *:process ptrace;
112*e4a36f41SAndroid Build Coastguard Worker
113*e4a36f41SAndroid Build Coastguard Workerallow incidentd self:global_capability_class_set {
114*e4a36f41SAndroid Build Coastguard Worker    # Send signals to processes
115*e4a36f41SAndroid Build Coastguard Worker    kill
116*e4a36f41SAndroid Build Coastguard Worker};
117*e4a36f41SAndroid Build Coastguard Worker
118*e4a36f41SAndroid Build Coastguard Worker# Connect to tombstoned to intercept dumps.
119*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(incidentd, tombstoned_intercept, tombstoned)
120*e4a36f41SAndroid Build Coastguard Worker
121*e4a36f41SAndroid Build Coastguard Worker# Run a shell.
122*e4a36f41SAndroid Build Coastguard Workerallow incidentd shell_exec:file rx_file_perms;
123*e4a36f41SAndroid Build Coastguard Worker
124*e4a36f41SAndroid Build Coastguard Worker# logd access - work to be done is a PII safe log (possibly an event log?)
125*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`read_logd(incidentd)')
126*e4a36f41SAndroid Build Coastguard Worker# TODO control_logd(incidentd)
127*e4a36f41SAndroid Build Coastguard Worker
128*e4a36f41SAndroid Build Coastguard Worker# Allow incidentd to find these standard groups of services.
129*e4a36f41SAndroid Build Coastguard Worker# Others can be allowlisted individually.
130*e4a36f41SAndroid Build Coastguard Workerallow incidentd {
131*e4a36f41SAndroid Build Coastguard Worker  system_server_service
132*e4a36f41SAndroid Build Coastguard Worker  app_api_service
133*e4a36f41SAndroid Build Coastguard Worker  system_api_service
134*e4a36f41SAndroid Build Coastguard Worker}:service_manager find;
135*e4a36f41SAndroid Build Coastguard Worker
136*e4a36f41SAndroid Build Coastguard Worker# Only incidentd can publish the binder service
137*e4a36f41SAndroid Build Coastguard Workeradd_service(incidentd, incident_service)
138*e4a36f41SAndroid Build Coastguard Worker
139*e4a36f41SAndroid Build Coastguard Worker# Allow pipes only from dumpstate and incident
140*e4a36f41SAndroid Build Coastguard Workerallow incidentd { dumpstate incident }:fd use;
141*e4a36f41SAndroid Build Coastguard Workerallow incidentd { dumpstate incident }:fifo_file write;
142*e4a36f41SAndroid Build Coastguard Worker
143*e4a36f41SAndroid Build Coastguard Worker# Allow incident to call back to incident with status updates.
144*e4a36f41SAndroid Build Coastguard Workerbinder_call(incidentd, incident)
145*e4a36f41SAndroid Build Coastguard Worker
146*e4a36f41SAndroid Build Coastguard Worker###
147*e4a36f41SAndroid Build Coastguard Worker### neverallow rules
148*e4a36f41SAndroid Build Coastguard Worker###
149*e4a36f41SAndroid Build Coastguard Worker
150*e4a36f41SAndroid Build Coastguard Worker# only dumpstate, system_server, system_app and incident command can find the incident service
151*e4a36f41SAndroid Build Coastguard Workerneverallow {
152*e4a36f41SAndroid Build Coastguard Worker  domain
153*e4a36f41SAndroid Build Coastguard Worker  -dumpstate
154*e4a36f41SAndroid Build Coastguard Worker  -incident
155*e4a36f41SAndroid Build Coastguard Worker  -incidentd
156*e4a36f41SAndroid Build Coastguard Worker  -priv_app
157*e4a36f41SAndroid Build Coastguard Worker  -statsd
158*e4a36f41SAndroid Build Coastguard Worker  -system_app
159*e4a36f41SAndroid Build Coastguard Worker  -system_server
160*e4a36f41SAndroid Build Coastguard Worker} incident_service:service_manager find;
161*e4a36f41SAndroid Build Coastguard Worker
162*e4a36f41SAndroid Build Coastguard Worker# only incidentd and the other root services in limited circumstances
163*e4a36f41SAndroid Build Coastguard Worker# can get to the files in /data/misc/incidents
164*e4a36f41SAndroid Build Coastguard Worker#
165*e4a36f41SAndroid Build Coastguard Worker# write, execute, append are forbidden almost everywhere
166*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -incidentd -init -vold } incident_data_file:file {
167*e4a36f41SAndroid Build Coastguard Worker  w_file_perms
168*e4a36f41SAndroid Build Coastguard Worker  x_file_perms
169*e4a36f41SAndroid Build Coastguard Worker  create
170*e4a36f41SAndroid Build Coastguard Worker  rename
171*e4a36f41SAndroid Build Coastguard Worker  setattr
172*e4a36f41SAndroid Build Coastguard Worker  unlink
173*e4a36f41SAndroid Build Coastguard Worker  append
174*e4a36f41SAndroid Build Coastguard Worker};
175*e4a36f41SAndroid Build Coastguard Worker# read is also allowed by system_server, for when the file is handed to dropbox
176*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -incidentd -init -vold -system_server } incident_data_file:file r_file_perms;
177*e4a36f41SAndroid Build Coastguard Worker# limited access to the directory itself
178*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -incidentd -init -vold } incident_data_file:dir create_dir_perms;
179*e4a36f41SAndroid Build Coastguard Worker
180