xref: /aosp_15_r20/system/sepolicy/prebuilts/api/30.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 Workerr_dir_file(dex2oat, apk_data_file)
6*e4a36f41SAndroid Build Coastguard Worker# Access to /vendor/app
7*e4a36f41SAndroid Build Coastguard Workerr_dir_file(dex2oat, vendor_app_file)
8*e4a36f41SAndroid Build Coastguard Worker# Access /vendor/framework
9*e4a36f41SAndroid Build Coastguard Workerallow dex2oat vendor_framework_file:dir { getattr search };
10*e4a36f41SAndroid Build Coastguard Workerallow dex2oat vendor_framework_file:file { getattr open read map };
11*e4a36f41SAndroid Build Coastguard Worker
12*e4a36f41SAndroid Build Coastguard Workerallow dex2oat tmpfs:file { read getattr map };
13*e4a36f41SAndroid Build Coastguard Worker
14*e4a36f41SAndroid Build Coastguard Workerr_dir_file(dex2oat, dalvikcache_data_file)
15*e4a36f41SAndroid Build Coastguard Workerallow dex2oat dalvikcache_data_file:file write;
16*e4a36f41SAndroid Build Coastguard Worker# Read symlinks in /data/dalvik-cache. This is required for PIC mode boot images, where
17*e4a36f41SAndroid Build Coastguard Worker# the oat file is symlinked to the original file in /system.
18*e4a36f41SAndroid Build Coastguard Workerallow dex2oat dalvikcache_data_file:lnk_file read;
19*e4a36f41SAndroid Build Coastguard Workerallow dex2oat installd:fd use;
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 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##################
39*e4a36f41SAndroid Build Coastguard Worker# A/B OTA Dexopt #
40*e4a36f41SAndroid Build Coastguard Worker##################
41*e4a36f41SAndroid Build Coastguard Worker
42*e4a36f41SAndroid Build Coastguard Worker# Allow dex2oat to use file descriptors from otapreopt.
43*e4a36f41SAndroid Build Coastguard Workerallow dex2oat postinstall_dexopt:fd use;
44*e4a36f41SAndroid Build Coastguard Worker
45*e4a36f41SAndroid Build Coastguard Worker# Allow dex2oat to read files under /postinstall (e.g. APKs under /system, /system/bin/linker).
46*e4a36f41SAndroid Build Coastguard Workerallow dex2oat postinstall_file:dir r_dir_perms;
47*e4a36f41SAndroid Build Coastguard Workerallow dex2oat postinstall_file:filesystem getattr;
48*e4a36f41SAndroid Build Coastguard Workerallow dex2oat postinstall_file:lnk_file { getattr read };
49*e4a36f41SAndroid Build Coastguard Workerallow dex2oat postinstall_file:file read;
50*e4a36f41SAndroid Build Coastguard Worker# Allow dex2oat to use libraries under /postinstall/system (e.g. /system/lib/libc.so).
51*e4a36f41SAndroid Build Coastguard Worker# TODO(b/120266448): Remove when Bionic libraries are part of the Runtime APEX.
52*e4a36f41SAndroid Build Coastguard Workerallow dex2oat postinstall_file:file { execute getattr open };
53*e4a36f41SAndroid Build Coastguard Worker
54*e4a36f41SAndroid Build Coastguard Worker# Allow dex2oat access to /postinstall/apex.
55*e4a36f41SAndroid Build Coastguard Workerallow dex2oat postinstall_apex_mnt_dir:dir { getattr search };
56*e4a36f41SAndroid Build Coastguard Worker
57*e4a36f41SAndroid Build Coastguard Worker# Allow dex2oat access to files in /data/ota.
58*e4a36f41SAndroid Build Coastguard Workerallow dex2oat ota_data_file:dir ra_dir_perms;
59*e4a36f41SAndroid Build Coastguard Workerallow dex2oat ota_data_file:file r_file_perms;
60*e4a36f41SAndroid Build Coastguard Worker
61*e4a36f41SAndroid Build Coastguard Worker# Create and read symlinks in /data/ota/dalvik-cache. This is required for PIC mode boot images,
62*e4a36f41SAndroid Build Coastguard Worker# where the oat file is symlinked to the original file in /system.
63*e4a36f41SAndroid Build Coastguard Workerallow dex2oat ota_data_file:lnk_file { create read };
64*e4a36f41SAndroid Build Coastguard Worker
65*e4a36f41SAndroid Build Coastguard Worker# It would be nice to tie this down, but currently, because of how images are written, we can't
66*e4a36f41SAndroid Build Coastguard Worker# pass file descriptors for the preopted boot image to dex2oat. So dex2oat needs to be able to
67*e4a36f41SAndroid Build Coastguard Worker# create them itself (and make them world-readable).
68*e4a36f41SAndroid Build Coastguard Workerallow dex2oat ota_data_file:file { create w_file_perms setattr };
69*e4a36f41SAndroid Build Coastguard Worker
70*e4a36f41SAndroid Build Coastguard Worker###############
71*e4a36f41SAndroid Build Coastguard Worker# APEX Update #
72*e4a36f41SAndroid Build Coastguard Worker###############
73*e4a36f41SAndroid Build Coastguard Worker
74*e4a36f41SAndroid Build Coastguard Worker# /dev/zero is inherited.
75*e4a36f41SAndroid Build Coastguard Workerallow dex2oat apexd:fd use;
76*e4a36f41SAndroid Build Coastguard Worker
77*e4a36f41SAndroid Build Coastguard Worker# Allow dex2oat to use file descriptors from preinstall.
78*e4a36f41SAndroid Build Coastguard Workerallow dex2oat art_apex_preinstall:fd use;
79*e4a36f41SAndroid Build Coastguard Worker
80*e4a36f41SAndroid Build Coastguard Worker##############
81*e4a36f41SAndroid Build Coastguard Worker# Neverallow #
82*e4a36f41SAndroid Build Coastguard Worker##############
83*e4a36f41SAndroid Build Coastguard Worker
84*e4a36f41SAndroid Build Coastguard Workerneverallow dex2oat { privapp_data_file app_data_file }:notdevfile_class_set open;
85