Sepolicy: Add otapreopt_slot
The new A/B OTA artifact naming scheme includes the target slot so that the system is robust with respect to unexpected reboots. This complicates the renaming code after reboot, so it is moved from the zygote into a simple script (otapreopt_slot) that is hooked into the startup sequence in init. Give the script the subset of the rights that the zygote had so that it can move the artifacts from /data/ota into /data/dalvik-cache. Relabeling will be done in the init rc component, so relabeling rights can be completely removed. Bug: 25612095 Bug: 28069686 Change-Id: Iad56dc3d78ac759f4f2cce65633cdaf1cab7631b
This commit is contained in:
parent
d47c1e93ae
commit
eb717421b1
4 changed files with 30 additions and 25 deletions
|
@ -378,6 +378,7 @@ neverallow {
|
|||
-postinstall_dexopt
|
||||
-cppreopts
|
||||
-dex2oat
|
||||
-otapreopt_slot
|
||||
} dalvikcache_data_file:file no_w_file_perms;
|
||||
|
||||
neverallow {
|
||||
|
@ -388,6 +389,7 @@ neverallow {
|
|||
-cppreopts
|
||||
-dex2oat
|
||||
-zygote
|
||||
-otapreopt_slot
|
||||
} dalvikcache_data_file:dir no_w_dir_perms;
|
||||
|
||||
# Only system_server should be able to send commands via the zygote socket
|
||||
|
|
|
@ -175,6 +175,7 @@
|
|||
/system/bin/mdnsd u:object_r:mdnsd_exec:s0
|
||||
/system/bin/installd u:object_r:installd_exec:s0
|
||||
/system/bin/otapreopt_chroot u:object_r:otapreopt_chroot_exec:s0
|
||||
/system/bin/otapreopt_slot u:object_r:otapreopt_slot_exec:s0
|
||||
/system/bin/keystore u:object_r:keystore_exec:s0
|
||||
/system/bin/fingerprintd u:object_r:fingerprintd_exec:s0
|
||||
/system/bin/gatekeeperd u:object_r:gatekeeperd_exec:s0
|
||||
|
|
27
otapreopt_slot.te
Normal file
27
otapreopt_slot.te
Normal file
|
@ -0,0 +1,27 @@
|
|||
# otapreopt_slot
|
||||
#
|
||||
# This command set moves the artifact corresponding to the current slot
|
||||
# from /data/ota to /data/dalvik-cache.
|
||||
|
||||
type otapreopt_slot, domain, mlstrustedsubject;
|
||||
type otapreopt_slot_exec, exec_type, file_type;
|
||||
|
||||
# Technically not a daemon but we do want the transition from init domain to
|
||||
# cppreopts to occur.
|
||||
init_daemon_domain(otapreopt_slot)
|
||||
|
||||
# The otapreopt_slot renames the OTA dalvik-cache to the regular dalvik-cache, and cleans up
|
||||
# the directory afterwards.
|
||||
allow otapreopt_slot ota_data_file:dir { rw_dir_perms rename reparent rmdir };
|
||||
|
||||
# Delete old content of the dalvik-cache.
|
||||
allow otapreopt_slot dalvikcache_data_file:dir { add_name getattr open read remove_name rmdir search write };
|
||||
allow otapreopt_slot dalvikcache_data_file:file { getattr unlink };
|
||||
allow otapreopt_slot dalvikcache_data_file:lnk_file { getattr read unlink };
|
||||
|
||||
# Allow cppreopts to execute itself using #!/system/bin/sh
|
||||
allow otapreopt_slot shell_exec:file rx_file_perms;
|
||||
|
||||
# Allow running the mv and rm/rmdir commands using otapreopt_slot permissions.
|
||||
# Needed so we can move artifacts into /data/dalvik-cache/dalvik-cache.
|
||||
allow otapreopt_slot toolbox_exec:file rx_file_perms;
|
25
zygote.te
25
zygote.te
|
@ -81,31 +81,6 @@ userdebug_or_eng(`
|
|||
allow zygote method_trace_data_file:file { create w_file_perms };
|
||||
')
|
||||
|
||||
###
|
||||
### A/B OTA
|
||||
###
|
||||
|
||||
# The zygote is responsible for detecting A/B OTA artifacts and moving them into
|
||||
# the actual dalvik-cache.
|
||||
|
||||
# Allow zygote access to files in /data/ota.
|
||||
# This includes reading symlinks in /data/ota/dalvik-cache. This is required for PIC mode boot
|
||||
# images, where the oat file is symlinked to the original file in /system.
|
||||
r_dir_file(zygote, ota_data_file)
|
||||
|
||||
# The zygote renames the OTA dalvik-cache to the regular dalvik-cache.
|
||||
allow zygote ota_data_file:dir { rw_dir_perms rename reparent };
|
||||
|
||||
# And needs to relabel the entries, so as to have the dalvikcache_data_file label.
|
||||
allow zygote ota_data_file:{ dir file lnk_file } relabelfrom;
|
||||
allow zygote dalvikcache_data_file:{ dir file lnk_file } relabelto;
|
||||
|
||||
# The zygote also cleans up the now-empty dalvik-cache directory after an OTA.
|
||||
# In case something goes wrong in relabelling, we also need to be able to delete the files that
|
||||
# have already been moved.
|
||||
allow zygote ota_data_file:dir rmdir;
|
||||
allow zygote ota_data_file:{ file lnk_file } unlink;
|
||||
|
||||
###
|
||||
### neverallow rules
|
||||
###
|
||||
|
|
Loading…
Reference in a new issue