blob: b88526347577ea7154081c804cec534c8e4ccd22 [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
34# section id 2006, allow reading /sys/class/power_supply/bms/battery_type
35allow incidentd sysfs_batteryinfo:dir { search };
36allow incidentd sysfs_batteryinfo:file r_file_perms;
37
Joe Onorato41f93db2016-11-20 23:23:04 -080038# Create and write into /data/misc/incidents
39allow incidentd incident_data_file:dir rw_dir_perms;
40allow incidentd incident_data_file:file create_file_perms;
41
42# Get process attributes
43# TODO allow incidentd domain:process getattr;
44
45# Signal java processes to dump their stack and get the results
46# TODO allow incidentd { appdomain ephemeral_app system_server }:process signal;
Yi Jinbc24ba72018-01-22 14:00:46 -080047# TODO allow incidentd anr_data_file:dir create_dir_perms;
Joe Onorato41f93db2016-11-20 23:23:04 -080048# TODO allow incidentd anr_data_file:file create_file_perms;
49
50# Signal native processes to dump their stack.
51# This list comes from native_processes_to_dump in incidentd/utils.c
52allow incidentd {
53 audioserver
54 cameraserver
55 drmserver
56 inputflinger
57 mediacodec
58 mediadrmserver
59 mediaextractor
60 mediaserver
61 sdcardd
62 surfaceflinger
63}:process signal;
64
65# Allow incidentd to make binder calls to any binder service
Yi Jinbc24ba72018-01-22 14:00:46 -080066binder_call(incidentd, system_server)
Joe Onorato41f93db2016-11-20 23:23:04 -080067binder_call(incidentd, appdomain)
68
69# Reading /proc/PID/maps of other processes
Benjamin Gordon9b2e0cb2017-11-09 15:51:26 -070070# TODO allow incidentd self:global_capability_class_set sys_ptrace;
Joe Onorato41f93db2016-11-20 23:23:04 -080071
72# Run a shell.
73allow incidentd shell_exec:file rx_file_perms;
74
75# logd access - work to be done is a PII safe log (possibly an event log?)
Yi Jinbc24ba72018-01-22 14:00:46 -080076userdebug_or_eng(`read_logd(incidentd)')
Joe Onorato41f93db2016-11-20 23:23:04 -080077# TODO control_logd(incidentd)
78
79# Allow incidentd to find these standard groups of services.
80# Others can be whitelisted individually.
81allow incidentd {
82 system_server_service
83 app_api_service
84 system_api_service
85}:service_manager find;
86
87# Only incidentd can publish the binder service
88add_service(incidentd, incident_service)
89
90# Allow pipes from (and only from) incident
91allow incidentd incident:fd use;
92allow incidentd incident:fifo_file write;
93
94# Allow incident to call back to incident with status updates.
95binder_call(incidentd, incident)
96
97###
98### neverallow rules
99###
100
101# only system_server, system_app and incident command can find the incident service
102neverallow { domain -system_server -system_app -incident -incidentd } incident_service:service_manager find;
103
104# only incidentd and the other root services in limited circumstances
105# can get to the files in /data/misc/incidents
106#
107# write, execute, append are forbidden almost everywhere
108neverallow { domain -incidentd -init -vold } incident_data_file:file {
109 w_file_perms
110 x_file_perms
111 create
112 rename
113 setattr
114 unlink
115 append
116};
117# read is also allowed by system_server, for when the file is handed to dropbox
118neverallow { domain -incidentd -init -vold -system_server } incident_data_file:file r_file_perms;
119# limited access to the directory itself
120neverallow { domain -incidentd -init -vold } incident_data_file:dir create_dir_perms;
121