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