blob: 3b234bfe3c68b0bd728bfb3935f3a6fa8d09cdd8 [file] [log] [blame]
Jiakai Zhangc871c1c2022-07-19 21:29:31 +01001# ART service daemon.
2typeattribute artd coredomain;
Jiakai Zhang28e69a42022-09-23 22:37:59 +01003typeattribute artd mlstrustedsubject;
Chris Wailes467d8a82021-03-03 12:30:28 -08004type artd_exec, system_file_type, exec_type, file_type;
Jiakai Zhang76bfb7e2022-05-26 13:55:33 +01005type artd_tmpfs, file_type;
Chris Wailes467d8a82021-03-03 12:30:28 -08006
7# Allow artd to publish a binder service and make binder calls.
8binder_use(artd)
9add_service(artd, artd_service)
ThiƩbaud Weksteen8a250b92023-08-24 10:37:17 +100010allow artd dumpstate:fifo_file { getattr write };
11allow artd dumpstate:fd use;
Chris Wailes467d8a82021-03-03 12:30:28 -080012
Chris Wailes467d8a82021-03-03 12:30:28 -080013init_daemon_domain(artd)
Calin Juravle0b2ca6c2021-05-18 15:33:08 -070014
15# Allow query ART device config properties
16get_prop(artd, device_config_runtime_native_prop)
17get_prop(artd, device_config_runtime_native_boot_prop)
Jiakai Zhang76bfb7e2022-05-26 13:55:33 +010018
19# Access to "odsign.verification.success" for deciding whether to deny files in
20# the ART APEX data directory.
21get_prop(artd, odsign_prop)
22
23# Reading an APK opens a ZipArchive, which unpack to tmpfs.
24# Use tmpfs_domain() which will give tmpfs files created by artd their
25# own label, which differs from other labels created by other processes.
26# This allows to distinguish in policy files created by artd vs other
27# processes.
28tmpfs_domain(artd)
29
30# Allow testing userfaultfd support.
31userfaultfd_use(artd)
32
Jiakai Zhang5e531052022-12-12 14:28:40 +000033# Read access to primary dex'es on writable partitions
34# ({/data,/mnt/expand/<volume-uuid>}/app/...).
Jiakai Zhang77894602023-01-17 16:57:03 +080035# Also allow creating the "oat" directory before restorecon.
Jiakai Zhang5e531052022-12-12 14:28:40 +000036allow artd mnt_expand_file:dir { getattr search };
Jiakai Zhang77894602023-01-17 16:57:03 +080037allow artd apk_data_file:dir { rw_dir_perms create setattr relabelfrom };
38allow artd apk_data_file:file r_file_perms;
Jiakai Zhang76bfb7e2022-05-26 13:55:33 +010039
Jiakai Zhang5e531052022-12-12 14:28:40 +000040# Read access to vendor APKs ({/vendor,/odm}/{app,priv-app}/...).
Jiakai Zhang76bfb7e2022-05-26 13:55:33 +010041r_dir_file(artd, vendor_app_file)
42
Jooyung Han7c4f8a82023-06-09 13:26:54 +090043# Read access to vendor overlay APKs ({/vendor,/odm,/oem,/apex/*}/overlay/...).
Jiakai Zhang5e531052022-12-12 14:28:40 +000044allow artd oemfs:dir { getattr search };
45r_dir_file(artd, vendor_overlay_file)
Jooyung Han7c4f8a82023-06-09 13:26:54 +090046# Vendor overlay can be found in vendor apex
47allow artd vendor_apex_metadata_file:dir { getattr search };
Jiakai Zhang5e531052022-12-12 14:28:40 +000048
49# Read access to vendor shared libraries ({/vendor,/odm}/framework/...).
50r_dir_file(artd, vendor_framework_file)
51
Jiakai Zhang2ce60a62022-06-07 15:20:58 +010052# Read/write access to all compilation artifacts generated on device for apps'
53# primary dex'es. (/data/dalvik-cache/..., /data/app/.../oat/..., etc.)
Jiakai Zhang77894602023-01-17 16:57:03 +080054allow artd dalvikcache_data_file:dir { create_dir_perms relabelto };
55allow artd dalvikcache_data_file:file { create_file_perms relabelto };
Jiakai Zhang76bfb7e2022-05-26 13:55:33 +010056
57# Read access to the ART APEX data directory.
58# Needed for reading the boot image generated on device.
59allow artd apex_module_data_file:dir { getattr search };
60r_dir_file(artd, apex_art_data_file)
61
62# Read access to /apex/apex-info-list.xml
63# Needed for getting APEX versions.
64allow artd apex_info_file:file r_file_perms;
Jiakai Zhang2ce60a62022-06-07 15:20:58 +010065
66# Allow getting root capabilities to bypass permission checks.
67# - "dac_override" and "dac_read_search" are for
68# - reading secondary dex'es in app data directories (reading primary dex'es
69# doesn't need root capabilities)
70# - managing (CRUD) compilation artifacts in both APK directories for primary
71# dex'es and in app data directories for secondary dex'es
72# - managing (CRUD) profile files for both primary dex'es and secondary dex'es
73# - "fowner" is for adjusting the file permissions of compilation artifacts and
74# profile files based on whether they include user data or not.
Jiakai Zhangc871c1c2022-07-19 21:29:31 +010075# - "chown" is for transferring the ownership of compilation artifacts and
76# profile files to the system or apps.
77allow artd self:global_capability_class_set { dac_override dac_read_search fowner chown };
78
Jiakai Zhang440ae782022-12-23 16:24:14 +000079# Read/write access to profiles (/data/misc/profiles/{ref,cur}/...). Also allow
80# scanning /data/misc/profiles/cur, for cleaning up obsolete managed files.
81allow artd user_profile_root_file:dir r_dir_perms;
Jiakai Zhangff67b842022-09-23 20:59:42 +010082allow artd user_profile_data_file:dir rw_dir_perms;
Jiakai Zhangc871c1c2022-07-19 21:29:31 +010083allow artd user_profile_data_file:file create_file_perms;
84
Jiakai Zhang2ffeca72022-10-21 17:03:56 +010085# Read/write access to secondary dex files, their profiles, and their
86# compilation artifacts
87# ({/data,/mnt/expand/<volume-uuid>}/{user,user_de}/<user-id>/<package-name>/...).
88allow artd app_data_file_type:dir { create_dir_perms relabelfrom relabelto };
89allow artd app_data_file_type:file { create_file_perms relabelfrom relabelto };
90
Jiakai Zhang68345972022-12-12 14:34:50 +000091# Allow symlinks for secondary dex files. This has be to restricted because
92# symlinks can cause various security issues. We allow "privapp_data_file" just
93# for GMS because so far we only see GMS using symlinks.
94allow artd privapp_data_file:lnk_file { getattr read };
95
Jiakai Zhangd7f81192022-12-12 13:45:13 +000096# Read access to SELinux context files, for restorecon.
97allow artd file_contexts_file:file r_file_perms;
98allow artd seapp_contexts_file:file r_file_perms;
99
100# Check validity of SELinux context, for restorecon.
101selinux_check_context(artd)
102
Jiakai Zhang440ae782022-12-23 16:24:14 +0000103# Allow scanning /, for cleaning up obsolete managed files.
104allow artd rootfs:dir r_dir_perms;
105
106# Allow scanning /data, for cleaning up obsolete managed files.
107allow artd system_data_root_file:dir r_dir_perms;
108
109# Allow scanning /mnt, for cleaning up obsolete managed files.
110allow artd tmpfs:dir r_dir_perms;
111
112# Allow scanning /mnt/expand, for cleaning up obsolete managed files.
113allow artd mnt_expand_file:dir r_dir_perms;
114
115# Allow scanning {/data,/mnt/expand/<volume-uuid>}/{user,user_de}, for cleaning
116# up obsolete managed files.
117allow artd system_userdir_file:dir r_dir_perms;
118
119# Allow scanning {/data,/mnt/expand/<volume-uuid>}/{user,user_de}/<user-id> and
120# /mnt/expand/<volume-uuid>, for cleaning up obsolete managed files.
121allow artd system_data_file:dir r_dir_perms;
122
Jiakai Zhangc871c1c2022-07-19 21:29:31 +0100123# Never allow running other binaries without a domain transition.
124# The only exception is art_exec. It is allowed to use the artd domain because
125# it is a thin wrapper that executes other binaries on behalf of artd.
126neverallow artd ~{art_exec_exec}:file execute_no_trans;
127allow artd art_exec_exec:file rx_file_perms;
128
129# Allow running other binaries in their own domains.
130domain_auto_trans(artd, profman_exec, profman)
131domain_auto_trans(artd, dex2oat_exec, dex2oat)
132
133# Allow sending sigkill to subprocesses.
134allow artd { profman dex2oat }:process sigkill;
Jiakai Zhang88e55832022-09-07 23:52:09 +0100135
136# Allow reading process info (/proc/<pid>/...).
137# This is needed for getting CPU time and wall time spent on subprocesses.
138r_dir_file(artd, profman);
139r_dir_file(artd, dex2oat);