blob: 656f69fed53a7cf117057aec1440d8deda1026a0 [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)
Nick Kralevich5e372712018-09-27 10:21:37 -07005type incidentd_exec, system_file_type, exec_type, file_type;
Joe Onorato41f93db2016-11-20 23:23:04 -08006binder_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
Bookatzd2f3d182018-11-05 15:01:39 -080048# section id 3023, allow obtaining stats report
49allow incidentd stats_service:service_manager find;
50binder_call(incidentd, statsd)
51
Ryan Savitski72f247f2019-05-29 17:50:44 +010052# section id 3026, allow reading /data/misc/perfetto-traces.
Florian Mayer487bf1c2020-03-26 17:19:21 +010053allow incidentd perfetto_traces_data_file:dir r_dir_perms;
54allow incidentd perfetto_traces_data_file:file r_file_perms;
Ryan Savitski72f247f2019-05-29 17:50:44 +010055
Joe Onorato41f93db2016-11-20 23:23:04 -080056# Create and write into /data/misc/incidents
57allow incidentd incident_data_file:dir rw_dir_perms;
58allow incidentd incident_data_file:file create_file_perms;
59
Kweku Adams985db6d2018-03-12 16:21:40 -070060# Enable incidentd to get stack traces.
61binder_use(incidentd)
62hwbinder_use(incidentd)
63allow incidentd hwservicemanager:hwservice_manager { list };
64get_prop(incidentd, hwservicemanager_prop)
65allow incidentd hidl_manager_hwservice:hwservice_manager { find };
Joe Onorato41f93db2016-11-20 23:23:04 -080066
Kweku Adams06ac7db2018-03-06 17:42:35 -080067# Read files in /proc
68allow incidentd {
Kweku Adams985db6d2018-03-12 16:21:40 -070069 proc_cmdline
70 proc_pipe_conf
Kweku Adams06ac7db2018-03-06 17:42:35 -080071 proc_stat
72}:file r_file_perms;
73
Joe Onorato41f93db2016-11-20 23:23:04 -080074# Signal java processes to dump their stack and get the results
Kweku Adams985db6d2018-03-12 16:21:40 -070075allow incidentd { appdomain ephemeral_app system_server }:process signal;
Joe Onorato41f93db2016-11-20 23:23:04 -080076
77# Signal native processes to dump their stack.
78# This list comes from native_processes_to_dump in incidentd/utils.c
79allow incidentd {
Kweku Adams985db6d2018-03-12 16:21:40 -070080 # This list comes from native_processes_to_dump in dumputils/dump_utils.cpp
Joe Onorato41f93db2016-11-20 23:23:04 -080081 audioserver
82 cameraserver
83 drmserver
84 inputflinger
Joe Onorato41f93db2016-11-20 23:23:04 -080085 mediadrmserver
86 mediaextractor
Kweku Adams985db6d2018-03-12 16:21:40 -070087 mediametrics
Joe Onorato41f93db2016-11-20 23:23:04 -080088 mediaserver
89 sdcardd
Kweku Adams985db6d2018-03-12 16:21:40 -070090 statsd
Joe Onorato41f93db2016-11-20 23:23:04 -080091 surfaceflinger
Kweku Adams985db6d2018-03-12 16:21:40 -070092
93 # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.cpp
94 hal_audio_server
95 hal_bluetooth_server
96 hal_camera_server
Pawin Vongmasa609c2432019-04-30 05:09:28 -070097 hal_codec2_server
Kevin Chyn6d976f42019-06-19 11:12:11 -070098 hal_face_server
Chia-I Wu7c5e18c2018-08-09 15:56:09 -070099 hal_graphics_allocator_server
Kweku Adams985db6d2018-03-12 16:21:40 -0700100 hal_graphics_composer_server
Yifan Hong0d53ef22018-11-27 17:35:31 -0800101 hal_health_server
Steven Moreland7baf7252018-05-25 16:23:37 -0700102 hal_omx_server
Kweku Adams985db6d2018-03-12 16:21:40 -0700103 hal_sensors_server
104 hal_vr_server
Joe Onorato41f93db2016-11-20 23:23:04 -0800105}:process signal;
106
107# Allow incidentd to make binder calls to any binder service
Yi Jinbc24ba72018-01-22 14:00:46 -0800108binder_call(incidentd, system_server)
Joe Onorato41f93db2016-11-20 23:23:04 -0800109binder_call(incidentd, appdomain)
110
111# Reading /proc/PID/maps of other processes
Kweku Adams985db6d2018-03-12 16:21:40 -0700112userdebug_or_eng(`allow incidentd self:global_capability_class_set { sys_ptrace }');
113# incidentd has capability sys_ptrace, but should only use that capability for
114# accessing sensitive /proc/PID files, never for using ptrace attach.
115neverallow incidentd *:process ptrace;
116
117allow incidentd self:global_capability_class_set {
118 # Send signals to processes
119 kill
120};
121
122# Connect to tombstoned to intercept dumps.
123unix_socket_connect(incidentd, tombstoned_intercept, tombstoned)
Joe Onorato41f93db2016-11-20 23:23:04 -0800124
125# Run a shell.
126allow incidentd shell_exec:file rx_file_perms;
127
Mike Ma08f494d2020-01-17 19:00:16 -0800128# For running am, incident-helper-cmd and similar framework commands.
129# Run /system/bin/app_process.
130allow incidentd zygote_exec:file { rx_file_perms };
Mike Maab619352020-02-11 12:56:36 -0800131# Access the runtime feature flag properties.
132get_prop(incidentd, device_config_runtime_native_prop)
133get_prop(incidentd, device_config_runtime_native_boot_prop)
134# ART locks profile files.
135allow incidentd system_file:file lock;
136# Incidentd should never exec from the memory (e.g. JIT cache). These denials are expected.
137dontaudit incidentd dalvikcache_data_file:dir r_dir_perms;
138dontaudit incidentd tmpfs:file rwx_file_perms;
Mike Ma08f494d2020-01-17 19:00:16 -0800139
Joe Onorato41f93db2016-11-20 23:23:04 -0800140# logd access - work to be done is a PII safe log (possibly an event log?)
Yi Jinbc24ba72018-01-22 14:00:46 -0800141userdebug_or_eng(`read_logd(incidentd)')
Joe Onorato41f93db2016-11-20 23:23:04 -0800142# TODO control_logd(incidentd)
143
Mike Ma08f494d2020-01-17 19:00:16 -0800144# Access /data/misc/logd
Mike Maab619352020-02-11 12:56:36 -0800145r_dir_file(incidentd, misc_logd_file)
Mike Ma08f494d2020-01-17 19:00:16 -0800146
Joe Onorato41f93db2016-11-20 23:23:04 -0800147# Allow incidentd to find these standard groups of services.
148# Others can be whitelisted individually.
149allow incidentd {
150 system_server_service
151 app_api_service
152 system_api_service
153}:service_manager find;
154
155# Only incidentd can publish the binder service
156add_service(incidentd, incident_service)
157
Mike Made3a3e42018-12-03 10:35:40 -0800158# Allow pipes only from dumpstate and incident
159allow incidentd { dumpstate incident }:fd use;
160allow incidentd { dumpstate incident }:fifo_file write;
Joe Onorato41f93db2016-11-20 23:23:04 -0800161
162# Allow incident to call back to incident with status updates.
163binder_call(incidentd, incident)
164
zhouwenjiec8ae8fa2019-10-25 13:45:06 -0700165# Read device serial number from system properties
166# This is used to track reports from lab testing devices
167userdebug_or_eng(`
168 get_prop(incidentd, serialno_prop)
169')
170
Wenjie Zhou27d52552020-04-09 14:43:00 -0700171# Read ro.boot.bootreason, persist.sys.boot.bootreason
172# This is used to track reports from lab testing devices
173userdebug_or_eng(`
174 get_prop(incidentd, bootloader_boot_reason_prop);
175 get_prop(incidentd, system_boot_reason_prop);
176 get_prop(incidentd, last_boot_reason_prop);
177')
178
Joe Onorato41f93db2016-11-20 23:23:04 -0800179###
180### neverallow rules
181###
Joe Onorato41f93db2016-11-20 23:23:04 -0800182# only incidentd and the other root services in limited circumstances
183# can get to the files in /data/misc/incidents
184#
185# write, execute, append are forbidden almost everywhere
186neverallow { domain -incidentd -init -vold } incident_data_file:file {
187 w_file_perms
188 x_file_perms
189 create
190 rename
191 setattr
192 unlink
193 append
194};
195# read is also allowed by system_server, for when the file is handed to dropbox
196neverallow { domain -incidentd -init -vold -system_server } incident_data_file:file r_file_perms;
197# limited access to the directory itself
198neverallow { domain -incidentd -init -vold } incident_data_file:dir create_dir_perms;
199