blob: 70e118748546d4c9681fc6489d0df25122bc0492 [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
Yi Jinbc24ba72018-01-22 14:00:46 -080025# section id 2001, allow reading /proc/pagetypeinfo
26allow incidentd proc_pagetypeinfo:file r_file_perms;
27
28# section id 2002, allow reading /d/wakeup_sources
29allow incidentd debugfs_wakeup_sources:file r_file_perms;
30
31# section id 2003, allow executing top
32allow incidentd proc_meminfo:file { open read };
33
34# section id 2004, allow reading /sys/devices/system/cpu/cpufreq/all_time_in_state
35allow incidentd sysfs_devices_system_cpu:file r_file_perms;
36
Kweku Adams06ac7db2018-03-06 17:42:35 -080037# section id 2005, allow reading ps dump in full
38allow incidentd domain:process getattr;
39
Yi Jinbc24ba72018-01-22 14:00:46 -080040# section id 2006, allow reading /sys/class/power_supply/bms/battery_type
41allow incidentd sysfs_batteryinfo:dir { search };
42allow incidentd sysfs_batteryinfo:file r_file_perms;
43
Yi Jin76238cd2018-03-30 10:14:08 -070044# section id 2007, allow reading LAST_KMSG /sys/fs/pstore/console-ramoops
45userdebug_or_eng(`allow incidentd pstorefs:dir search');
46userdebug_or_eng(`allow incidentd pstorefs:file r_file_perms');
47
Bookatzd2f3d182018-11-05 15:01:39 -080048# section id 3023, allow obtaining stats report
49allow incidentd stats_service:service_manager find;
50binder_call(incidentd, statsd)
51
Ryan Savitski72f247f2019-05-29 17:50:44 +010052# section id 3026, allow reading /data/misc/perfetto-traces.
Florian Mayer487bf1c2020-03-26 17:19:21 +010053allow incidentd perfetto_traces_data_file:dir r_dir_perms;
54allow incidentd perfetto_traces_data_file:file r_file_perms;
Ryan Savitski72f247f2019-05-29 17:50:44 +010055
Alex Hong8b230722021-03-09 18:02:33 +080056# section id 3052, allow accessing nfc_service
57allow incidentd nfc_service:service_manager find;
58
Joe Onorato41f93db2016-11-20 23:23:04 -080059# Create and write into /data/misc/incidents
60allow incidentd incident_data_file:dir rw_dir_perms;
61allow incidentd incident_data_file:file create_file_perms;
62
Kweku Adams985db6d2018-03-12 16:21:40 -070063# Enable incidentd to get stack traces.
64binder_use(incidentd)
65hwbinder_use(incidentd)
66allow incidentd hwservicemanager:hwservice_manager { list };
67get_prop(incidentd, hwservicemanager_prop)
68allow incidentd hidl_manager_hwservice:hwservice_manager { find };
Joe Onorato41f93db2016-11-20 23:23:04 -080069
Kweku Adams06ac7db2018-03-06 17:42:35 -080070# Read files in /proc
71allow incidentd {
Kweku Adams985db6d2018-03-12 16:21:40 -070072 proc_cmdline
Alistair Delva2bbf1ce2020-12-02 16:04:12 -080073 proc_pid_max
Kweku Adams985db6d2018-03-12 16:21:40 -070074 proc_pipe_conf
Kweku Adams06ac7db2018-03-06 17:42:35 -080075 proc_stat
76}:file r_file_perms;
77
Joe Onorato41f93db2016-11-20 23:23:04 -080078# Signal java processes to dump their stack and get the results
Kweku Adams985db6d2018-03-12 16:21:40 -070079allow incidentd { appdomain ephemeral_app system_server }:process signal;
Joe Onorato41f93db2016-11-20 23:23:04 -080080
81# Signal native processes to dump their stack.
82# This list comes from native_processes_to_dump in incidentd/utils.c
83allow incidentd {
Kweku Adams985db6d2018-03-12 16:21:40 -070084 # This list comes from native_processes_to_dump in dumputils/dump_utils.cpp
Joe Onorato41f93db2016-11-20 23:23:04 -080085 audioserver
86 cameraserver
87 drmserver
88 inputflinger
Joe Onorato41f93db2016-11-20 23:23:04 -080089 mediadrmserver
90 mediaextractor
Kweku Adams985db6d2018-03-12 16:21:40 -070091 mediametrics
Joe Onorato41f93db2016-11-20 23:23:04 -080092 mediaserver
93 sdcardd
Kweku Adams985db6d2018-03-12 16:21:40 -070094 statsd
Joe Onorato41f93db2016-11-20 23:23:04 -080095 surfaceflinger
Kweku Adams985db6d2018-03-12 16:21:40 -070096
97 # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.cpp
98 hal_audio_server
99 hal_bluetooth_server
100 hal_camera_server
Pawin Vongmasa609c2432019-04-30 05:09:28 -0700101 hal_codec2_server
Kevin Chyn6d976f42019-06-19 11:12:11 -0700102 hal_face_server
Chia-I Wu7c5e18c2018-08-09 15:56:09 -0700103 hal_graphics_allocator_server
Kweku Adams985db6d2018-03-12 16:21:40 -0700104 hal_graphics_composer_server
Yifan Hong0d53ef22018-11-27 17:35:31 -0800105 hal_health_server
Steven Moreland7baf7252018-05-25 16:23:37 -0700106 hal_omx_server
Kweku Adams985db6d2018-03-12 16:21:40 -0700107 hal_sensors_server
108 hal_vr_server
Joe Onorato41f93db2016-11-20 23:23:04 -0800109}:process signal;
110
111# Allow incidentd to make binder calls to any binder service
Yi Jinbc24ba72018-01-22 14:00:46 -0800112binder_call(incidentd, system_server)
Joe Onorato41f93db2016-11-20 23:23:04 -0800113binder_call(incidentd, appdomain)
114
115# Reading /proc/PID/maps of other processes
Kweku Adams985db6d2018-03-12 16:21:40 -0700116userdebug_or_eng(`allow incidentd self:global_capability_class_set { sys_ptrace }');
117# incidentd has capability sys_ptrace, but should only use that capability for
118# accessing sensitive /proc/PID files, never for using ptrace attach.
119neverallow incidentd *:process ptrace;
120
121allow incidentd self:global_capability_class_set {
122 # Send signals to processes
123 kill
124};
125
126# Connect to tombstoned to intercept dumps.
127unix_socket_connect(incidentd, tombstoned_intercept, tombstoned)
Joe Onorato41f93db2016-11-20 23:23:04 -0800128
129# Run a shell.
130allow incidentd shell_exec:file rx_file_perms;
131
Mike Ma08f494d2020-01-17 19:00:16 -0800132# For running am, incident-helper-cmd and similar framework commands.
133# Run /system/bin/app_process.
134allow incidentd zygote_exec:file { rx_file_perms };
Mike Maab619352020-02-11 12:56:36 -0800135# Access the runtime feature flag properties.
136get_prop(incidentd, device_config_runtime_native_prop)
137get_prop(incidentd, device_config_runtime_native_boot_prop)
138# ART locks profile files.
139allow incidentd system_file:file lock;
140# Incidentd should never exec from the memory (e.g. JIT cache). These denials are expected.
141dontaudit incidentd dalvikcache_data_file:dir r_dir_perms;
Orion Hodson8f75f762020-10-16 15:29:55 +0100142dontaudit incidentd apex_module_data_file:dir r_dir_perms;
143dontaudit incidentd apex_art_data_file:dir r_dir_perms;
Mike Maab619352020-02-11 12:56:36 -0800144dontaudit incidentd tmpfs:file rwx_file_perms;
Mike Ma08f494d2020-01-17 19:00:16 -0800145
Joe Onorato41f93db2016-11-20 23:23:04 -0800146# logd access - work to be done is a PII safe log (possibly an event log?)
Yi Jinbc24ba72018-01-22 14:00:46 -0800147userdebug_or_eng(`read_logd(incidentd)')
Joe Onorato41f93db2016-11-20 23:23:04 -0800148# TODO control_logd(incidentd)
149
Mike Ma08f494d2020-01-17 19:00:16 -0800150# Access /data/misc/logd
Mike Maab619352020-02-11 12:56:36 -0800151r_dir_file(incidentd, misc_logd_file)
Mike Ma08f494d2020-01-17 19:00:16 -0800152
Joe Onorato41f93db2016-11-20 23:23:04 -0800153# Allow incidentd to find these standard groups of services.
Jeff Sharkeya0e7a6d2020-07-31 12:28:11 -0600154# Others can be allowlisted individually.
Joe Onorato41f93db2016-11-20 23:23:04 -0800155allow incidentd {
156 system_server_service
157 app_api_service
158 system_api_service
159}:service_manager find;
160
161# Only incidentd can publish the binder service
162add_service(incidentd, incident_service)
163
Mike Made3a3e42018-12-03 10:35:40 -0800164# Allow pipes only from dumpstate and incident
165allow incidentd { dumpstate incident }:fd use;
166allow incidentd { dumpstate incident }:fifo_file write;
Joe Onorato41f93db2016-11-20 23:23:04 -0800167
168# Allow incident to call back to incident with status updates.
169binder_call(incidentd, incident)
170
zhouwenjiec8ae8fa2019-10-25 13:45:06 -0700171# Read device serial number from system properties
172# This is used to track reports from lab testing devices
173userdebug_or_eng(`
174 get_prop(incidentd, serialno_prop)
175')
176
Wenjie Zhou27d52552020-04-09 14:43:00 -0700177# Read ro.boot.bootreason, persist.sys.boot.bootreason
178# This is used to track reports from lab testing devices
179userdebug_or_eng(`
180 get_prop(incidentd, bootloader_boot_reason_prop);
181 get_prop(incidentd, system_boot_reason_prop);
182 get_prop(incidentd, last_boot_reason_prop);
183')
184
Joe Onorato41f93db2016-11-20 23:23:04 -0800185###
186### neverallow rules
187###
Joe Onorato41f93db2016-11-20 23:23:04 -0800188# only incidentd and the other root services in limited circumstances
189# can get to the files in /data/misc/incidents
190#
191# write, execute, append are forbidden almost everywhere
192neverallow { domain -incidentd -init -vold } incident_data_file:file {
193 w_file_perms
194 x_file_perms
195 create
196 rename
197 setattr
198 unlink
199 append
200};
201# read is also allowed by system_server, for when the file is handed to dropbox
202neverallow { domain -incidentd -init -vold -system_server } incident_data_file:file r_file_perms;
203# limited access to the directory itself
204neverallow { domain -incidentd -init -vold } incident_data_file:dir create_dir_perms;
205