blob: 0c57f0f0a6964bb968d1649c39e1e337f96eaba0 [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.
53# TODO(b/134706389): remove when no longer used.
54userdebug_or_eng(`
55 allow incidentd perfetto_traces_data_file:dir r_dir_perms;
56 allow incidentd perfetto_traces_data_file:file r_file_perms;
57');
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
73 proc_pipe_conf
Kweku Adams06ac7db2018-03-06 17:42:35 -080074 proc_stat
75}:file r_file_perms;
76
Joe Onorato41f93db2016-11-20 23:23:04 -080077# Signal java processes to dump their stack and get the results
Kweku Adams985db6d2018-03-12 16:21:40 -070078allow incidentd { appdomain ephemeral_app system_server }:process signal;
Joe Onorato41f93db2016-11-20 23:23:04 -080079
80# Signal native processes to dump their stack.
81# This list comes from native_processes_to_dump in incidentd/utils.c
82allow incidentd {
Kweku Adams985db6d2018-03-12 16:21:40 -070083 # This list comes from native_processes_to_dump in dumputils/dump_utils.cpp
Joe Onorato41f93db2016-11-20 23:23:04 -080084 audioserver
85 cameraserver
86 drmserver
87 inputflinger
Joe Onorato41f93db2016-11-20 23:23:04 -080088 mediadrmserver
89 mediaextractor
Kweku Adams985db6d2018-03-12 16:21:40 -070090 mediametrics
Joe Onorato41f93db2016-11-20 23:23:04 -080091 mediaserver
92 sdcardd
Kweku Adams985db6d2018-03-12 16:21:40 -070093 statsd
Joe Onorato41f93db2016-11-20 23:23:04 -080094 surfaceflinger
Kweku Adams985db6d2018-03-12 16:21:40 -070095
96 # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.cpp
97 hal_audio_server
98 hal_bluetooth_server
99 hal_camera_server
Pawin Vongmasa609c2432019-04-30 05:09:28 -0700100 hal_codec2_server
Kevin Chyn6d976f42019-06-19 11:12:11 -0700101 hal_face_server
Chia-I Wu7c5e18c2018-08-09 15:56:09 -0700102 hal_graphics_allocator_server
Kweku Adams985db6d2018-03-12 16:21:40 -0700103 hal_graphics_composer_server
Yifan Hong0d53ef22018-11-27 17:35:31 -0800104 hal_health_server
Steven Moreland7baf7252018-05-25 16:23:37 -0700105 hal_omx_server
Kweku Adams985db6d2018-03-12 16:21:40 -0700106 hal_sensors_server
107 hal_vr_server
Joe Onorato41f93db2016-11-20 23:23:04 -0800108}:process signal;
109
110# Allow incidentd to make binder calls to any binder service
Yi Jinbc24ba72018-01-22 14:00:46 -0800111binder_call(incidentd, system_server)
Joe Onorato41f93db2016-11-20 23:23:04 -0800112binder_call(incidentd, appdomain)
113
114# Reading /proc/PID/maps of other processes
Kweku Adams985db6d2018-03-12 16:21:40 -0700115userdebug_or_eng(`allow incidentd self:global_capability_class_set { sys_ptrace }');
116# incidentd has capability sys_ptrace, but should only use that capability for
117# accessing sensitive /proc/PID files, never for using ptrace attach.
118neverallow incidentd *:process ptrace;
119
120allow incidentd self:global_capability_class_set {
121 # Send signals to processes
122 kill
123};
124
125# Connect to tombstoned to intercept dumps.
126unix_socket_connect(incidentd, tombstoned_intercept, tombstoned)
Joe Onorato41f93db2016-11-20 23:23:04 -0800127
128# Run a shell.
129allow incidentd shell_exec:file rx_file_perms;
130
131# logd access - work to be done is a PII safe log (possibly an event log?)
Yi Jinbc24ba72018-01-22 14:00:46 -0800132userdebug_or_eng(`read_logd(incidentd)')
Joe Onorato41f93db2016-11-20 23:23:04 -0800133# TODO control_logd(incidentd)
134
135# Allow incidentd to find these standard groups of services.
136# Others can be whitelisted individually.
137allow incidentd {
138 system_server_service
139 app_api_service
140 system_api_service
141}:service_manager find;
142
143# Only incidentd can publish the binder service
144add_service(incidentd, incident_service)
145
Mike Made3a3e42018-12-03 10:35:40 -0800146# Allow pipes only from dumpstate and incident
147allow incidentd { dumpstate incident }:fd use;
148allow incidentd { dumpstate incident }:fifo_file write;
Joe Onorato41f93db2016-11-20 23:23:04 -0800149
150# Allow incident to call back to incident with status updates.
151binder_call(incidentd, incident)
152
153###
154### neverallow rules
155###
156
Ryan Savitski72f247f2019-05-29 17:50:44 +0100157# only specific domains can find the incident service
158# TODO(b/134706389): remove "perfetto" when no longer used.
yrocf38ca52018-01-22 13:56:41 -0800159neverallow {
160 domain
Mike Made3a3e42018-12-03 10:35:40 -0800161 -dumpstate
yrocf38ca52018-01-22 13:56:41 -0800162 -incident
163 -incidentd
Ryan Savitski72f247f2019-05-29 17:50:44 +0100164 userdebug_or_eng(`-perfetto')
Joe Onorato9cc5c092019-03-16 15:45:45 -0700165 -priv_app
yrocf38ca52018-01-22 13:56:41 -0800166 -statsd
167 -system_app
168 -system_server
169} incident_service:service_manager find;
Joe Onorato41f93db2016-11-20 23:23:04 -0800170
171# only incidentd and the other root services in limited circumstances
172# can get to the files in /data/misc/incidents
173#
174# write, execute, append are forbidden almost everywhere
175neverallow { domain -incidentd -init -vold } incident_data_file:file {
176 w_file_perms
177 x_file_perms
178 create
179 rename
180 setattr
181 unlink
182 append
183};
184# read is also allowed by system_server, for when the file is handed to dropbox
185neverallow { domain -incidentd -init -vold -system_server } incident_data_file:file r_file_perms;
186# limited access to the directory itself
187neverallow { domain -incidentd -init -vold } incident_data_file:dir create_dir_perms;
188