Jiakai Zhang | c871c1c | 2022-07-19 21:29:31 +0100 | [diff] [blame] | 1 | # ART service daemon. |
| 2 | typeattribute artd coredomain; |
Jiakai Zhang | 28e69a4 | 2022-09-23 22:37:59 +0100 | [diff] [blame] | 3 | typeattribute artd mlstrustedsubject; |
Chris Wailes | 467d8a8 | 2021-03-03 12:30:28 -0800 | [diff] [blame] | 4 | type artd_exec, system_file_type, exec_type, file_type; |
Jiakai Zhang | 76bfb7e | 2022-05-26 13:55:33 +0100 | [diff] [blame] | 5 | type artd_tmpfs, file_type; |
Chris Wailes | 467d8a8 | 2021-03-03 12:30:28 -0800 | [diff] [blame] | 6 | |
| 7 | # Allow artd to publish a binder service and make binder calls. |
| 8 | binder_use(artd) |
| 9 | add_service(artd, artd_service) |
| 10 | allow artd dumpstate:fifo_file { getattr write }; |
| 11 | |
Chris Wailes | 467d8a8 | 2021-03-03 12:30:28 -0800 | [diff] [blame] | 12 | init_daemon_domain(artd) |
Calin Juravle | 0b2ca6c | 2021-05-18 15:33:08 -0700 | [diff] [blame] | 13 | |
| 14 | # Allow query ART device config properties |
| 15 | get_prop(artd, device_config_runtime_native_prop) |
| 16 | get_prop(artd, device_config_runtime_native_boot_prop) |
Jiakai Zhang | 76bfb7e | 2022-05-26 13:55:33 +0100 | [diff] [blame] | 17 | |
| 18 | # Access to "odsign.verification.success" for deciding whether to deny files in |
| 19 | # the ART APEX data directory. |
| 20 | get_prop(artd, odsign_prop) |
| 21 | |
| 22 | # Reading an APK opens a ZipArchive, which unpack to tmpfs. |
| 23 | # Use tmpfs_domain() which will give tmpfs files created by artd their |
| 24 | # own label, which differs from other labels created by other processes. |
| 25 | # This allows to distinguish in policy files created by artd vs other |
| 26 | # processes. |
| 27 | tmpfs_domain(artd) |
| 28 | |
| 29 | # Allow testing userfaultfd support. |
| 30 | userfaultfd_use(artd) |
| 31 | |
| 32 | # Read access to primary dex'es on writable partitions (e.g., /data/app/...). |
| 33 | r_dir_file(artd, apk_data_file) |
| 34 | |
| 35 | # Read access to /vendor/app. |
| 36 | r_dir_file(artd, vendor_app_file) |
| 37 | |
Jiakai Zhang | 2ce60a6 | 2022-06-07 15:20:58 +0100 | [diff] [blame] | 38 | # Read/write access to all compilation artifacts generated on device for apps' |
| 39 | # primary dex'es. (/data/dalvik-cache/..., /data/app/.../oat/..., etc.) |
| 40 | allow artd dalvikcache_data_file:dir create_dir_perms; |
| 41 | allow artd dalvikcache_data_file:file create_file_perms; |
Jiakai Zhang | 76bfb7e | 2022-05-26 13:55:33 +0100 | [diff] [blame] | 42 | |
| 43 | # Read access to the ART APEX data directory. |
| 44 | # Needed for reading the boot image generated on device. |
| 45 | allow artd apex_module_data_file:dir { getattr search }; |
| 46 | r_dir_file(artd, apex_art_data_file) |
| 47 | |
| 48 | # Read access to /apex/apex-info-list.xml |
| 49 | # Needed for getting APEX versions. |
| 50 | allow artd apex_info_file:file r_file_perms; |
Jiakai Zhang | 2ce60a6 | 2022-06-07 15:20:58 +0100 | [diff] [blame] | 51 | |
| 52 | # Allow getting root capabilities to bypass permission checks. |
| 53 | # - "dac_override" and "dac_read_search" are for |
| 54 | # - reading secondary dex'es in app data directories (reading primary dex'es |
| 55 | # doesn't need root capabilities) |
| 56 | # - managing (CRUD) compilation artifacts in both APK directories for primary |
| 57 | # dex'es and in app data directories for secondary dex'es |
| 58 | # - managing (CRUD) profile files for both primary dex'es and secondary dex'es |
| 59 | # - "fowner" is for adjusting the file permissions of compilation artifacts and |
| 60 | # profile files based on whether they include user data or not. |
Jiakai Zhang | c871c1c | 2022-07-19 21:29:31 +0100 | [diff] [blame] | 61 | # - "chown" is for transferring the ownership of compilation artifacts and |
| 62 | # profile files to the system or apps. |
| 63 | allow artd self:global_capability_class_set { dac_override dac_read_search fowner chown }; |
| 64 | |
| 65 | # Read/write access to profiles (/data/misc/profiles/{ref,cur}/...). |
Jiakai Zhang | 28e69a4 | 2022-09-23 22:37:59 +0100 | [diff] [blame] | 66 | allow artd user_profile_root_file:dir { getattr search }; |
Jiakai Zhang | ff67b84 | 2022-09-23 20:59:42 +0100 | [diff] [blame] | 67 | allow artd user_profile_data_file:dir rw_dir_perms; |
Jiakai Zhang | c871c1c | 2022-07-19 21:29:31 +0100 | [diff] [blame] | 68 | allow artd user_profile_data_file:file create_file_perms; |
| 69 | |
Jiakai Zhang | 2ffeca7 | 2022-10-21 17:03:56 +0100 | [diff] [blame] | 70 | # Read/write access to secondary dex files, their profiles, and their |
| 71 | # compilation artifacts |
| 72 | # ({/data,/mnt/expand/<volume-uuid>}/{user,user_de}/<user-id>/<package-name>/...). |
| 73 | allow artd app_data_file_type:dir { create_dir_perms relabelfrom relabelto }; |
| 74 | allow artd app_data_file_type:file { create_file_perms relabelfrom relabelto }; |
| 75 | |
Jiakai Zhang | c871c1c | 2022-07-19 21:29:31 +0100 | [diff] [blame] | 76 | # Never allow running other binaries without a domain transition. |
| 77 | # The only exception is art_exec. It is allowed to use the artd domain because |
| 78 | # it is a thin wrapper that executes other binaries on behalf of artd. |
| 79 | neverallow artd ~{art_exec_exec}:file execute_no_trans; |
| 80 | allow artd art_exec_exec:file rx_file_perms; |
| 81 | |
| 82 | # Allow running other binaries in their own domains. |
| 83 | domain_auto_trans(artd, profman_exec, profman) |
| 84 | domain_auto_trans(artd, dex2oat_exec, dex2oat) |
| 85 | |
| 86 | # Allow sending sigkill to subprocesses. |
| 87 | allow artd { profman dex2oat }:process sigkill; |
Jiakai Zhang | 88e5583 | 2022-09-07 23:52:09 +0100 | [diff] [blame] | 88 | |
| 89 | # Allow reading process info (/proc/<pid>/...). |
| 90 | # This is needed for getting CPU time and wall time spent on subprocesses. |
| 91 | r_dir_file(artd, profman); |
| 92 | r_dir_file(artd, dex2oat); |