xref: /aosp_15_r20/system/sepolicy/prebuilts/api/202404/private/artd.te (revision e4a36f4174b17bbab9dc043f4a65dc8d87377290)
1*e4a36f41SAndroid Build Coastguard Worker# ART service daemon.
2*e4a36f41SAndroid Build Coastguard Workertypeattribute artd coredomain;
3*e4a36f41SAndroid Build Coastguard Workertypeattribute artd mlstrustedsubject;
4*e4a36f41SAndroid Build Coastguard Workertype artd_exec, system_file_type, exec_type, file_type;
5*e4a36f41SAndroid Build Coastguard Workertype artd_tmpfs, file_type;
6*e4a36f41SAndroid Build Coastguard Worker
7*e4a36f41SAndroid Build Coastguard Worker# Allow artd to publish a binder service and make binder calls.
8*e4a36f41SAndroid Build Coastguard Workerbinder_use(artd)
9*e4a36f41SAndroid Build Coastguard Workeradd_service(artd, artd_service)
10*e4a36f41SAndroid Build Coastguard Workeradd_service(artd, artd_pre_reboot_service)
11*e4a36f41SAndroid Build Coastguard Workerallow artd dumpstate:fifo_file { getattr write };
12*e4a36f41SAndroid Build Coastguard Workerallow artd dumpstate:fd use;
13*e4a36f41SAndroid Build Coastguard Worker
14*e4a36f41SAndroid Build Coastguard Workerinit_daemon_domain(artd)
15*e4a36f41SAndroid Build Coastguard Worker
16*e4a36f41SAndroid Build Coastguard Worker# Allow query ART device config properties
17*e4a36f41SAndroid Build Coastguard Workerget_prop(artd, device_config_runtime_native_prop)
18*e4a36f41SAndroid Build Coastguard Workerget_prop(artd, device_config_runtime_native_boot_prop)
19*e4a36f41SAndroid Build Coastguard Worker
20*e4a36f41SAndroid Build Coastguard Worker# Access to "odsign.verification.success" for deciding whether to deny files in
21*e4a36f41SAndroid Build Coastguard Worker# the ART APEX data directory.
22*e4a36f41SAndroid Build Coastguard Workerget_prop(artd, odsign_prop)
23*e4a36f41SAndroid Build Coastguard Worker
24*e4a36f41SAndroid Build Coastguard Worker# Reading an APK opens a ZipArchive, which unpack to tmpfs.
25*e4a36f41SAndroid Build Coastguard Worker# Use tmpfs_domain() which will give tmpfs files created by artd their
26*e4a36f41SAndroid Build Coastguard Worker# own label, which differs from other labels created by other processes.
27*e4a36f41SAndroid Build Coastguard Worker# This allows to distinguish in policy files created by artd vs other
28*e4a36f41SAndroid Build Coastguard Worker# processes.
29*e4a36f41SAndroid Build Coastguard Workertmpfs_domain(artd)
30*e4a36f41SAndroid Build Coastguard Worker
31*e4a36f41SAndroid Build Coastguard Worker# Allow testing userfaultfd support.
32*e4a36f41SAndroid Build Coastguard Workeruserfaultfd_use(artd)
33*e4a36f41SAndroid Build Coastguard Worker
34*e4a36f41SAndroid Build Coastguard Worker# Read access to primary dex'es on writable partitions
35*e4a36f41SAndroid Build Coastguard Worker# ({/data,/mnt/expand/<volume-uuid>}/app/...).
36*e4a36f41SAndroid Build Coastguard Worker# Also allow creating the "oat" directory before restorecon.
37*e4a36f41SAndroid Build Coastguard Workerallow artd mnt_expand_file:dir { getattr search };
38*e4a36f41SAndroid Build Coastguard Workerallow artd apk_data_file:dir { rw_dir_perms create setattr relabelfrom };
39*e4a36f41SAndroid Build Coastguard Workerallow artd apk_data_file:file r_file_perms;
40*e4a36f41SAndroid Build Coastguard Worker
41*e4a36f41SAndroid Build Coastguard Worker# Read access to vendor APKs ({/vendor,/odm}/{app,priv-app}/...).
42*e4a36f41SAndroid Build Coastguard Workerr_dir_file(artd, vendor_app_file)
43*e4a36f41SAndroid Build Coastguard Worker
44*e4a36f41SAndroid Build Coastguard Worker# Read access to vendor overlay APKs ({/vendor,/odm,/oem,/apex/*}/overlay/...).
45*e4a36f41SAndroid Build Coastguard Workerallow artd oemfs:dir { getattr search };
46*e4a36f41SAndroid Build Coastguard Workerr_dir_file(artd, vendor_overlay_file)
47*e4a36f41SAndroid Build Coastguard Worker# Vendor overlay can be found in vendor apex
48*e4a36f41SAndroid Build Coastguard Workerallow artd vendor_apex_metadata_file:dir { getattr search };
49*e4a36f41SAndroid Build Coastguard Worker
50*e4a36f41SAndroid Build Coastguard Worker# Read access to vendor shared libraries ({/vendor,/odm}/framework/...).
51*e4a36f41SAndroid Build Coastguard Workerr_dir_file(artd, vendor_framework_file)
52*e4a36f41SAndroid Build Coastguard Worker
53*e4a36f41SAndroid Build Coastguard Worker# Read/write access to all compilation artifacts generated on device for apps'
54*e4a36f41SAndroid Build Coastguard Worker# primary dex'es. (/data/dalvik-cache/..., /data/app/.../oat/..., etc.)
55*e4a36f41SAndroid Build Coastguard Workerallow artd dalvikcache_data_file:dir { create_dir_perms relabelto };
56*e4a36f41SAndroid Build Coastguard Workerallow artd dalvikcache_data_file:file { create_file_perms relabelto };
57*e4a36f41SAndroid Build Coastguard Worker
58*e4a36f41SAndroid Build Coastguard Worker# Read access to the ART APEX data directory.
59*e4a36f41SAndroid Build Coastguard Worker# Needed for reading the boot image generated on device.
60*e4a36f41SAndroid Build Coastguard Workerallow artd apex_module_data_file:dir { getattr search };
61*e4a36f41SAndroid Build Coastguard Workerr_dir_file(artd, apex_art_data_file)
62*e4a36f41SAndroid Build Coastguard Worker
63*e4a36f41SAndroid Build Coastguard Worker# Read access to /apex/apex-info-list.xml
64*e4a36f41SAndroid Build Coastguard Worker# Needed for getting APEX versions.
65*e4a36f41SAndroid Build Coastguard Workerallow artd apex_info_file:file r_file_perms;
66*e4a36f41SAndroid Build Coastguard Worker
67*e4a36f41SAndroid Build Coastguard Worker# Allow getting root capabilities to bypass permission checks.
68*e4a36f41SAndroid Build Coastguard Worker# - "dac_override" and "dac_read_search" are for
69*e4a36f41SAndroid Build Coastguard Worker#   - reading secondary dex'es in app data directories (reading primary dex'es
70*e4a36f41SAndroid Build Coastguard Worker#     doesn't need root capabilities)
71*e4a36f41SAndroid Build Coastguard Worker#   - managing (CRUD) compilation artifacts in both APK directories for primary
72*e4a36f41SAndroid Build Coastguard Worker#     dex'es and in app data directories for secondary dex'es
73*e4a36f41SAndroid Build Coastguard Worker#   - managing (CRUD) profile files for both primary dex'es and secondary dex'es
74*e4a36f41SAndroid Build Coastguard Worker# - "fowner" is for adjusting the file permissions of compilation artifacts and
75*e4a36f41SAndroid Build Coastguard Worker#   profile files based on whether they include user data or not.
76*e4a36f41SAndroid Build Coastguard Worker# - "chown" is for transferring the ownership of compilation artifacts and
77*e4a36f41SAndroid Build Coastguard Worker#   profile files to the system or apps.
78*e4a36f41SAndroid Build Coastguard Workerallow artd self:global_capability_class_set { dac_override dac_read_search fowner chown };
79*e4a36f41SAndroid Build Coastguard Worker
80*e4a36f41SAndroid Build Coastguard Worker# Read/write access to profiles (/data/misc/profiles/{ref,cur}/...). Also allow
81*e4a36f41SAndroid Build Coastguard Worker# scanning /data/misc/profiles/cur, for cleaning up obsolete managed files.
82*e4a36f41SAndroid Build Coastguard Workerallow artd user_profile_root_file:dir r_dir_perms;
83*e4a36f41SAndroid Build Coastguard Workerallow artd user_profile_data_file:dir rw_dir_perms;
84*e4a36f41SAndroid Build Coastguard Workerallow artd user_profile_data_file:file create_file_perms;
85*e4a36f41SAndroid Build Coastguard Worker
86*e4a36f41SAndroid Build Coastguard Worker# Read/write access to secondary dex files, their profiles, and their
87*e4a36f41SAndroid Build Coastguard Worker# compilation artifacts
88*e4a36f41SAndroid Build Coastguard Worker# ({/data,/mnt/expand/<volume-uuid>}/{user,user_de}/<user-id>/<package-name>/...).
89*e4a36f41SAndroid Build Coastguard Workerallow artd app_data_file_type:dir { create_dir_perms relabelfrom relabelto };
90*e4a36f41SAndroid Build Coastguard Workerallow artd app_data_file_type:file { create_file_perms relabelfrom relabelto };
91*e4a36f41SAndroid Build Coastguard Worker
92*e4a36f41SAndroid Build Coastguard Worker# Allow symlinks for secondary dex files. This has be to restricted because
93*e4a36f41SAndroid Build Coastguard Worker# symlinks can cause various security issues. We allow "privapp_data_file" just
94*e4a36f41SAndroid Build Coastguard Worker# for GMS because so far we only see GMS using symlinks.
95*e4a36f41SAndroid Build Coastguard Workerallow artd privapp_data_file:lnk_file { getattr read };
96*e4a36f41SAndroid Build Coastguard Worker
97*e4a36f41SAndroid Build Coastguard Worker# Read access to SELinux context files, for restorecon.
98*e4a36f41SAndroid Build Coastguard Workerallow artd file_contexts_file:file r_file_perms;
99*e4a36f41SAndroid Build Coastguard Workerallow artd seapp_contexts_file:file r_file_perms;
100*e4a36f41SAndroid Build Coastguard Worker
101*e4a36f41SAndroid Build Coastguard Worker# Check validity of SELinux context, for restorecon.
102*e4a36f41SAndroid Build Coastguard Workerselinux_check_context(artd)
103*e4a36f41SAndroid Build Coastguard Worker
104*e4a36f41SAndroid Build Coastguard Worker# Allow scanning /, for cleaning up obsolete managed files.
105*e4a36f41SAndroid Build Coastguard Workerallow artd rootfs:dir r_dir_perms;
106*e4a36f41SAndroid Build Coastguard Worker
107*e4a36f41SAndroid Build Coastguard Worker# Allow scanning /data, for cleaning up obsolete managed files.
108*e4a36f41SAndroid Build Coastguard Workerallow artd system_data_root_file:dir r_dir_perms;
109*e4a36f41SAndroid Build Coastguard Worker
110*e4a36f41SAndroid Build Coastguard Worker# Allow scanning /mnt, for cleaning up obsolete managed files.
111*e4a36f41SAndroid Build Coastguard Workerallow artd tmpfs:dir r_dir_perms;
112*e4a36f41SAndroid Build Coastguard Worker
113*e4a36f41SAndroid Build Coastguard Worker# Allow scanning /mnt/expand, for cleaning up obsolete managed files.
114*e4a36f41SAndroid Build Coastguard Workerallow artd mnt_expand_file:dir r_dir_perms;
115*e4a36f41SAndroid Build Coastguard Worker
116*e4a36f41SAndroid Build Coastguard Worker# Allow scanning {/data,/mnt/expand/<volume-uuid>}/{user,user_de}, for cleaning
117*e4a36f41SAndroid Build Coastguard Worker# up obsolete managed files.
118*e4a36f41SAndroid Build Coastguard Workerallow artd system_userdir_file:dir r_dir_perms;
119*e4a36f41SAndroid Build Coastguard Worker
120*e4a36f41SAndroid Build Coastguard Worker# Allow scanning {/data,/mnt/expand/<volume-uuid>}/{user,user_de}/<user-id> and
121*e4a36f41SAndroid Build Coastguard Worker# /mnt/expand/<volume-uuid>, for cleaning up obsolete managed files.
122*e4a36f41SAndroid Build Coastguard Workerallow artd system_data_file:dir r_dir_perms;
123*e4a36f41SAndroid Build Coastguard Worker
124*e4a36f41SAndroid Build Coastguard Worker# Never allow running other binaries without a domain transition.
125*e4a36f41SAndroid Build Coastguard Worker# The only exception is art_exec. It is allowed to use the artd domain because
126*e4a36f41SAndroid Build Coastguard Worker# it is a thin wrapper that executes other binaries on behalf of artd.
127*e4a36f41SAndroid Build Coastguard Workerneverallow artd ~{art_exec_exec}:file execute_no_trans;
128*e4a36f41SAndroid Build Coastguard Workerallow artd art_exec_exec:file rx_file_perms;
129*e4a36f41SAndroid Build Coastguard Worker
130*e4a36f41SAndroid Build Coastguard Worker# Allow running other binaries in their own domains.
131*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(artd, profman_exec, profman)
132*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(artd, dex2oat_exec, dex2oat)
133*e4a36f41SAndroid Build Coastguard Worker
134*e4a36f41SAndroid Build Coastguard Worker# Allow sending sigkill to subprocesses.
135*e4a36f41SAndroid Build Coastguard Workerallow artd { profman dex2oat }:process sigkill;
136*e4a36f41SAndroid Build Coastguard Worker
137*e4a36f41SAndroid Build Coastguard Worker# Allow reading process info (/proc/<pid>/...).
138*e4a36f41SAndroid Build Coastguard Worker# This is needed for getting CPU time and wall time spent on subprocesses.
139*e4a36f41SAndroid Build Coastguard Workerr_dir_file(artd, profman);
140*e4a36f41SAndroid Build Coastguard Workerr_dir_file(artd, dex2oat);
141*e4a36f41SAndroid Build Coastguard Worker
142*e4a36f41SAndroid Build Coastguard Worker# Allow artd to reopen its own memfd.
143*e4a36f41SAndroid Build Coastguard Worker# artd needs to reopen a memfd with readonly in order to pass it to subprocesses
144*e4a36f41SAndroid Build Coastguard Worker# that don't have write permissions on memfds.
145*e4a36f41SAndroid Build Coastguard Workerallow artd artd_tmpfs:file open;
146