Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame] | 1 | # dex2oat |
| 2 | type dex2oat, domain, coredomain; |
| 3 | type dex2oat_exec, system_file_type, exec_type, file_type; |
| 4 | |
| 5 | userfaultfd_use(dex2oat) |
| 6 | |
| 7 | r_dir_file(dex2oat, apk_data_file) |
| 8 | # Access to /vendor/app |
| 9 | r_dir_file(dex2oat, vendor_app_file) |
| 10 | # Access /vendor/framework |
| 11 | allow dex2oat vendor_framework_file:dir { getattr search }; |
| 12 | allow dex2oat vendor_framework_file:file { getattr open read map }; |
| 13 | |
| 14 | allow dex2oat tmpfs:file { read getattr map }; |
| 15 | |
| 16 | r_dir_file(dex2oat, dalvikcache_data_file) |
| 17 | allow dex2oat dalvikcache_data_file:file write; |
| 18 | allow dex2oat installd:fd use; |
| 19 | |
| 20 | # Acquire advisory lock on /system/framework/arm/* |
| 21 | allow dex2oat system_file:file lock; |
| 22 | allow dex2oat postinstall_file:file lock; |
| 23 | |
| 24 | # Read already open asec_apk_file file descriptors passed by installd. |
| 25 | # Also allow reading unlabeled files, to allow for upgrading forward |
| 26 | # locked APKs. |
| 27 | allow dex2oat asec_apk_file:file { read map }; |
| 28 | allow dex2oat unlabeled:file { read map }; |
| 29 | allow dex2oat oemfs:file { read map }; |
| 30 | allow dex2oat apk_tmp_file:dir search; |
| 31 | allow dex2oat apk_tmp_file:file r_file_perms; |
| 32 | allow dex2oat user_profile_data_file:file { getattr read lock map }; |
| 33 | |
| 34 | # Allow dex2oat to compile app's secondary dex files which were reported back to |
| 35 | # the framework. |
| 36 | allow dex2oat { privapp_data_file app_data_file }:file { getattr read write lock map }; |
| 37 | |
| 38 | # Allow dex2oat to find files and directories under /data/misc/apexdata/com.android.runtime. |
| 39 | allow dex2oat apex_module_data_file:dir search; |
| 40 | |
| 41 | # Allow dex2oat to use file descriptors passed from odrefresh. |
| 42 | allow dex2oat odrefresh:fd use; |
| 43 | |
| 44 | # Allow dex2oat to use devpts and file descriptors passed from odsign |
| 45 | allow dex2oat odsign_devpts:chr_file { read write }; |
| 46 | allow dex2oat odsign:fd use; |
| 47 | |
| 48 | # Allow dex2oat to write to file descriptors from odrefresh for files |
| 49 | # in the staging area. |
| 50 | allow dex2oat apex_art_staging_data_file:dir r_dir_perms; |
| 51 | allow dex2oat apex_art_staging_data_file:file { getattr map read write unlink }; |
| 52 | |
| 53 | # Allow dex2oat to read artifacts from odrefresh. |
| 54 | allow dex2oat apex_art_data_file:dir r_dir_perms; |
| 55 | allow dex2oat apex_art_data_file:file r_file_perms; |
| 56 | |
| 57 | # Allow dex2oat to read runtime native flag properties. |
| 58 | get_prop(dex2oat, device_config_runtime_native_prop) |
| 59 | get_prop(dex2oat, device_config_runtime_native_boot_prop) |
| 60 | |
| 61 | # Allow dex2oat to read /apex/apex-info-list.xml |
| 62 | allow dex2oat apex_info_file:file r_file_perms; |
| 63 | |
| 64 | ################## |
| 65 | # A/B OTA Dexopt # |
| 66 | ################## |
| 67 | |
| 68 | # Allow dex2oat to use file descriptors from otapreopt. |
| 69 | allow dex2oat postinstall_dexopt:fd use; |
| 70 | |
| 71 | # Allow dex2oat to read files under /postinstall (e.g. APKs under /system, /system/bin/linker). |
| 72 | allow dex2oat postinstall_file:dir r_dir_perms; |
| 73 | allow dex2oat postinstall_file:filesystem getattr; |
| 74 | allow dex2oat postinstall_file:lnk_file { getattr read }; |
| 75 | allow dex2oat postinstall_file:file read; |
| 76 | # Allow dex2oat to use libraries under /postinstall/system (e.g. /system/lib/libc.so). |
| 77 | # TODO(b/120266448): Remove when Bionic libraries are part of the Runtime APEX. |
| 78 | allow dex2oat postinstall_file:file { execute getattr open }; |
| 79 | |
| 80 | # Allow dex2oat access to /postinstall/apex. |
| 81 | allow dex2oat postinstall_apex_mnt_dir:dir { getattr search }; |
| 82 | |
| 83 | # Allow dex2oat access to files in /data/ota. |
| 84 | allow dex2oat ota_data_file:dir ra_dir_perms; |
| 85 | allow dex2oat ota_data_file:file r_file_perms; |
| 86 | |
| 87 | # Create and read symlinks in /data/ota/dalvik-cache. This is required for PIC mode boot images, |
| 88 | # where the oat file is symlinked to the original file in /system. |
| 89 | allow dex2oat ota_data_file:lnk_file { create read }; |
| 90 | |
| 91 | # It would be nice to tie this down, but currently, because of how images are written, we can't |
| 92 | # pass file descriptors for the preopted boot image to dex2oat. So dex2oat needs to be able to |
| 93 | # create them itself (and make them world-readable). |
| 94 | allow dex2oat ota_data_file:file { create w_file_perms setattr }; |
| 95 | |
| 96 | ############### |
| 97 | # APEX Update # |
| 98 | ############### |
| 99 | |
| 100 | # /dev/zero is inherited. |
| 101 | allow dex2oat apexd:fd use; |
| 102 | |
| 103 | # Allow dex2oat to use file descriptors from preinstall. |
| 104 | |
| 105 | ############## |
| 106 | # Neverallow # |
| 107 | ############## |
| 108 | |
| 109 | neverallow dex2oat { privapp_data_file app_data_file }:notdevfile_class_set open; |