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