David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 1 | # Domain for a child process that manages virtual machines on behalf of its parent. |
| 2 | |
| 3 | type virtualizationmanager, domain, coredomain; |
| 4 | type virtualizationmanager_exec, system_file_type, exec_type, file_type; |
| 5 | |
| 6 | # Allow virtualizationmanager to communicate use, read and write over the adb connection. |
| 7 | allow virtualizationmanager adbd:fd use; |
Alice Wang | ea51816 | 2023-09-04 12:26:03 +0000 | [diff] [blame] | 8 | allow virtualizationmanager adbd:unix_stream_socket { getattr read write }; |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 9 | |
Alan Stokes | 6d019be | 2023-06-08 13:13:08 +0100 | [diff] [blame] | 10 | # Allow writing VM logs to the shell console |
| 11 | allow virtualizationmanager devpts:chr_file { read write getattr ioctl }; |
| 12 | |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 13 | # Let the virtualizationmanager domain use Binder. |
| 14 | binder_use(virtualizationmanager) |
| 15 | |
| 16 | # Let virtualizationmanager find and communicate with virtualizationservice. |
| 17 | allow virtualizationmanager virtualization_service:service_manager find; |
| 18 | binder_call(virtualizationmanager, virtualizationservice) |
| 19 | |
| 20 | # Allow calling into the system server to find native services. "permission_service" to check |
| 21 | # permissions, and "package_native" for staged apex info. |
| 22 | binder_call(virtualizationmanager, system_server) |
| 23 | allow virtualizationmanager { package_native_service permission_service }:service_manager find; |
| 24 | |
| 25 | # When virtualizationmanager execs a file with the crosvm_exec label, run it in the crosvm domain. |
| 26 | domain_auto_trans(virtualizationmanager, crosvm_exec, crosvm) |
| 27 | |
| 28 | # Let virtualizationmanager kill crosvm. |
| 29 | allow virtualizationmanager crosvm:process sigkill; |
| 30 | |
| 31 | # Let virtualizationmanager create files inside virtualizationservice's temporary directories. |
| 32 | allow virtualizationmanager virtualizationservice_data_file:dir rw_dir_perms; |
| 33 | allow virtualizationmanager virtualizationservice_data_file:{ file sock_file } create_file_perms; |
| 34 | |
| 35 | # Let virtualizationmanager read and write files from its various clients, but not open them |
| 36 | # directly as they must be passed over Binder by the client. |
| 37 | allow virtualizationmanager apk_data_file:file { getattr read }; |
| 38 | |
| 39 | # Write access is needed for mutable partitions like instance.img |
| 40 | allow virtualizationmanager { |
| 41 | app_data_file |
| 42 | apex_compos_data_file |
Alice Wang | 40519f7 | 2023-08-31 11:37:30 +0000 | [diff] [blame] | 43 | apex_virt_data_file |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 44 | privapp_data_file |
| 45 | }:file { getattr read write }; |
| 46 | |
| 47 | # shell_data_file is used for automated tests and manual debugging. |
| 48 | allow virtualizationmanager shell_data_file:file { getattr read write }; |
| 49 | |
| 50 | # Allow virtualizationmanager to read apex-info-list.xml and access the APEX files listed there. |
| 51 | allow virtualizationmanager apex_info_file:file r_file_perms; |
| 52 | allow virtualizationmanager apex_data_file:dir search; |
| 53 | allow virtualizationmanager staging_data_file:file r_file_perms; |
| 54 | allow virtualizationmanager staging_data_file:dir search; |
| 55 | |
| 56 | # Run derive_classpath in our domain |
| 57 | allow virtualizationmanager derive_classpath_exec:file rx_file_perms; |
| 58 | allow virtualizationmanager apex_mnt_dir:dir r_dir_perms; |
| 59 | # Ignore harmless denials on /proc/self/fd |
| 60 | dontaudit virtualizationmanager self:dir write; |
| 61 | |
| 62 | # Let virtualizationmanager to accept vsock connection from the guest VMs |
| 63 | allow virtualizationmanager self:vsock_socket { create_socket_perms_no_ioctl listen accept }; |
Steven Moreland | 378ed74 | 2024-06-05 21:29:02 +0000 | [diff] [blame] | 64 | neverallow { domain -virtualizationmanager } virtualizationmanager:vsock_socket { accept bind create connect listen }; |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 65 | |
| 66 | # Allow virtualizationmanager to inspect all hypervisor capabilities. |
| 67 | get_prop(virtualizationmanager, hypervisor_prop) |
| 68 | get_prop(virtualizationmanager, hypervisor_restricted_prop) |
| 69 | |
Jaewan Kim | 4183cbb | 2023-08-31 07:58:08 +0000 | [diff] [blame] | 70 | # Allow virtualizationmanager to be read custom pvmfw.img configuration |
| 71 | userdebug_or_eng(`get_prop(virtualizationmanager, hypervisor_pvmfw_prop)') |
| 72 | dontaudit virtualizationmanager hypervisor_pvmfw_prop:file read; |
Inseob Kim | 41fe7ea | 2024-09-03 10:59:07 +0900 | [diff] [blame] | 73 | neverallow { |
| 74 | domain |
| 75 | -init |
| 76 | -dumpstate |
| 77 | userdebug_or_eng(`-virtualizationmanager') |
| 78 | is_flag_enabled(RELEASE_AVF_ENABLE_EARLY_VM, -early_virtmgr) |
| 79 | } hypervisor_pvmfw_prop:file no_rw_file_perms; |
Jaewan Kim | 4183cbb | 2023-08-31 07:58:08 +0000 | [diff] [blame] | 80 | |
| 81 | # Allow virtualizationmanager to be read custom virtualizationmanager configuration |
| 82 | userdebug_or_eng(`get_prop(virtualizationmanager, hypervisor_virtualizationmanager_prop)') |
| 83 | dontaudit virtualizationmanager hypervisor_virtualizationmanager_prop:file read; |
Inseob Kim | 41fe7ea | 2024-09-03 10:59:07 +0900 | [diff] [blame] | 84 | neverallow { |
| 85 | domain |
| 86 | -init |
| 87 | -dumpstate |
| 88 | userdebug_or_eng(`-virtualizationmanager') |
| 89 | is_flag_enabled(RELEASE_AVF_ENABLE_EARLY_VM, -early_virtmgr) |
| 90 | } hypervisor_virtualizationmanager_prop:file no_rw_file_perms; |
Jaewan Kim | 4183cbb | 2023-08-31 07:58:08 +0000 | [diff] [blame] | 91 | |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 92 | # Allow virtualizationmanager service to talk to tombstoned to push guest ramdumps |
| 93 | unix_socket_connect(virtualizationmanager, tombstoned_crash, tombstoned) |
| 94 | |
| 95 | # Append ramdumps to tombstone files passed as fds from tombstoned |
| 96 | allow virtualizationmanager tombstone_data_file:file { append getattr }; |
| 97 | allow virtualizationmanager tombstoned:fd use; |
| 98 | |
Jaewan Kim | 2141ad5 | 2024-01-31 05:56:43 +0000 | [diff] [blame] | 99 | # Allow virtualizationmanager to read file system DT for VM reference DT and AVF debug policy |
| 100 | r_dir_file(virtualizationmanager, proc_dt_avf) |
| 101 | r_dir_file(virtualizationmanager, sysfs_dt_avf) |
Jaewan Kim | 93f5788 | 2023-02-07 01:49:24 +0900 | [diff] [blame] | 102 | |
Shikha Panwar | c9b9921 | 2023-12-14 22:08:26 +0000 | [diff] [blame] | 103 | # virtualizationmanager to be client of secretkeeper HAL. It ferries SecretManagement messages |
| 104 | # from pVM to HAL. |
| 105 | hal_client_domain(virtualizationmanager, hal_secretkeeper); |
| 106 | |
Jaewan Kim | 0783a9c | 2023-04-03 12:57:25 +0900 | [diff] [blame] | 107 | # Let virtualizationmanager open test artifacts under /data/local/tmp with file path. |
| 108 | # (e.g. custom debug policy) |
| 109 | userdebug_or_eng(` |
| 110 | allow virtualizationmanager shell_data_file:dir search; |
| 111 | allow virtualizationmanager shell_data_file:file open; |
| 112 | ') |
| 113 | |
Seungjae Yoo | d2a0892 | 2023-11-15 17:59:30 +0900 | [diff] [blame] | 114 | # Allow virtualizationmanager to read microdroid related files in vendor partition |
| 115 | r_dir_file(virtualizationmanager, vendor_microdroid_file) |
| 116 | |
Seungjae Yoo | ed25d94 | 2023-11-27 15:01:40 +0900 | [diff] [blame] | 117 | # Do not allow writing vendor_microdroid_file from any process. |
| 118 | neverallow { domain recovery_only(`userdebug_or_eng(`-fastbootd')') } vendor_microdroid_file:dir no_w_dir_perms; |
| 119 | neverallow { domain recovery_only(`userdebug_or_eng(`-fastbootd')') } vendor_microdroid_file:file no_w_file_perms; |
| 120 | |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 121 | # Allow reading files under /proc/[crosvm pid]/, for collecting CPU & memory usage inside VM. |
| 122 | r_dir_file(virtualizationmanager, crosvm); |
Alan Stokes | c5b9146 | 2023-01-05 14:03:13 +0000 | [diff] [blame] | 123 | |
| 124 | # For debug purposes we try to get the canonical path from /proc/self/fd/N. That triggers |
| 125 | # a harmless denial for CompOS log files, so ignore that. |
| 126 | dontaudit virtualizationmanager apex_module_data_file:dir search; |
Inseob Kim | fb0ed7f | 2024-01-03 09:32:18 +0900 | [diff] [blame] | 127 | |
| 128 | is_flag_enabled(RELEASE_AVF_ENABLE_DEVICE_ASSIGNMENT, ` |
| 129 | # virtualizationmanager holds references to bound devices, returned from vfio_handler |
| 130 | binder_call(virtualizationmanager, vfio_handler) |
| 131 | ') |
Seungjae Yoo | 80fd618 | 2024-05-20 16:59:02 +0900 | [diff] [blame] | 132 | |
| 133 | is_flag_enabled(RELEASE_AVF_ENABLE_NETWORK, ` |
| 134 | # Allow virtualizationmanager to deal with file descriptors of TAP interfaces. |
| 135 | allow virtualizationmanager tun_device:chr_file rw_file_perms; |
| 136 | allow virtualizationmanager vmnic:fd use; |
| 137 | ') |
Nikita Ioffe | 48966b6 | 2024-10-22 14:01:17 +0000 | [diff] [blame^] | 138 | |
| 139 | # virtualizationmanager reads tee_service_contexts_file to determine if VM is allowed |
| 140 | # to access requested tee services |
| 141 | allow virtualizationmanager tee_service_contexts_file:file r_file_perms; |
| 142 | # virtualizationmanager uses libselinux to check if VM is allowed to access requested |
| 143 | # tee services. |
| 144 | selinux_check_access(virtualizationmanager) |