1typeattribute bootstat coredomain; 2 3init_daemon_domain(bootstat) 4 5# Collect metrics on boot time created by init 6get_prop(bootstat, boottime_prop) 7 8# Read/Write [persist.]sys.boot.reason and ro.boot.bootreason (write if empty) 9set_prop(bootstat, bootloader_boot_reason_prop) 10set_prop(bootstat, system_boot_reason_prop) 11set_prop(bootstat, last_boot_reason_prop) 12 13read_runtime_log_tags(bootstat) 14 15# Allow persistent storage in /data/misc/bootstat. 16allow bootstat bootstat_data_file:dir rw_dir_perms; 17allow bootstat bootstat_data_file:file create_file_perms; 18 19allow bootstat metadata_file:dir search; 20allow bootstat metadata_bootstat_file:dir rw_dir_perms; 21allow bootstat metadata_bootstat_file:file create_file_perms; 22 23# ToDo: TBI move access for the following to a system health HAL 24 25# Allow access to /sys/fs/pstore/ and syslog 26allow bootstat pstorefs:dir search; 27allow bootstat pstorefs:file r_file_perms; 28allow bootstat kernel:system syslog_read; 29 30# Allow access to reading the logs to read aspects of system health 31read_logd(bootstat) 32 33# Allow bootstat write to statsd. 34unix_socket_send(bootstat, statsdw, statsd) 35 36### 37### Neverallow rules 38### 39 40neverallow { 41 domain 42 -bootstat 43 -init 44} system_boot_reason_prop:property_service set; 45 46neverallow { 47 domain 48 -bootanim 49 -bootstat 50 -dumpstate 51 userdebug_or_eng(`-incidentd') 52 -init 53 -platform_app 54 -recovery 55 -shell 56 -system_server 57} { bootloader_boot_reason_prop last_boot_reason_prop }:file r_file_perms; 58# ... and refine, as these components should not set the last boot reason 59neverallow { bootanim recovery } last_boot_reason_prop:file r_file_perms; 60 61neverallow { 62 domain 63 -bootstat 64 -init 65 -system_server 66} { bootloader_boot_reason_prop last_boot_reason_prop }:property_service set; 67# ... and refine ... for a ro propertly no less ... keep this _tight_ 68neverallow system_server bootloader_boot_reason_prop:property_service set; 69