blob: e86b3bfd52fb68f728efd821cff477713cfc8a57 [file] [log] [blame]
Alex Klyubinf5446eb2017-03-23 14:27:32 -07001typeattribute incidentd coredomain;
Yi Jinbc24ba72018-01-22 14:00:46 -08002typeattribute incidentd mlstrustedsubject;
Alex Klyubinf5446eb2017-03-23 14:27:32 -07003
Joe Onorato41f93db2016-11-20 23:23:04 -08004init_daemon_domain(incidentd)
Nick Kralevich5e372712018-09-27 10:21:37 -07005type incidentd_exec, system_file_type, exec_type, file_type;
Joe Onorato41f93db2016-11-20 23:23:04 -08006binder_use(incidentd)
7wakelock_use(incidentd)
8
Joe Onorato41f93db2016-11-20 23:23:04 -08009# Allow incidentd to scan through /proc/pid for all processes
10r_dir_file(incidentd, domain)
11
Yi Jinbc24ba72018-01-22 14:00:46 -080012# Allow incidentd to kill incident_helper when timeout
13allow incidentd incident_helper:process sigkill;
Joe Onorato41f93db2016-11-20 23:23:04 -080014
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
Yi Jin880de352018-06-26 14:17:04 -070022# section id 1002, allow reading kernel version /proc/version
23allow incidentd proc_version:file r_file_perms;
24
Alex Hong4d750b52021-04-01 22:05:22 +080025# section id 1116, allow accessing statsd socket
26unix_socket_send(incidentd, statsdw, statsd)
27
Yi Jinbc24ba72018-01-22 14:00:46 -080028# 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
Hridya Valsaraju23f9f512021-05-04 22:01:51 -070032no_debugfs_restriction(`
33 allow incidentd debugfs_wakeup_sources:file r_file_perms;
34')
Yi Jinbc24ba72018-01-22 14:00:46 -080035
36# section id 2003, allow executing top
37allow incidentd proc_meminfo:file { open read };
38
39# section id 2004, allow reading /sys/devices/system/cpu/cpufreq/all_time_in_state
40allow incidentd sysfs_devices_system_cpu:file r_file_perms;
41
Kweku Adams06ac7db2018-03-06 17:42:35 -080042# section id 2005, allow reading ps dump in full
43allow incidentd domain:process getattr;
44
Yi Jinbc24ba72018-01-22 14:00:46 -080045# section id 2006, allow reading /sys/class/power_supply/bms/battery_type
46allow incidentd sysfs_batteryinfo:dir { search };
47allow incidentd sysfs_batteryinfo:file r_file_perms;
48
Yi Jin76238cd2018-03-30 10:14:08 -070049# section id 2007, allow reading LAST_KMSG /sys/fs/pstore/console-ramoops
50userdebug_or_eng(`allow incidentd pstorefs:dir search');
51userdebug_or_eng(`allow incidentd pstorefs:file r_file_perms');
52
Bookatzd2f3d182018-11-05 15:01:39 -080053# section id 3023, allow obtaining stats report
54allow incidentd stats_service:service_manager find;
55binder_call(incidentd, statsd)
56
Ryan Savitski72f247f2019-05-29 17:50:44 +010057# section id 3026, allow reading /data/misc/perfetto-traces.
Florian Mayer487bf1c2020-03-26 17:19:21 +010058allow incidentd perfetto_traces_data_file:dir r_dir_perms;
59allow incidentd perfetto_traces_data_file:file r_file_perms;
Ryan Savitski72f247f2019-05-29 17:50:44 +010060
Alex Hong8b230722021-03-09 18:02:33 +080061# section id 3052, allow accessing nfc_service
62allow incidentd nfc_service:service_manager find;
63
Joe Onorato41f93db2016-11-20 23:23:04 -080064# Create and write into /data/misc/incidents
65allow incidentd incident_data_file:dir rw_dir_perms;
66allow incidentd incident_data_file:file create_file_perms;
67
Kweku Adams985db6d2018-03-12 16:21:40 -070068# Enable incidentd to get stack traces.
69binder_use(incidentd)
70hwbinder_use(incidentd)
71allow incidentd hwservicemanager:hwservice_manager { list };
72get_prop(incidentd, hwservicemanager_prop)
73allow incidentd hidl_manager_hwservice:hwservice_manager { find };
Joe Onorato41f93db2016-11-20 23:23:04 -080074
Kweku Adams06ac7db2018-03-06 17:42:35 -080075# Read files in /proc
76allow incidentd {
Kweku Adams985db6d2018-03-12 16:21:40 -070077 proc_cmdline
Alistair Delva2bbf1ce2020-12-02 16:04:12 -080078 proc_pid_max
Kweku Adams985db6d2018-03-12 16:21:40 -070079 proc_pipe_conf
Kweku Adams06ac7db2018-03-06 17:42:35 -080080 proc_stat
81}:file r_file_perms;
82
Joe Onorato41f93db2016-11-20 23:23:04 -080083# Signal java processes to dump their stack and get the results
Kweku Adams985db6d2018-03-12 16:21:40 -070084allow incidentd { appdomain ephemeral_app system_server }:process signal;
Joe Onorato41f93db2016-11-20 23:23:04 -080085
86# Signal native processes to dump their stack.
87# This list comes from native_processes_to_dump in incidentd/utils.c
88allow incidentd {
Kweku Adams985db6d2018-03-12 16:21:40 -070089 # This list comes from native_processes_to_dump in dumputils/dump_utils.cpp
Joe Onorato41f93db2016-11-20 23:23:04 -080090 audioserver
91 cameraserver
92 drmserver
93 inputflinger
Joe Onorato41f93db2016-11-20 23:23:04 -080094 mediadrmserver
95 mediaextractor
Kweku Adams985db6d2018-03-12 16:21:40 -070096 mediametrics
Joe Onorato41f93db2016-11-20 23:23:04 -080097 mediaserver
98 sdcardd
Kweku Adams985db6d2018-03-12 16:21:40 -070099 statsd
Joe Onorato41f93db2016-11-20 23:23:04 -0800100 surfaceflinger
Kweku Adams985db6d2018-03-12 16:21:40 -0700101
102 # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.cpp
103 hal_audio_server
104 hal_bluetooth_server
105 hal_camera_server
Pawin Vongmasa609c2432019-04-30 05:09:28 -0700106 hal_codec2_server
Kevin Chyn6d976f42019-06-19 11:12:11 -0700107 hal_face_server
Chia-I Wu7c5e18c2018-08-09 15:56:09 -0700108 hal_graphics_allocator_server
Kweku Adams985db6d2018-03-12 16:21:40 -0700109 hal_graphics_composer_server
Yifan Hong0d53ef22018-11-27 17:35:31 -0800110 hal_health_server
Steven Moreland7baf7252018-05-25 16:23:37 -0700111 hal_omx_server
Kweku Adams985db6d2018-03-12 16:21:40 -0700112 hal_sensors_server
113 hal_vr_server
Joe Onorato41f93db2016-11-20 23:23:04 -0800114}:process signal;
115
116# Allow incidentd to make binder calls to any binder service
Yi Jinbc24ba72018-01-22 14:00:46 -0800117binder_call(incidentd, system_server)
Joe Onorato41f93db2016-11-20 23:23:04 -0800118binder_call(incidentd, appdomain)
119
120# Reading /proc/PID/maps of other processes
Kweku Adams985db6d2018-03-12 16:21:40 -0700121userdebug_or_eng(`allow incidentd self:global_capability_class_set { sys_ptrace }');
122# incidentd has capability sys_ptrace, but should only use that capability for
123# accessing sensitive /proc/PID files, never for using ptrace attach.
124neverallow incidentd *:process ptrace;
125
126allow incidentd self:global_capability_class_set {
127 # Send signals to processes
128 kill
129};
130
131# Connect to tombstoned to intercept dumps.
132unix_socket_connect(incidentd, tombstoned_intercept, tombstoned)
Joe Onorato41f93db2016-11-20 23:23:04 -0800133
134# Run a shell.
135allow incidentd shell_exec:file rx_file_perms;
136
Mike Ma08f494d2020-01-17 19:00:16 -0800137# For running am, incident-helper-cmd and similar framework commands.
138# Run /system/bin/app_process.
139allow incidentd zygote_exec:file { rx_file_perms };
Mike Maab619352020-02-11 12:56:36 -0800140# Access the runtime feature flag properties.
141get_prop(incidentd, device_config_runtime_native_prop)
142get_prop(incidentd, device_config_runtime_native_boot_prop)
Orion Hodson2abf1e22021-07-09 14:54:27 +0100143# Access odsign verification status.
144get_prop(incidentd, odsign_prop)
Mike Maab619352020-02-11 12:56:36 -0800145# ART locks profile files.
146allow incidentd system_file:file lock;
147# Incidentd should never exec from the memory (e.g. JIT cache). These denials are expected.
148dontaudit incidentd dalvikcache_data_file:dir r_dir_perms;
Orion Hodson8f75f762020-10-16 15:29:55 +0100149dontaudit incidentd apex_module_data_file:dir r_dir_perms;
150dontaudit incidentd apex_art_data_file:dir r_dir_perms;
Mike Maab619352020-02-11 12:56:36 -0800151dontaudit incidentd tmpfs:file rwx_file_perms;
Mike Ma08f494d2020-01-17 19:00:16 -0800152
Nicolas Geoffray7a2693b2021-10-09 15:46:44 +0100153# Allow incidentd to read /apex/apex-info-list.xml
154allow incidentd apex_info_file:file r_file_perms;
155
Joe Onorato41f93db2016-11-20 23:23:04 -0800156# logd access - work to be done is a PII safe log (possibly an event log?)
Yi Jinbc24ba72018-01-22 14:00:46 -0800157userdebug_or_eng(`read_logd(incidentd)')
Joe Onorato41f93db2016-11-20 23:23:04 -0800158# TODO control_logd(incidentd)
159
Mike Ma08f494d2020-01-17 19:00:16 -0800160# Access /data/misc/logd
Mike Maab619352020-02-11 12:56:36 -0800161r_dir_file(incidentd, misc_logd_file)
Mike Ma08f494d2020-01-17 19:00:16 -0800162
Joe Onorato41f93db2016-11-20 23:23:04 -0800163# Allow incidentd to find these standard groups of services.
Jeff Sharkeya0e7a6d2020-07-31 12:28:11 -0600164# Others can be allowlisted individually.
Joe Onorato41f93db2016-11-20 23:23:04 -0800165allow incidentd {
166 system_server_service
167 app_api_service
168 system_api_service
Carmen Jacksona60d7f22021-06-23 16:53:45 -0700169 -tracingproxy_service
Joe Onorato41f93db2016-11-20 23:23:04 -0800170}:service_manager find;
171
172# Only incidentd can publish the binder service
173add_service(incidentd, incident_service)
174
Mike Made3a3e42018-12-03 10:35:40 -0800175# Allow pipes only from dumpstate and incident
176allow incidentd { dumpstate incident }:fd use;
177allow incidentd { dumpstate incident }:fifo_file write;
Joe Onorato41f93db2016-11-20 23:23:04 -0800178
179# Allow incident to call back to incident with status updates.
180binder_call(incidentd, incident)
181
zhouwenjiec8ae8fa2019-10-25 13:45:06 -0700182# Read device serial number from system properties
183# This is used to track reports from lab testing devices
184userdebug_or_eng(`
185 get_prop(incidentd, serialno_prop)
186')
187
Wenjie Zhou27d52552020-04-09 14:43:00 -0700188# Read ro.boot.bootreason, persist.sys.boot.bootreason
189# This is used to track reports from lab testing devices
190userdebug_or_eng(`
191 get_prop(incidentd, bootloader_boot_reason_prop);
192 get_prop(incidentd, system_boot_reason_prop);
193 get_prop(incidentd, last_boot_reason_prop);
194')
195
Alex Hong4c23abb2023-02-01 17:50:57 +0800196# Allow incident to read the build properties for attestation feature
197get_prop(incidentd, build_attestation_prop);
198
Joe Onorato41f93db2016-11-20 23:23:04 -0800199###
200### neverallow rules
201###
Joe Onorato41f93db2016-11-20 23:23:04 -0800202# only incidentd and the other root services in limited circumstances
203# can get to the files in /data/misc/incidents
204#
205# write, execute, append are forbidden almost everywhere
206neverallow { domain -incidentd -init -vold } incident_data_file:file {
207 w_file_perms
208 x_file_perms
209 create
210 rename
211 setattr
212 unlink
213 append
214};
215# read is also allowed by system_server, for when the file is handed to dropbox
216neverallow { domain -incidentd -init -vold -system_server } incident_data_file:file r_file_perms;
217# limited access to the directory itself
218neverallow { domain -incidentd -init -vold } incident_data_file:dir create_dir_perms;
219