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