blob: a574eee830c30fa73a6e65be35e230c28d641472 [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
Alex Hong4d750b52021-04-01 22:05:22 +080025# section id 1116, allow accessing statsd socket
26unix_socket_send(incidentd, statsdw, statsd)
27
Yi Jinbc24ba72018-01-22 14:00:46 -080028# section id 2001, allow reading /proc/pagetypeinfo
29allow incidentd proc_pagetypeinfo:file r_file_perms;
30
31# section id 2002, allow reading /d/wakeup_sources
32allow incidentd debugfs_wakeup_sources:file r_file_perms;
33
34# section id 2003, allow executing top
35allow incidentd proc_meminfo:file { open read };
36
37# section id 2004, allow reading /sys/devices/system/cpu/cpufreq/all_time_in_state
38allow incidentd sysfs_devices_system_cpu:file r_file_perms;
39
Kweku Adams06ac7db2018-03-06 17:42:35 -080040# section id 2005, allow reading ps dump in full
41allow incidentd domain:process getattr;
42
Yi Jinbc24ba72018-01-22 14:00:46 -080043# section id 2006, allow reading /sys/class/power_supply/bms/battery_type
44allow incidentd sysfs_batteryinfo:dir { search };
45allow incidentd sysfs_batteryinfo:file r_file_perms;
46
Yi Jin76238cd2018-03-30 10:14:08 -070047# section id 2007, allow reading LAST_KMSG /sys/fs/pstore/console-ramoops
48userdebug_or_eng(`allow incidentd pstorefs:dir search');
49userdebug_or_eng(`allow incidentd pstorefs:file r_file_perms');
50
Bookatzd2f3d182018-11-05 15:01:39 -080051# section id 3023, allow obtaining stats report
52allow incidentd stats_service:service_manager find;
53binder_call(incidentd, statsd)
54
Ryan Savitski72f247f2019-05-29 17:50:44 +010055# section id 3026, allow reading /data/misc/perfetto-traces.
Florian Mayer487bf1c2020-03-26 17:19:21 +010056allow incidentd perfetto_traces_data_file:dir r_dir_perms;
57allow incidentd perfetto_traces_data_file:file r_file_perms;
Ryan Savitski72f247f2019-05-29 17:50:44 +010058
Alex Hong8b230722021-03-09 18:02:33 +080059# section id 3052, allow accessing nfc_service
60allow incidentd nfc_service:service_manager find;
61
Joe Onorato41f93db2016-11-20 23:23:04 -080062# Create and write into /data/misc/incidents
63allow incidentd incident_data_file:dir rw_dir_perms;
64allow incidentd incident_data_file:file create_file_perms;
65
Kweku Adams985db6d2018-03-12 16:21:40 -070066# Enable incidentd to get stack traces.
67binder_use(incidentd)
68hwbinder_use(incidentd)
69allow incidentd hwservicemanager:hwservice_manager { list };
70get_prop(incidentd, hwservicemanager_prop)
71allow incidentd hidl_manager_hwservice:hwservice_manager { find };
Joe Onorato41f93db2016-11-20 23:23:04 -080072
Kweku Adams06ac7db2018-03-06 17:42:35 -080073# Read files in /proc
74allow incidentd {
Kweku Adams985db6d2018-03-12 16:21:40 -070075 proc_cmdline
Alistair Delva2bbf1ce2020-12-02 16:04:12 -080076 proc_pid_max
Kweku Adams985db6d2018-03-12 16:21:40 -070077 proc_pipe_conf
Kweku Adams06ac7db2018-03-06 17:42:35 -080078 proc_stat
79}:file r_file_perms;
80
Joe Onorato41f93db2016-11-20 23:23:04 -080081# Signal java processes to dump their stack and get the results
Kweku Adams985db6d2018-03-12 16:21:40 -070082allow incidentd { appdomain ephemeral_app system_server }:process signal;
Joe Onorato41f93db2016-11-20 23:23:04 -080083
84# Signal native processes to dump their stack.
85# This list comes from native_processes_to_dump in incidentd/utils.c
86allow incidentd {
Kweku Adams985db6d2018-03-12 16:21:40 -070087 # This list comes from native_processes_to_dump in dumputils/dump_utils.cpp
Joe Onorato41f93db2016-11-20 23:23:04 -080088 audioserver
89 cameraserver
90 drmserver
91 inputflinger
Joe Onorato41f93db2016-11-20 23:23:04 -080092 mediadrmserver
93 mediaextractor
Kweku Adams985db6d2018-03-12 16:21:40 -070094 mediametrics
Joe Onorato41f93db2016-11-20 23:23:04 -080095 mediaserver
96 sdcardd
Kweku Adams985db6d2018-03-12 16:21:40 -070097 statsd
Joe Onorato41f93db2016-11-20 23:23:04 -080098 surfaceflinger
Kweku Adams985db6d2018-03-12 16:21:40 -070099
100 # This list comes from hal_interfaces_to_dump in dumputils/dump_utils.cpp
101 hal_audio_server
102 hal_bluetooth_server
103 hal_camera_server
Pawin Vongmasa609c2432019-04-30 05:09:28 -0700104 hal_codec2_server
Kevin Chyn6d976f42019-06-19 11:12:11 -0700105 hal_face_server
Chia-I Wu7c5e18c2018-08-09 15:56:09 -0700106 hal_graphics_allocator_server
Kweku Adams985db6d2018-03-12 16:21:40 -0700107 hal_graphics_composer_server
Yifan Hong0d53ef22018-11-27 17:35:31 -0800108 hal_health_server
Steven Moreland7baf7252018-05-25 16:23:37 -0700109 hal_omx_server
Kweku Adams985db6d2018-03-12 16:21:40 -0700110 hal_sensors_server
111 hal_vr_server
Joe Onorato41f93db2016-11-20 23:23:04 -0800112}:process signal;
113
114# Allow incidentd to make binder calls to any binder service
Yi Jinbc24ba72018-01-22 14:00:46 -0800115binder_call(incidentd, system_server)
Joe Onorato41f93db2016-11-20 23:23:04 -0800116binder_call(incidentd, appdomain)
117
118# Reading /proc/PID/maps of other processes
Kweku Adams985db6d2018-03-12 16:21:40 -0700119userdebug_or_eng(`allow incidentd self:global_capability_class_set { sys_ptrace }');
120# incidentd has capability sys_ptrace, but should only use that capability for
121# accessing sensitive /proc/PID files, never for using ptrace attach.
122neverallow incidentd *:process ptrace;
123
124allow incidentd self:global_capability_class_set {
125 # Send signals to processes
126 kill
127};
128
129# Connect to tombstoned to intercept dumps.
130unix_socket_connect(incidentd, tombstoned_intercept, tombstoned)
Joe Onorato41f93db2016-11-20 23:23:04 -0800131
132# Run a shell.
133allow incidentd shell_exec:file rx_file_perms;
134
Mike Ma08f494d2020-01-17 19:00:16 -0800135# For running am, incident-helper-cmd and similar framework commands.
136# Run /system/bin/app_process.
137allow incidentd zygote_exec:file { rx_file_perms };
Mike Maab619352020-02-11 12:56:36 -0800138# Access the runtime feature flag properties.
139get_prop(incidentd, device_config_runtime_native_prop)
140get_prop(incidentd, device_config_runtime_native_boot_prop)
141# ART locks profile files.
142allow incidentd system_file:file lock;
143# Incidentd should never exec from the memory (e.g. JIT cache). These denials are expected.
144dontaudit incidentd dalvikcache_data_file:dir r_dir_perms;
Orion Hodson8f75f762020-10-16 15:29:55 +0100145dontaudit incidentd apex_module_data_file:dir r_dir_perms;
146dontaudit incidentd apex_art_data_file:dir r_dir_perms;
Mike Maab619352020-02-11 12:56:36 -0800147dontaudit incidentd tmpfs:file rwx_file_perms;
Mike Ma08f494d2020-01-17 19:00:16 -0800148
Joe Onorato41f93db2016-11-20 23:23:04 -0800149# logd access - work to be done is a PII safe log (possibly an event log?)
Yi Jinbc24ba72018-01-22 14:00:46 -0800150userdebug_or_eng(`read_logd(incidentd)')
Joe Onorato41f93db2016-11-20 23:23:04 -0800151# TODO control_logd(incidentd)
152
Mike Ma08f494d2020-01-17 19:00:16 -0800153# Access /data/misc/logd
Mike Maab619352020-02-11 12:56:36 -0800154r_dir_file(incidentd, misc_logd_file)
Mike Ma08f494d2020-01-17 19:00:16 -0800155
Joe Onorato41f93db2016-11-20 23:23:04 -0800156# Allow incidentd to find these standard groups of services.
Jeff Sharkeya0e7a6d2020-07-31 12:28:11 -0600157# Others can be allowlisted individually.
Joe Onorato41f93db2016-11-20 23:23:04 -0800158allow incidentd {
159 system_server_service
160 app_api_service
161 system_api_service
162}:service_manager find;
163
164# Only incidentd can publish the binder service
165add_service(incidentd, incident_service)
166
Mike Made3a3e42018-12-03 10:35:40 -0800167# Allow pipes only from dumpstate and incident
168allow incidentd { dumpstate incident }:fd use;
169allow incidentd { dumpstate incident }:fifo_file write;
Joe Onorato41f93db2016-11-20 23:23:04 -0800170
171# Allow incident to call back to incident with status updates.
172binder_call(incidentd, incident)
173
zhouwenjiec8ae8fa2019-10-25 13:45:06 -0700174# Read device serial number from system properties
175# This is used to track reports from lab testing devices
176userdebug_or_eng(`
177 get_prop(incidentd, serialno_prop)
178')
179
Wenjie Zhou27d52552020-04-09 14:43:00 -0700180# Read ro.boot.bootreason, persist.sys.boot.bootreason
181# This is used to track reports from lab testing devices
182userdebug_or_eng(`
183 get_prop(incidentd, bootloader_boot_reason_prop);
184 get_prop(incidentd, system_boot_reason_prop);
185 get_prop(incidentd, last_boot_reason_prop);
186')
187
Joe Onorato41f93db2016-11-20 23:23:04 -0800188###
189### neverallow rules
190###
Joe Onorato41f93db2016-11-20 23:23:04 -0800191# only incidentd and the other root services in limited circumstances
192# can get to the files in /data/misc/incidents
193#
194# write, execute, append are forbidden almost everywhere
195neverallow { domain -incidentd -init -vold } incident_data_file:file {
196 w_file_perms
197 x_file_perms
198 create
199 rename
200 setattr
201 unlink
202 append
203};
204# read is also allowed by system_server, for when the file is handed to dropbox
205neverallow { domain -incidentd -init -vold -system_server } incident_data_file:file r_file_perms;
206# limited access to the directory itself
207neverallow { domain -incidentd -init -vold } incident_data_file:dir create_dir_perms;
208