2018-04-20 20:07:22 +02:00
|
|
|
type statsd, domain, mlstrustedsubject;
|
2017-12-19 00:14:33 +01:00
|
|
|
typeattribute statsd coredomain;
|
|
|
|
|
|
|
|
init_daemon_domain(statsd)
|
|
|
|
|
|
|
|
type statsd_exec, exec_type, file_type;
|
|
|
|
binder_use(statsd)
|
|
|
|
|
|
|
|
# Allow statsd to scan through /proc/pid for all processes.
|
|
|
|
r_dir_file(statsd, domain)
|
|
|
|
|
|
|
|
# Allow executing files on system, such as running a shell or running:
|
|
|
|
# /system/bin/toolbox
|
|
|
|
# /system/bin/logcat
|
|
|
|
# /system/bin/dumpsys
|
2017-12-21 01:00:54 +01:00
|
|
|
allow statsd devpts:chr_file { getattr ioctl read write };
|
2017-12-19 00:14:33 +01:00
|
|
|
allow statsd shell_exec:file rx_file_perms;
|
|
|
|
allow statsd system_file:file execute_no_trans;
|
|
|
|
allow statsd toolbox_exec:file rx_file_perms;
|
|
|
|
|
2017-12-21 01:00:54 +01:00
|
|
|
userdebug_or_eng(`
|
|
|
|
allow statsd su:fifo_file read;
|
|
|
|
')
|
|
|
|
|
2017-12-19 00:14:33 +01:00
|
|
|
# Create, read, and write into /data/misc/stats-data, /data/misc/stats-system.
|
|
|
|
allow statsd stats_data_file:dir create_dir_perms;
|
|
|
|
allow statsd stats_data_file:file create_file_perms;
|
|
|
|
|
|
|
|
# Allow statsd to make binder calls to any binder service.
|
|
|
|
binder_call(statsd, appdomain)
|
2018-01-24 20:26:14 +01:00
|
|
|
binder_call(statsd, healthd)
|
2017-12-19 00:14:33 +01:00
|
|
|
binder_call(statsd, incidentd)
|
2018-01-30 18:48:35 +01:00
|
|
|
userdebug_or_eng(`
|
|
|
|
binder_call(statsd, perfprofd)
|
|
|
|
')
|
2017-12-19 00:14:33 +01:00
|
|
|
binder_call(statsd, statscompanion_service)
|
2017-12-21 01:00:54 +01:00
|
|
|
binder_call(statsd, system_server)
|
2017-12-19 00:14:33 +01:00
|
|
|
|
|
|
|
# Allow logd access.
|
|
|
|
read_logd(statsd)
|
|
|
|
control_logd(statsd)
|
|
|
|
|
2018-01-24 17:07:09 +01:00
|
|
|
# Allow to exec the perfetto cmdline client and pass it the trace config on
|
|
|
|
# stdint through a pipe. It allows statsd to capture traces and hand them
|
|
|
|
# to Android dropbox.
|
|
|
|
allow statsd perfetto_exec:file rx_file_perms;
|
|
|
|
domain_auto_trans(statsd, perfetto_exec, perfetto)
|
2017-12-21 03:51:15 +01:00
|
|
|
|
2017-12-19 00:14:33 +01:00
|
|
|
# Grant statsd with permissions to register the services.
|
|
|
|
allow statsd {
|
|
|
|
app_api_service
|
2018-01-22 22:56:41 +01:00
|
|
|
incident_service
|
|
|
|
statscompanion_service
|
2017-12-19 00:14:33 +01:00
|
|
|
system_api_service
|
|
|
|
}:service_manager find;
|
|
|
|
|
2018-01-24 20:26:14 +01:00
|
|
|
# Grant statsd to access health hal to access battery metrics.
|
|
|
|
allow statsd hal_health_hwservice:hwservice_manager find;
|
|
|
|
|
2017-12-19 00:14:33 +01:00
|
|
|
# Only statsd can publish the binder service.
|
|
|
|
add_service(statsd, stats_service)
|
|
|
|
|
|
|
|
# Allow pipes from (and only from) stats.
|
|
|
|
allow statsd stats:fd use;
|
|
|
|
allow statsd stats:fifo_file write;
|
|
|
|
|
2018-01-18 01:17:28 +01:00
|
|
|
# Allow statsd to send dump info to dumpstate
|
|
|
|
allow statsd dumpstate:fd use;
|
|
|
|
allow statsd dumpstate:fifo_file { getattr write };
|
|
|
|
|
2017-12-19 00:14:33 +01:00
|
|
|
# Allow statsd to call back to stats with status updates.
|
|
|
|
binder_call(statsd, stats)
|
|
|
|
|
2017-12-21 01:00:54 +01:00
|
|
|
# Allow access to with hardware layer and process stats.
|
|
|
|
allow statsd proc_uid_cputime_showstat:file { getattr open read };
|
2018-04-12 18:14:27 +02:00
|
|
|
hal_client_domain(statsd, hal_health)
|
2017-12-21 01:00:54 +01:00
|
|
|
hal_client_domain(statsd, hal_power)
|
2018-02-24 01:01:27 +01:00
|
|
|
hal_client_domain(statsd, hal_thermal)
|
2017-12-21 01:00:54 +01:00
|
|
|
|
2018-02-13 18:33:36 +01:00
|
|
|
# Allow 'adb shell cmd' to upload configs and download output.
|
|
|
|
allow statsd adbd:fd use;
|
2018-02-23 21:54:13 +01:00
|
|
|
allow statsd adbd:unix_stream_socket { getattr read write };
|
|
|
|
allow statsd shell:fifo_file { getattr read };
|
2018-02-13 18:33:36 +01:00
|
|
|
|
2018-04-20 20:07:22 +02:00
|
|
|
unix_socket_send(bluetooth, statsdw, statsd)
|
|
|
|
unix_socket_send(bootstat, statsdw, statsd)
|
2018-05-04 01:43:03 +02:00
|
|
|
unix_socket_send(lmkd, statsdw, statsd)
|
2018-04-20 20:07:22 +02:00
|
|
|
unix_socket_send(platform_app, statsdw, statsd)
|
|
|
|
unix_socket_send(radio, statsdw, statsd)
|
|
|
|
unix_socket_send(statsd, statsdw, statsd)
|
|
|
|
unix_socket_send(system_server, statsdw, statsd)
|
|
|
|
|
2017-12-19 00:14:33 +01:00
|
|
|
###
|
|
|
|
### neverallow rules
|
|
|
|
###
|
|
|
|
|
2017-12-12 01:19:23 +01:00
|
|
|
# Only system_server, system_app, traceur_app, and stats command can find the stats service.
|
2017-12-19 00:14:33 +01:00
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-dumpstate
|
2018-01-09 20:27:36 +01:00
|
|
|
-priv_app
|
2017-12-19 00:14:33 +01:00
|
|
|
-shell
|
|
|
|
-stats
|
|
|
|
-statsd
|
|
|
|
-system_app
|
|
|
|
-system_server
|
2018-01-09 21:24:47 +01:00
|
|
|
-traceur_app
|
2017-12-19 00:14:33 +01:00
|
|
|
} stats_service:service_manager find;
|
|
|
|
|
|
|
|
# Only statsd and the other root services in limited circumstances.
|
|
|
|
# can get to the files in /data/misc/stats-data, /data/misc/stats-service.
|
|
|
|
# Other services are prohibitted from accessing the file.
|
2018-03-29 20:07:13 +02:00
|
|
|
neverallow { domain -statsd -system_server -init -vold } stats_data_file:file *;
|
2017-12-19 00:14:33 +01:00
|
|
|
|
|
|
|
# Limited access to the directory itself.
|
2018-03-29 20:07:13 +02:00
|
|
|
neverallow { domain -statsd -system_server -init -vold } stats_data_file:dir *;
|