yro | 5744cbd | 2017-12-11 15:30:12 -0800 | [diff] [blame^] | 1 | type statsd, domain; |
| 2 | typeattribute statsd coredomain; |
| 3 | |
| 4 | init_daemon_domain(statsd) |
| 5 | |
| 6 | type statsd_exec, exec_type, file_type; |
| 7 | binder_use(statsd) |
| 8 | |
| 9 | # Allow statsd to scan through /proc/pid for all processes. |
| 10 | r_dir_file(statsd, domain) |
| 11 | |
| 12 | # Allow executing files on system, such as running a shell or running: |
| 13 | # /system/bin/toolbox |
| 14 | # /system/bin/logcat |
| 15 | # /system/bin/dumpsys |
| 16 | allow statsd shell_exec:file rx_file_perms; |
| 17 | allow statsd system_file:file execute_no_trans; |
| 18 | allow statsd toolbox_exec:file rx_file_perms; |
| 19 | |
| 20 | # Create, read, and write into /data/misc/stats-data, /data/misc/stats-system. |
| 21 | allow statsd stats_data_file:dir create_dir_perms; |
| 22 | allow statsd stats_data_file:file create_file_perms; |
| 23 | |
| 24 | # Allow statsd to make binder calls to any binder service. |
| 25 | binder_call(statsd, appdomain) |
| 26 | binder_call(statsd, incidentd) |
| 27 | binder_call(statsd, statscompanion_service) |
| 28 | |
| 29 | # Allow logd access. |
| 30 | read_logd(statsd) |
| 31 | control_logd(statsd) |
| 32 | |
| 33 | # Grant statsd with permissions to register the services. |
| 34 | allow statsd { |
| 35 | statscompanion_service |
| 36 | app_api_service |
| 37 | system_api_service |
| 38 | }:service_manager find; |
| 39 | |
| 40 | # Only statsd can publish the binder service. |
| 41 | add_service(statsd, stats_service) |
| 42 | |
| 43 | # Allow pipes from (and only from) stats. |
| 44 | allow statsd stats:fd use; |
| 45 | allow statsd stats:fifo_file write; |
| 46 | |
| 47 | # Allow statsd to call back to stats with status updates. |
| 48 | binder_call(statsd, stats) |
| 49 | |
| 50 | ### |
| 51 | ### neverallow rules |
| 52 | ### |
| 53 | |
| 54 | # Only system_server, system_app, and stats command can find the stats service. |
| 55 | neverallow { |
| 56 | domain |
| 57 | -dumpstate |
| 58 | -shell |
| 59 | -stats |
| 60 | -statsd |
| 61 | -system_app |
| 62 | -system_server |
| 63 | } stats_service:service_manager find; |
| 64 | |
| 65 | # Only statsd and the other root services in limited circumstances. |
| 66 | # can get to the files in /data/misc/stats-data, /data/misc/stats-service. |
| 67 | # Other services are prohibitted from accessing the file. |
| 68 | neverallow { domain -statsd -init -vold -vendor_init } stats_data_file:file *; |
| 69 | |
| 70 | # Limited access to the directory itself. |
| 71 | neverallow { domain -statsd -init -vold -vendor_init } stats_data_file:dir *; |
| 72 | |