blob: 824dece286d4d2496cc8461920239b5cfb34d53f [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
Joe Onorato41f93db2016-11-20 23:23:04 -080041# Create and write into /data/misc/incidents
42allow incidentd incident_data_file:dir rw_dir_perms;
43allow incidentd incident_data_file:file create_file_perms;
44
45# Get process attributes
46# TODO allow incidentd domain:process getattr;
47
Kweku Adams06ac7db2018-03-06 17:42:35 -080048# Read files in /proc
49allow incidentd {
50 proc_stat
51}:file r_file_perms;
52
Joe Onorato41f93db2016-11-20 23:23:04 -080053# Signal java processes to dump their stack and get the results
54# TODO allow incidentd { appdomain ephemeral_app system_server }:process signal;
Yi Jinbc24ba72018-01-22 14:00:46 -080055# TODO allow incidentd anr_data_file:dir create_dir_perms;
Joe Onorato41f93db2016-11-20 23:23:04 -080056# TODO allow incidentd anr_data_file:file create_file_perms;
57
58# Signal native processes to dump their stack.
59# This list comes from native_processes_to_dump in incidentd/utils.c
60allow incidentd {
61 audioserver
62 cameraserver
63 drmserver
64 inputflinger
65 mediacodec
66 mediadrmserver
67 mediaextractor
68 mediaserver
69 sdcardd
70 surfaceflinger
71}:process signal;
72
73# Allow incidentd to make binder calls to any binder service
Yi Jinbc24ba72018-01-22 14:00:46 -080074binder_call(incidentd, system_server)
Joe Onorato41f93db2016-11-20 23:23:04 -080075binder_call(incidentd, appdomain)
76
77# Reading /proc/PID/maps of other processes
Benjamin Gordon9b2e0cb2017-11-09 15:51:26 -070078# TODO allow incidentd self:global_capability_class_set sys_ptrace;
Joe Onorato41f93db2016-11-20 23:23:04 -080079
80# Run a shell.
81allow incidentd shell_exec:file rx_file_perms;
82
83# logd access - work to be done is a PII safe log (possibly an event log?)
Yi Jinbc24ba72018-01-22 14:00:46 -080084userdebug_or_eng(`read_logd(incidentd)')
Joe Onorato41f93db2016-11-20 23:23:04 -080085# TODO control_logd(incidentd)
86
87# Allow incidentd to find these standard groups of services.
88# Others can be whitelisted individually.
89allow incidentd {
90 system_server_service
91 app_api_service
92 system_api_service
93}:service_manager find;
94
95# Only incidentd can publish the binder service
96add_service(incidentd, incident_service)
97
98# Allow pipes from (and only from) incident
99allow incidentd incident:fd use;
100allow incidentd incident:fifo_file write;
101
102# Allow incident to call back to incident with status updates.
103binder_call(incidentd, incident)
104
105###
106### neverallow rules
107###
108
109# only system_server, system_app and incident command can find the incident service
yrocf38ca52018-01-22 13:56:41 -0800110neverallow {
111 domain
112 -incident
113 -incidentd
114 -statsd
115 -system_app
116 -system_server
117} incident_service:service_manager find;
Joe Onorato41f93db2016-11-20 23:23:04 -0800118
119# only incidentd and the other root services in limited circumstances
120# can get to the files in /data/misc/incidents
121#
122# write, execute, append are forbidden almost everywhere
123neverallow { domain -incidentd -init -vold } incident_data_file:file {
124 w_file_perms
125 x_file_perms
126 create
127 rename
128 setattr
129 unlink
130 append
131};
132# read is also allowed by system_server, for when the file is handed to dropbox
133neverallow { domain -incidentd -init -vold -system_server } incident_data_file:file r_file_perms;
134# limited access to the directory itself
135neverallow { domain -incidentd -init -vold } incident_data_file:dir create_dir_perms;
136