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