blob: 94af0436b9175ec3c2a5486add1a6b000895c29a [file] [log] [blame]
Andreas Gampe6d5baca2019-02-26 13:13:28 -08001# Domain for the otapreopt executable, running under postinstall_dexopt
2#
3# Note: otapreopt is a driver for dex2oat, and reuses parts of installd. As such,
4# this is derived and adapted from installd.te.
5
Alan Stokes7aa40412020-12-04 14:07:52 +00006type postinstall_dexopt, domain, coredomain, mlstrustedsubject;
Alex Light16dfb432021-03-11 11:26:08 -08007type postinstall_dexopt_exec, system_file_type, exec_type, file_type;
Alex Light8393a052021-04-26 16:46:57 -07008type postinstall_dexopt_tmpfs, file_type;
Alex Klyubinf5446eb2017-03-23 14:27:32 -07009
dcashmancc39f632016-07-22 13:13:11 -070010# Run dex2oat/patchoat in its own sandbox.
11# We have to manually transition, as we don't have an entrypoint.
Roland Levillain66f40a82019-03-13 18:52:23 +000012# - Case where dex2oat is in a non-flattened APEX, which has retained
13# the correct type (`dex2oat_exec`).
Roland Levillainab9c0532019-01-19 12:42:11 +000014domain_auto_trans(postinstall_dexopt, dex2oat_exec, dex2oat)
Roland Levillain66f40a82019-03-13 18:52:23 +000015# - Case where dex2oat is in a flattened APEX, which has been tagged
16# with the `postinstall_file` type by update_engine.
17domain_auto_trans(postinstall_dexopt, postinstall_file, dex2oat)
Andreas Gampe6d5baca2019-02-26 13:13:28 -080018
Alex Light8393a052021-04-26 16:46:57 -070019# Run derive_classpath to get the current BCP.
20domain_auto_trans(postinstall_dexopt, derive_classpath_exec, derive_classpath)
21# Allow postinstall_dexopt to make a tempfile for derive_classpath to write into
22tmpfs_domain(postinstall_dexopt);
23allow postinstall_dexopt postinstall_dexopt_tmpfs:file open;
24
Andreas Gampe6d5baca2019-02-26 13:13:28 -080025allow postinstall_dexopt self:global_capability_class_set { chown dac_override dac_read_search fowner fsetid setgid setuid };
26
27allow postinstall_dexopt postinstall_file:filesystem getattr;
28allow postinstall_dexopt postinstall_file:dir { getattr read search };
29allow postinstall_dexopt postinstall_file:lnk_file { getattr read };
30allow postinstall_dexopt proc_filesystems:file { getattr open read };
Alex Light16dfb432021-03-11 11:26:08 -080031allow postinstall_dexopt rootfs:file r_file_perms;
32
Andreas Gampe6d5baca2019-02-26 13:13:28 -080033allow postinstall_dexopt tmpfs:file read;
34
35# Allow access to /postinstall/apex.
36allow postinstall_dexopt postinstall_apex_mnt_dir:dir { getattr search };
37
38# Note: /data/ota is created by init (see system/core/rootdir/init.rc) to avoid giving access
39# here and having to relabel the directory.
40
41# Read app data (APKs) as input to dex2oat.
42r_dir_file(postinstall_dexopt, apk_data_file)
43# Read vendor app data (APKs) as input to dex2oat.
44r_dir_file(postinstall_dexopt, vendor_app_file)
Andreas Gampe30186cf2019-03-22 12:13:53 -070045# Read vendor overlay files (APKs) as input to dex2oat.
46r_dir_file(postinstall_dexopt, vendor_overlay_file)
Andreas Gampe6d5baca2019-02-26 13:13:28 -080047# Access to app oat directory.
48r_dir_file(postinstall_dexopt, dalvikcache_data_file)
49
50# Read profile data.
Alan Stokes7aa40412020-12-04 14:07:52 +000051allow postinstall_dexopt { user_profile_root_file user_profile_data_file }:dir { getattr search };
Andreas Gampe6d5baca2019-02-26 13:13:28 -080052allow postinstall_dexopt user_profile_data_file:file r_file_perms;
53# Suppress deletion denial (we do not want to update the profile).
54dontaudit postinstall_dexopt user_profile_data_file:file { write };
55
56# Write to /data/ota(/*). Create symlinks in /data/ota(/*)
57allow postinstall_dexopt ota_data_file:dir create_dir_perms;
58allow postinstall_dexopt ota_data_file:file create_file_perms;
59allow postinstall_dexopt ota_data_file:lnk_file create_file_perms;
60
61# Need to write .b files, which are dalvikcache_data_file, not ota_data_file.
62# TODO: See whether we can apply ota_data_file?
63allow postinstall_dexopt dalvikcache_data_file:dir rw_dir_perms;
64allow postinstall_dexopt dalvikcache_data_file:file create_file_perms;
65
66# Allow labeling of files under /data/app/com.example/oat/
67# TODO: Restrict to .b suffix?
68allow postinstall_dexopt dalvikcache_data_file:dir relabelto;
69allow postinstall_dexopt dalvikcache_data_file:file { relabelto link };
70
71# Check validity of SELinux context before use.
72selinux_check_context(postinstall_dexopt)
73selinux_check_access(postinstall_dexopt)
74
75
76# Postinstall wants to know about our child.
77allow postinstall_dexopt postinstall:process sigchld;
78
79# Allow otapreopt to use file descriptors from otapreopt_chroot.
80# TODO: Probably we can actually close file descriptors...
81allow postinstall_dexopt otapreopt_chroot:fd use;
Nicolas Geoffray40014752019-03-01 10:05:35 +000082
83# Allow postinstall_dexopt to access the runtime feature flag properties.
84get_prop(postinstall_dexopt, device_config_runtime_native_prop)
85get_prop(postinstall_dexopt, device_config_runtime_native_boot_prop)