Remove access to ro.runtime.firstboot from apps

ro.runtime.firstboot system property is only used internally by
system_server to distinguish between first start after boot from
consecutive starts (for example, this happens when full-disk
encryption is enabled). The value of the property is a
millisecond-precise timestamp which can help track individual
device. Thus apps should not have access to this property.

Test: Device boots fine, reading ro.runtime.firstboot from an app results in an error and SELinux denial.
Bug: 33700679
Change-Id: I4c3c26a35c5dd840bced3a3e53d071f45317f63c
diff --git a/private/property_contexts b/private/property_contexts
index a27b756..39e8a8d 100644
--- a/private/property_contexts
+++ b/private/property_contexts
@@ -18,6 +18,7 @@
 net.                    u:object_r:system_prop:s0
 dev.                    u:object_r:system_prop:s0
 ro.runtime.             u:object_r:system_prop:s0
+ro.runtime.firstboot    u:object_r:firstboot_prop:s0
 hw.                     u:object_r:system_prop:s0
 ro.hw.                  u:object_r:system_prop:s0
 sys.                    u:object_r:system_prop:s0
diff --git a/public/domain.te b/public/domain.te
index 47b3e5a..2bf0be3 100644
--- a/public/domain.te
+++ b/public/domain.te
@@ -386,6 +386,9 @@
   -system_server
 } serialno_prop:file r_file_perms;
 
+# Do not allow reading the last boot timestamp from system properties
+neverallow { domain -init -system_server } firstboot_prop:file r_file_perms;
+
 neverallow {
   domain
   -init
diff --git a/public/property.te b/public/property.te
index 0bba50d..ce5ce2f 100644
--- a/public/property.te
+++ b/public/property.te
@@ -21,6 +21,7 @@
 type dumpstate_prop, property_type, core_property_type;
 type ffs_prop, property_type, core_property_type;
 type fingerprint_prop, property_type, core_property_type;
+type firstboot_prop, property_type;
 type hwservicemanager_prop, property_type;
 type logd_prop, property_type, core_property_type;
 type logpersistd_logging_prop, property_type;
diff --git a/public/system_server.te b/public/system_server.te
index bc1dd9f..99ff1d8 100644
--- a/public/system_server.te
+++ b/public/system_server.te
@@ -391,6 +391,9 @@
 # Read device's serial number from system properties
 get_prop(system_server, serialno_prop)
 
+# Read/write the property which keeps track of whether this is the first start of system_server
+set_prop(system_server, firstboot_prop)
+
 # Create a socket for receiving info from wpa.
 allow system_server wpa_socket:dir rw_dir_perms;
 allow system_server system_wpa_socket:sock_file create_file_perms;