blob: 6b248f181723dbb4ae092d3f82825a582f7b4250 [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 Jinbc24ba72018-01-22 14:00:46 -080022# section id 2001, allow reading /proc/pagetypeinfo
23allow incidentd proc_pagetypeinfo:file r_file_perms;
24
25# section id 2002, allow reading /d/wakeup_sources
26allow incidentd debugfs_wakeup_sources:file r_file_perms;
27
28# section id 2003, allow executing top
29allow incidentd proc_meminfo:file { open read };
30
31# section id 2004, allow reading /sys/devices/system/cpu/cpufreq/all_time_in_state
32allow incidentd sysfs_devices_system_cpu:file r_file_perms;
33
Kweku Adams06ac7db2018-03-06 17:42:35 -080034# section id 2005, allow reading ps dump in full
35allow incidentd domain:process getattr;
36
Yi Jinbc24ba72018-01-22 14:00:46 -080037# section id 2006, allow reading /sys/class/power_supply/bms/battery_type
38allow incidentd sysfs_batteryinfo:dir { search };
39allow incidentd sysfs_batteryinfo:file r_file_perms;
40
Yi Jin76238cd2018-03-30 10:14:08 -070041# section id 2007, allow reading LAST_KMSG /sys/fs/pstore/console-ramoops
42userdebug_or_eng(`allow incidentd pstorefs:dir search');
43userdebug_or_eng(`allow incidentd pstorefs:file r_file_perms');
44
Joe Onorato41f93db2016-11-20 23:23:04 -080045# Create and write into /data/misc/incidents
46allow incidentd incident_data_file:dir rw_dir_perms;
47allow incidentd incident_data_file:file create_file_perms;
48
Kweku Adams985db6d2018-03-12 16:21:40 -070049# Enable incidentd to get stack traces.
50binder_use(incidentd)
51hwbinder_use(incidentd)
52allow incidentd hwservicemanager:hwservice_manager { list };
53get_prop(incidentd, hwservicemanager_prop)
54allow incidentd hidl_manager_hwservice:hwservice_manager { find };
Joe Onorato41f93db2016-11-20 23:23:04 -080055
Kweku Adams06ac7db2018-03-06 17:42:35 -080056# Read files in /proc
57allow incidentd {
Kweku Adams985db6d2018-03-12 16:21:40 -070058 proc_cmdline
59 proc_pipe_conf
Kweku Adams06ac7db2018-03-06 17:42:35 -080060 proc_stat
61}:file r_file_perms;
62
Joe Onorato41f93db2016-11-20 23:23:04 -080063# Signal java processes to dump their stack and get the results
Kweku Adams985db6d2018-03-12 16:21:40 -070064allow incidentd { appdomain ephemeral_app system_server }:process signal;
Joe Onorato41f93db2016-11-20 23:23:04 -080065
66# Signal native processes to dump their stack.
67# This list comes from native_processes_to_dump in incidentd/utils.c
68allow incidentd {
Kweku Adams985db6d2018-03-12 16:21:40 -070069 # This list comes from native_processes_to_dump in dumputils/dump_utils.cpp
Joe Onorato41f93db2016-11-20 23:23:04 -080070 audioserver
71 cameraserver
72 drmserver
73 inputflinger
Joe Onorato41f93db2016-11-20 23:23:04 -080074 mediadrmserver
75 mediaextractor
Kweku Adams985db6d2018-03-12 16:21:40 -070076 mediametrics
Joe Onorato41f93db2016-11-20 23:23:04 -080077 mediaserver
78 sdcardd
Kweku Adams985db6d2018-03-12 16:21:40 -070079 statsd
Joe Onorato41f93db2016-11-20 23:23:04 -080080 surfaceflinger
Kweku Adams985db6d2018-03-12 16:21:40 -070081
82 # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.cpp
83 hal_audio_server
84 hal_bluetooth_server
85 hal_camera_server
86 hal_graphics_composer_server
87 hal_sensors_server
88 hal_vr_server
89 mediacodec # TODO(b/36375899): hal_omx_server
Joe Onorato41f93db2016-11-20 23:23:04 -080090}:process signal;
91
92# Allow incidentd to make binder calls to any binder service
Yi Jinbc24ba72018-01-22 14:00:46 -080093binder_call(incidentd, system_server)
Joe Onorato41f93db2016-11-20 23:23:04 -080094binder_call(incidentd, appdomain)
95
96# Reading /proc/PID/maps of other processes
Kweku Adams985db6d2018-03-12 16:21:40 -070097userdebug_or_eng(`allow incidentd self:global_capability_class_set { sys_ptrace }');
98# incidentd has capability sys_ptrace, but should only use that capability for
99# accessing sensitive /proc/PID files, never for using ptrace attach.
100neverallow incidentd *:process ptrace;
101
102allow incidentd self:global_capability_class_set {
103 # Send signals to processes
104 kill
105};
106
107# Connect to tombstoned to intercept dumps.
108unix_socket_connect(incidentd, tombstoned_intercept, tombstoned)
Joe Onorato41f93db2016-11-20 23:23:04 -0800109
110# Run a shell.
111allow incidentd shell_exec:file rx_file_perms;
112
113# logd access - work to be done is a PII safe log (possibly an event log?)
Yi Jinbc24ba72018-01-22 14:00:46 -0800114userdebug_or_eng(`read_logd(incidentd)')
Joe Onorato41f93db2016-11-20 23:23:04 -0800115# TODO control_logd(incidentd)
116
117# Allow incidentd to find these standard groups of services.
118# Others can be whitelisted individually.
119allow incidentd {
120 system_server_service
121 app_api_service
122 system_api_service
123}:service_manager find;
124
125# Only incidentd can publish the binder service
126add_service(incidentd, incident_service)
127
128# Allow pipes from (and only from) incident
129allow incidentd incident:fd use;
130allow incidentd incident:fifo_file write;
131
132# Allow incident to call back to incident with status updates.
133binder_call(incidentd, incident)
134
135###
136### neverallow rules
137###
138
139# only system_server, system_app and incident command can find the incident service
yrocf38ca52018-01-22 13:56:41 -0800140neverallow {
141 domain
142 -incident
143 -incidentd
144 -statsd
145 -system_app
146 -system_server
147} incident_service:service_manager find;
Joe Onorato41f93db2016-11-20 23:23:04 -0800148
149# only incidentd and the other root services in limited circumstances
150# can get to the files in /data/misc/incidents
151#
152# write, execute, append are forbidden almost everywhere
153neverallow { domain -incidentd -init -vold } incident_data_file:file {
154 w_file_perms
155 x_file_perms
156 create
157 rename
158 setattr
159 unlink
160 append
161};
162# read is also allowed by system_server, for when the file is handed to dropbox
163neverallow { domain -incidentd -init -vold -system_server } incident_data_file:file r_file_perms;
164# limited access to the directory itself
165neverallow { domain -incidentd -init -vold } incident_data_file:dir create_dir_perms;
166