perfprofd.te 1.77 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# perfprofd - perf profile collection daemon
type perfprofd_exec, exec_type, file_type;

userdebug_or_eng(`

  type perfprofd, domain, mlstrustedsubject;

  init_daemon_domain(perfprofd)

  # 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
21
  allow perfprofd app_data_file:file r_file_perms;
22 23 24
  allow perfprofd app_data_file:dir search;
  allow perfprofd self:capability { dac_override };

25 26 27
  # 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;
28 29 30 31 32 33 34 35

  # perfprofd uses the system log
  read_logd(perfprofd);
  write_logd(perfprofd);

  # simpleperf uses ioctl() to turn on kernel perf events measurements
  allow perfprofd self:capability sys_admin;

36 37 38 39 40 41 42 43 44 45 46
  # simpleperf needs to examine /proc to collect task/thread info
  r_dir_file(perfprofd, domain)

  # simpleperf needs to access /proc/<pid>/exec
  allow perfprofd self:capability { sys_resource sys_ptrace };
  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;

47 48 49 50
  # simpleperf is going to execute "sleep"
  allow perfprofd toolbox_exec:file x_file_perms;

')