blob: 2ce24594e6450d5605a9d8cd64d52a72c770773c [file] [log] [blame]
Andreas Gampe6d5baca2019-02-26 13:13:28 -08001# dex2oat
2type dex2oat, domain, coredomain;
3type dex2oat_exec, system_file_type, exec_type, file_type;
4
Lokesh Gidra06edcd82021-03-11 11:32:47 -08005userfaultfd_use(dex2oat)
6
Andreas Gampe6d5baca2019-02-26 13:13:28 -08007r_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
14allow dex2oat tmpfs:file { read getattr map };
15
16r_dir_file(dex2oat, dalvikcache_data_file)
17allow dex2oat dalvikcache_data_file:file write;
Andreas Gampe6d5baca2019-02-26 13:13:28 -080018
19# Acquire advisory lock on /system/framework/arm/*
20allow dex2oat system_file:file lock;
Jeff Vander Stoep4c0259d2021-03-05 19:54:30 +010021allow dex2oat postinstall_file:file lock;
Andreas Gampe6d5baca2019-02-26 13:13:28 -080022
23# Read already open asec_apk_file file descriptors passed by installd.
24# Also allow reading unlabeled files, to allow for upgrading forward
25# locked APKs.
26allow dex2oat asec_apk_file:file { read map };
27allow dex2oat unlabeled:file { read map };
28allow dex2oat oemfs:file { read map };
29allow dex2oat apk_tmp_file:dir search;
30allow dex2oat apk_tmp_file:file r_file_perms;
31allow dex2oat user_profile_data_file:file { getattr read lock map };
32
33# Allow dex2oat to compile app's secondary dex files which were reported back to
34# the framework.
35allow dex2oat { privapp_data_file app_data_file }:file { getattr read write lock map };
36
Orion Hodson8f75f762020-10-16 15:29:55 +010037# Allow dex2oat to find files and directories under /data/misc/apexdata/com.android.runtime.
38allow dex2oat apex_module_data_file:dir search;
39
Jiakai Zhangc871c1c2022-07-19 21:29:31 +010040# Allow dex2oat to use devpts passed from odsign.
Martijn Coenen6afdb722020-11-27 12:23:54 +010041allow dex2oat odsign_devpts:chr_file { read write };
Martijn Coenen6afdb722020-11-27 12:23:54 +010042
Orion Hodson8f75f762020-10-16 15:29:55 +010043# Allow dex2oat to write to file descriptors from odrefresh for files
44# in the staging area.
45allow dex2oat apex_art_staging_data_file:dir r_dir_perms;
46allow dex2oat apex_art_staging_data_file:file { getattr map read write unlink };
47
48# Allow dex2oat to read artifacts from odrefresh.
49allow dex2oat apex_art_data_file:dir r_dir_perms;
50allow dex2oat apex_art_data_file:file r_file_perms;
51
Roland Levillaind7227d82021-02-02 15:27:06 +000052# Allow dex2oat to read runtime native flag properties.
53get_prop(dex2oat, device_config_runtime_native_prop)
54get_prop(dex2oat, device_config_runtime_native_boot_prop)
55
Nicolas Geoffray78f02502021-04-28 13:37:27 +010056# Allow dex2oat to read /apex/apex-info-list.xml
57allow dex2oat apex_info_file:file r_file_perms;
58
Jiakai Zhangc871c1c2022-07-19 21:29:31 +010059# Allow dex2oat to use file descriptors passed from privileged programs.
60allow dex2oat { artd installd odrefresh odsign }:fd use;
61
Andreas Gampe6d5baca2019-02-26 13:13:28 -080062##################
63# A/B OTA Dexopt #
64##################
65
66# Allow dex2oat to use file descriptors from otapreopt.
67allow dex2oat postinstall_dexopt:fd use;
68
Roland Levillain66f40a82019-03-13 18:52:23 +000069# Allow dex2oat to read files under /postinstall (e.g. APKs under /system, /system/bin/linker).
70allow dex2oat postinstall_file:dir r_dir_perms;
Andreas Gampe6d5baca2019-02-26 13:13:28 -080071allow dex2oat postinstall_file:filesystem getattr;
72allow dex2oat postinstall_file:lnk_file { getattr read };
Andreas Gampe6d5baca2019-02-26 13:13:28 -080073allow dex2oat postinstall_file:file read;
74# Allow dex2oat to use libraries under /postinstall/system (e.g. /system/lib/libc.so).
75# TODO(b/120266448): Remove when Bionic libraries are part of the Runtime APEX.
76allow dex2oat postinstall_file:file { execute getattr open };
77
78# Allow dex2oat access to /postinstall/apex.
79allow dex2oat postinstall_apex_mnt_dir:dir { getattr search };
Nicolas Geoffrayf82451e2021-06-22 14:36:08 +010080allow dex2oat postinstall_apex_mnt_dir:file r_file_perms;
Andreas Gampe6d5baca2019-02-26 13:13:28 -080081
82# Allow dex2oat access to files in /data/ota.
83allow dex2oat ota_data_file:dir ra_dir_perms;
84allow dex2oat ota_data_file:file r_file_perms;
85
86# Create and read symlinks in /data/ota/dalvik-cache. This is required for PIC mode boot images,
87# where the oat file is symlinked to the original file in /system.
88allow dex2oat ota_data_file:lnk_file { create read };
89
90# It would be nice to tie this down, but currently, because of how images are written, we can't
91# pass file descriptors for the preopted boot image to dex2oat. So dex2oat needs to be able to
92# create them itself (and make them world-readable).
93allow dex2oat ota_data_file:file { create w_file_perms setattr };
94
Andreas Gampeae127d82019-02-07 16:26:00 -080095###############
96# APEX Update #
97###############
98
99# /dev/zero is inherited.
100allow dex2oat apexd:fd use;
101
102# Allow dex2oat to use file descriptors from preinstall.
Andreas Gampeae127d82019-02-07 16:26:00 -0800103
Andreas Gampe6d5baca2019-02-26 13:13:28 -0800104##############
105# Neverallow #
106##############
107
108neverallow dex2oat { privapp_data_file app_data_file }:notdevfile_class_set open;