2016-12-07 01:49:25 +01:00
|
|
|
# perfprofd - perf profile collection daemon
|
2017-04-20 20:40:24 +02:00
|
|
|
type perfprofd, domain;
|
2018-09-27 19:21:37 +02:00
|
|
|
type perfprofd_exec, system_file_type, exec_type, file_type;
|
2016-12-07 01:49:25 +01:00
|
|
|
|
|
|
|
userdebug_or_eng(`
|
|
|
|
|
2017-04-20 20:40:24 +02:00
|
|
|
typeattribute perfprofd coredomain;
|
|
|
|
typeattribute perfprofd mlstrustedsubject;
|
2016-12-07 01:49:25 +01:00
|
|
|
|
2017-12-13 23:37:07 +01:00
|
|
|
# perfprofd access to sysfs directory structure.
|
|
|
|
allow perfprofd sysfs_type:dir search;
|
|
|
|
|
2016-12-07 01:49:25 +01:00
|
|
|
# perfprofd needs to control CPU hot-plug in order to avoid kernel
|
|
|
|
# perfevents problems in cases where CPU goes on/off during measurement;
|
|
|
|
# this means read access to /sys/devices/system/cpu/possible
|
|
|
|
# and read/write access to /sys/devices/system/cpu/cpu*/online
|
|
|
|
allow perfprofd sysfs_devices_system_cpu:file rw_file_perms;
|
|
|
|
|
|
|
|
# perfprofd checks for the existence of and then invokes simpleperf;
|
|
|
|
# simpleperf retains perfprofd domain after exec
|
|
|
|
allow perfprofd system_file:file rx_file_perms;
|
|
|
|
|
|
|
|
# perfprofd reads a config file from /data/data/com.google.android.gms/files
|
2018-08-03 00:54:23 +02:00
|
|
|
allow perfprofd { privapp_data_file app_data_file }:file r_file_perms;
|
|
|
|
allow perfprofd { privapp_data_file app_data_file }:dir search;
|
2018-09-07 00:19:40 +02:00
|
|
|
allow perfprofd self:global_capability_class_set { dac_override dac_read_search };
|
2016-12-07 01:49:25 +01:00
|
|
|
|
|
|
|
# perfprofd opens a file for writing in /data/misc/perfprofd
|
|
|
|
allow perfprofd perfprofd_data_file:file create_file_perms;
|
|
|
|
allow perfprofd perfprofd_data_file:dir rw_dir_perms;
|
|
|
|
|
|
|
|
# perfprofd uses the system log
|
|
|
|
read_logd(perfprofd);
|
|
|
|
write_logd(perfprofd);
|
|
|
|
|
|
|
|
# perfprofd inspects /sys/power/wake_unlock
|
|
|
|
wakelock_use(perfprofd);
|
|
|
|
|
2017-12-05 19:54:38 +01:00
|
|
|
# perfprofd looks at thermals.
|
|
|
|
allow perfprofd sysfs_thermal:dir r_dir_perms;
|
|
|
|
|
2018-07-17 02:19:38 +02:00
|
|
|
# perfprofd gets charging status.
|
|
|
|
hal_client_domain(perfprofd, hal_health)
|
2017-12-05 19:54:38 +01:00
|
|
|
|
2017-12-06 19:17:32 +01:00
|
|
|
# simpleperf reads kernel notes.
|
|
|
|
allow perfprofd sysfs_kernel_notes:file r_file_perms;
|
|
|
|
|
2017-12-05 19:54:38 +01:00
|
|
|
# Simpleperf & perfprofd query a range of proc stats.
|
|
|
|
allow perfprofd proc_loadavg:file r_file_perms;
|
|
|
|
allow perfprofd proc_stat:file r_file_perms;
|
|
|
|
allow perfprofd proc_modules:file r_file_perms;
|
|
|
|
|
|
|
|
# simpleperf writes to perf_event_paranoid under /proc.
|
|
|
|
allow perfprofd proc_perf:file write;
|
|
|
|
|
|
|
|
# Simpleperf: kptr_restrict. This would be required to dump kernel symbols.
|
|
|
|
dontaudit perfprofd proc_security:file *;
|
|
|
|
|
2016-12-07 01:49:25 +01:00
|
|
|
# simpleperf uses ioctl() to turn on kernel perf events measurements
|
2017-11-09 23:51:26 +01:00
|
|
|
allow perfprofd self:global_capability_class_set sys_admin;
|
2016-12-07 01:49:25 +01:00
|
|
|
|
|
|
|
# simpleperf needs to examine /proc to collect task/thread info
|
|
|
|
r_dir_file(perfprofd, domain)
|
|
|
|
|
|
|
|
# simpleperf needs to access /proc/<pid>/exec
|
2017-11-09 23:51:26 +01:00
|
|
|
allow perfprofd self:global_capability_class_set { sys_resource sys_ptrace };
|
2016-12-07 01:49:25 +01:00
|
|
|
neverallow perfprofd domain:process ptrace;
|
|
|
|
|
|
|
|
# simpleperf needs open/read any file that turns up in a profile
|
|
|
|
# to see whether it has a build ID
|
|
|
|
allow perfprofd exec_type:file r_file_perms;
|
2017-12-05 19:54:38 +01:00
|
|
|
# App & ART artifacts.
|
|
|
|
r_dir_file(perfprofd, apk_data_file)
|
|
|
|
r_dir_file(perfprofd, dalvikcache_data_file)
|
|
|
|
# Vendor libraries.
|
|
|
|
r_dir_file(perfprofd, vendor_file)
|
|
|
|
# Vendor apps.
|
|
|
|
r_dir_file(perfprofd, vendor_app_file)
|
2018-10-18 21:39:35 +02:00
|
|
|
# SP HAL files.
|
|
|
|
r_dir_file(perfprofd, same_process_hal_file)
|
2017-12-05 19:54:38 +01:00
|
|
|
|
|
|
|
# simpleperf will set security.perf_harden to enable access to perf_event_open()
|
|
|
|
set_prop(perfprofd, shell_prop)
|
2016-12-07 01:49:25 +01:00
|
|
|
|
|
|
|
# simpleperf examines debugfs on startup to collect tracepoint event types
|
2017-12-05 19:54:38 +01:00
|
|
|
r_dir_file(perfprofd, debugfs_tracing)
|
2018-03-30 22:10:35 +02:00
|
|
|
r_dir_file(perfprofd, debugfs_tracing_debug)
|
2016-12-07 01:49:25 +01:00
|
|
|
|
|
|
|
# simpleperf is going to execute "sleep"
|
|
|
|
allow perfprofd toolbox_exec:file rx_file_perms;
|
2018-03-30 22:10:35 +02:00
|
|
|
# simpleperf is going to execute "mv" on a temp file
|
|
|
|
allow perfprofd shell_exec:file rx_file_perms;
|
2016-12-07 01:49:25 +01:00
|
|
|
|
|
|
|
# needed for simpleperf on some kernels
|
2017-11-09 23:51:26 +01:00
|
|
|
allow perfprofd self:global_capability_class_set ipc_lock;
|
2016-12-07 01:49:25 +01:00
|
|
|
|
2017-12-05 22:51:50 +01:00
|
|
|
# simpleperf attempts to put a temp file into /data/local/tmp. Do not allow,
|
|
|
|
# use the fallback cwd code, do not spam the log. But ensure this is correctly
|
|
|
|
# removed at some point. b/70232908.
|
|
|
|
dontaudit perfprofd shell_data_file:dir *;
|
|
|
|
dontaudit perfprofd shell_data_file:file *;
|
|
|
|
|
2017-12-22 22:05:28 +01:00
|
|
|
# Allow perfprofd to publish a binder service and make binder calls.
|
|
|
|
binder_use(perfprofd)
|
|
|
|
add_service(perfprofd, perfprofd_service)
|
|
|
|
|
|
|
|
# Use devpts for streams from cmd.
|
|
|
|
#
|
|
|
|
# This is normally granted to binderservicedomain, but this service
|
|
|
|
# has tighter restrictions on the callers (see below), so must enable
|
|
|
|
# this manually.
|
|
|
|
allow perfprofd devpts:chr_file rw_file_perms;
|
|
|
|
|
|
|
|
# Use socket & pipe supplied by su, for cmd perfprofd dump.
|
|
|
|
allow perfprofd su:unix_stream_socket { read write getattr sendto };
|
|
|
|
allow perfprofd su:fifo_file r_file_perms;
|
|
|
|
|
2018-01-12 18:39:20 +01:00
|
|
|
# Allow perfprofd to submit to dropbox.
|
|
|
|
allow perfprofd dropbox_service:service_manager find;
|
2018-01-30 18:48:35 +01:00
|
|
|
binder_call(perfprofd, system_server)
|
2016-12-07 01:49:25 +01:00
|
|
|
')
|