Andreas Gampe | 6d5baca | 2019-02-26 13:13:28 -0800 | [diff] [blame^] | 1 | # Domain for the otapreopt executable, running under postinstall_dexopt |
| 2 | # |
| 3 | # Note: otapreopt is a driver for dex2oat, and reuses parts of installd. As such, |
| 4 | # this is derived and adapted from installd.te. |
| 5 | |
| 6 | type postinstall_dexopt, domain, coredomain; |
Alex Klyubin | f5446eb | 2017-03-23 14:27:32 -0700 | [diff] [blame] | 7 | |
dcashman | cc39f63 | 2016-07-22 13:13:11 -0700 | [diff] [blame] | 8 | # Run dex2oat/patchoat in its own sandbox. |
| 9 | # We have to manually transition, as we don't have an entrypoint. |
Roland Levillain | ab9c053 | 2019-01-19 12:42:11 +0000 | [diff] [blame] | 10 | domain_auto_trans(postinstall_dexopt, dex2oat_exec, dex2oat) |
Andreas Gampe | 6d5baca | 2019-02-26 13:13:28 -0800 | [diff] [blame^] | 11 | |
| 12 | allow postinstall_dexopt self:global_capability_class_set { chown dac_override dac_read_search fowner fsetid setgid setuid }; |
| 13 | |
| 14 | allow postinstall_dexopt postinstall_file:filesystem getattr; |
| 15 | allow postinstall_dexopt postinstall_file:dir { getattr read search }; |
| 16 | allow postinstall_dexopt postinstall_file:lnk_file { getattr read }; |
| 17 | allow postinstall_dexopt proc_filesystems:file { getattr open read }; |
| 18 | allow postinstall_dexopt tmpfs:file read; |
| 19 | |
| 20 | # Allow access to /postinstall/apex. |
| 21 | allow postinstall_dexopt postinstall_apex_mnt_dir:dir { getattr search }; |
| 22 | |
| 23 | # Note: /data/ota is created by init (see system/core/rootdir/init.rc) to avoid giving access |
| 24 | # here and having to relabel the directory. |
| 25 | |
| 26 | # Read app data (APKs) as input to dex2oat. |
| 27 | r_dir_file(postinstall_dexopt, apk_data_file) |
| 28 | # Read vendor app data (APKs) as input to dex2oat. |
| 29 | r_dir_file(postinstall_dexopt, vendor_app_file) |
| 30 | # Access to app oat directory. |
| 31 | r_dir_file(postinstall_dexopt, dalvikcache_data_file) |
| 32 | |
| 33 | # Read profile data. |
| 34 | allow postinstall_dexopt user_profile_data_file:dir { getattr search }; |
| 35 | allow postinstall_dexopt user_profile_data_file:file r_file_perms; |
| 36 | # Suppress deletion denial (we do not want to update the profile). |
| 37 | dontaudit postinstall_dexopt user_profile_data_file:file { write }; |
| 38 | |
| 39 | # Write to /data/ota(/*). Create symlinks in /data/ota(/*) |
| 40 | allow postinstall_dexopt ota_data_file:dir create_dir_perms; |
| 41 | allow postinstall_dexopt ota_data_file:file create_file_perms; |
| 42 | allow postinstall_dexopt ota_data_file:lnk_file create_file_perms; |
| 43 | |
| 44 | # Need to write .b files, which are dalvikcache_data_file, not ota_data_file. |
| 45 | # TODO: See whether we can apply ota_data_file? |
| 46 | allow postinstall_dexopt dalvikcache_data_file:dir rw_dir_perms; |
| 47 | allow postinstall_dexopt dalvikcache_data_file:file create_file_perms; |
| 48 | |
| 49 | # Allow labeling of files under /data/app/com.example/oat/ |
| 50 | # TODO: Restrict to .b suffix? |
| 51 | allow postinstall_dexopt dalvikcache_data_file:dir relabelto; |
| 52 | allow postinstall_dexopt dalvikcache_data_file:file { relabelto link }; |
| 53 | |
| 54 | # Check validity of SELinux context before use. |
| 55 | selinux_check_context(postinstall_dexopt) |
| 56 | selinux_check_access(postinstall_dexopt) |
| 57 | |
| 58 | |
| 59 | # Postinstall wants to know about our child. |
| 60 | allow postinstall_dexopt postinstall:process sigchld; |
| 61 | |
| 62 | # Allow otapreopt to use file descriptors from otapreopt_chroot. |
| 63 | # TODO: Probably we can actually close file descriptors... |
| 64 | allow postinstall_dexopt otapreopt_chroot:fd use; |