blob: 4456e39f8c07a3194a6d8c2e4f96083c78485634 [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)
5type incidentd_exec, exec_type, file_type;
6binder_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
Joe Onorato41f93db2016-11-20 23:23:04 -080048# Create and write into /data/misc/incidents
49allow incidentd incident_data_file:dir rw_dir_perms;
50allow incidentd incident_data_file:file create_file_perms;
51
Kweku Adams985db6d2018-03-12 16:21:40 -070052# Enable incidentd to get stack traces.
53binder_use(incidentd)
54hwbinder_use(incidentd)
55allow incidentd hwservicemanager:hwservice_manager { list };
56get_prop(incidentd, hwservicemanager_prop)
57allow incidentd hidl_manager_hwservice:hwservice_manager { find };
Joe Onorato41f93db2016-11-20 23:23:04 -080058
Kweku Adams06ac7db2018-03-06 17:42:35 -080059# Read files in /proc
60allow incidentd {
Kweku Adams985db6d2018-03-12 16:21:40 -070061 proc_cmdline
62 proc_pipe_conf
Kweku Adams06ac7db2018-03-06 17:42:35 -080063 proc_stat
64}:file r_file_perms;
65
Joe Onorato41f93db2016-11-20 23:23:04 -080066# Signal java processes to dump their stack and get the results
Kweku Adams985db6d2018-03-12 16:21:40 -070067allow incidentd { appdomain ephemeral_app system_server }:process signal;
Joe Onorato41f93db2016-11-20 23:23:04 -080068
69# Signal native processes to dump their stack.
70# This list comes from native_processes_to_dump in incidentd/utils.c
71allow incidentd {
Kweku Adams985db6d2018-03-12 16:21:40 -070072 # This list comes from native_processes_to_dump in dumputils/dump_utils.cpp
Joe Onorato41f93db2016-11-20 23:23:04 -080073 audioserver
74 cameraserver
75 drmserver
76 inputflinger
Joe Onorato41f93db2016-11-20 23:23:04 -080077 mediadrmserver
78 mediaextractor
Kweku Adams985db6d2018-03-12 16:21:40 -070079 mediametrics
Joe Onorato41f93db2016-11-20 23:23:04 -080080 mediaserver
81 sdcardd
Kweku Adams985db6d2018-03-12 16:21:40 -070082 statsd
Joe Onorato41f93db2016-11-20 23:23:04 -080083 surfaceflinger
Kweku Adams985db6d2018-03-12 16:21:40 -070084
85 # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.cpp
86 hal_audio_server
87 hal_bluetooth_server
88 hal_camera_server
89 hal_graphics_composer_server
Steven Moreland7baf7252018-05-25 16:23:37 -070090 hal_omx_server
Kweku Adams985db6d2018-03-12 16:21:40 -070091 hal_sensors_server
92 hal_vr_server
Joe Onorato41f93db2016-11-20 23:23:04 -080093}:process signal;
94
95# Allow incidentd to make binder calls to any binder service
Yi Jinbc24ba72018-01-22 14:00:46 -080096binder_call(incidentd, system_server)
Joe Onorato41f93db2016-11-20 23:23:04 -080097binder_call(incidentd, appdomain)
98
99# Reading /proc/PID/maps of other processes
Kweku Adams985db6d2018-03-12 16:21:40 -0700100userdebug_or_eng(`allow incidentd self:global_capability_class_set { sys_ptrace }');
101# incidentd has capability sys_ptrace, but should only use that capability for
102# accessing sensitive /proc/PID files, never for using ptrace attach.
103neverallow incidentd *:process ptrace;
104
105allow incidentd self:global_capability_class_set {
106 # Send signals to processes
107 kill
108};
109
110# Connect to tombstoned to intercept dumps.
111unix_socket_connect(incidentd, tombstoned_intercept, tombstoned)
Joe Onorato41f93db2016-11-20 23:23:04 -0800112
113# Run a shell.
114allow incidentd shell_exec:file rx_file_perms;
115
116# logd access - work to be done is a PII safe log (possibly an event log?)
Yi Jinbc24ba72018-01-22 14:00:46 -0800117userdebug_or_eng(`read_logd(incidentd)')
Joe Onorato41f93db2016-11-20 23:23:04 -0800118# TODO control_logd(incidentd)
119
120# Allow incidentd to find these standard groups of services.
121# Others can be whitelisted individually.
122allow incidentd {
123 system_server_service
124 app_api_service
125 system_api_service
126}:service_manager find;
127
128# Only incidentd can publish the binder service
129add_service(incidentd, incident_service)
130
131# Allow pipes from (and only from) incident
132allow incidentd incident:fd use;
133allow incidentd incident:fifo_file write;
134
135# Allow incident to call back to incident with status updates.
136binder_call(incidentd, incident)
137
138###
139### neverallow rules
140###
141
142# only system_server, system_app and incident command can find the incident service
yrocf38ca52018-01-22 13:56:41 -0800143neverallow {
144 domain
145 -incident
146 -incidentd
147 -statsd
148 -system_app
149 -system_server
150} incident_service:service_manager find;
Joe Onorato41f93db2016-11-20 23:23:04 -0800151
152# only incidentd and the other root services in limited circumstances
153# can get to the files in /data/misc/incidents
154#
155# write, execute, append are forbidden almost everywhere
156neverallow { domain -incidentd -init -vold } incident_data_file:file {
157 w_file_perms
158 x_file_perms
159 create
160 rename
161 setattr
162 unlink
163 append
164};
165# read is also allowed by system_server, for when the file is handed to dropbox
166neverallow { domain -incidentd -init -vold -system_server } incident_data_file:file r_file_perms;
167# limited access to the directory itself
168neverallow { domain -incidentd -init -vold } incident_data_file:dir create_dir_perms;
169