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