1*e4a36f41SAndroid Build Coastguard Worker# Domain for a child process that manages virtual machines on behalf of its parent. 2*e4a36f41SAndroid Build Coastguard Worker 3*e4a36f41SAndroid Build Coastguard Workertype virtualizationmanager, domain, coredomain; 4*e4a36f41SAndroid Build Coastguard Workertype virtualizationmanager_exec, system_file_type, exec_type, file_type; 5*e4a36f41SAndroid Build Coastguard Worker 6*e4a36f41SAndroid Build Coastguard Worker# Allow virtualizationmanager to communicate use, read and write over the adb connection. 7*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager adbd:fd use; 8*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager adbd:unix_stream_socket { getattr read write }; 9*e4a36f41SAndroid Build Coastguard Worker 10*e4a36f41SAndroid Build Coastguard Worker# Allow writing VM logs to the shell console 11*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager devpts:chr_file { read write getattr ioctl }; 12*e4a36f41SAndroid Build Coastguard Worker 13*e4a36f41SAndroid Build Coastguard Worker# Let the virtualizationmanager domain use Binder. 14*e4a36f41SAndroid Build Coastguard Workerbinder_use(virtualizationmanager) 15*e4a36f41SAndroid Build Coastguard Worker 16*e4a36f41SAndroid Build Coastguard Worker# Let virtualizationmanager find and communicate with virtualizationservice. 17*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager virtualization_service:service_manager find; 18*e4a36f41SAndroid Build Coastguard Workerbinder_call(virtualizationmanager, virtualizationservice) 19*e4a36f41SAndroid Build Coastguard Worker 20*e4a36f41SAndroid Build Coastguard Worker# Allow calling into the system server to find native services. "permission_service" to check 21*e4a36f41SAndroid Build Coastguard Worker# permissions, and "package_native" for staged apex info. 22*e4a36f41SAndroid Build Coastguard Workerbinder_call(virtualizationmanager, system_server) 23*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager { package_native_service permission_service }:service_manager find; 24*e4a36f41SAndroid Build Coastguard Worker 25*e4a36f41SAndroid Build Coastguard Worker# When virtualizationmanager execs a file with the crosvm_exec label, run it in the crosvm domain. 26*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(virtualizationmanager, crosvm_exec, crosvm) 27*e4a36f41SAndroid Build Coastguard Worker 28*e4a36f41SAndroid Build Coastguard Worker# Let virtualizationmanager kill crosvm. 29*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager crosvm:process sigkill; 30*e4a36f41SAndroid Build Coastguard Worker 31*e4a36f41SAndroid Build Coastguard Worker# Let virtualizationmanager create files inside virtualizationservice's temporary directories. 32*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager virtualizationservice_data_file:dir rw_dir_perms; 33*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager virtualizationservice_data_file:{ file sock_file } create_file_perms; 34*e4a36f41SAndroid Build Coastguard Worker 35*e4a36f41SAndroid Build Coastguard Worker# Let virtualizationmanager read and write files from its various clients, but not open them 36*e4a36f41SAndroid Build Coastguard Worker# directly as they must be passed over Binder by the client. 37*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager apk_data_file:file { getattr read }; 38*e4a36f41SAndroid Build Coastguard Worker 39*e4a36f41SAndroid Build Coastguard Worker# Write access is needed for mutable partitions like instance.img 40*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager { 41*e4a36f41SAndroid Build Coastguard Worker app_data_file 42*e4a36f41SAndroid Build Coastguard Worker apex_compos_data_file 43*e4a36f41SAndroid Build Coastguard Worker apex_virt_data_file 44*e4a36f41SAndroid Build Coastguard Worker privapp_data_file 45*e4a36f41SAndroid Build Coastguard Worker}:file { getattr read write }; 46*e4a36f41SAndroid Build Coastguard Worker 47*e4a36f41SAndroid Build Coastguard Worker# shell_data_file is used for automated tests and manual debugging. 48*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager shell_data_file:file { getattr read write }; 49*e4a36f41SAndroid Build Coastguard Worker 50*e4a36f41SAndroid Build Coastguard Worker# Allow virtualizationmanager to read apex-info-list.xml and access the APEX files listed there. 51*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager apex_info_file:file r_file_perms; 52*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager apex_data_file:dir search; 53*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager staging_data_file:file r_file_perms; 54*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager staging_data_file:dir search; 55*e4a36f41SAndroid Build Coastguard Worker 56*e4a36f41SAndroid Build Coastguard Worker# Run derive_classpath in our domain 57*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager derive_classpath_exec:file rx_file_perms; 58*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager apex_mnt_dir:dir r_dir_perms; 59*e4a36f41SAndroid Build Coastguard Worker# Ignore harmless denials on /proc/self/fd 60*e4a36f41SAndroid Build Coastguard Workerdontaudit virtualizationmanager self:dir write; 61*e4a36f41SAndroid Build Coastguard Worker 62*e4a36f41SAndroid Build Coastguard Worker# Let virtualizationmanager to accept vsock connection from the guest VMs 63*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager self:vsock_socket { create_socket_perms_no_ioctl listen accept }; 64*e4a36f41SAndroid Build Coastguard Worker 65*e4a36f41SAndroid Build Coastguard Worker# Allow virtualizationmanager to inspect all hypervisor capabilities. 66*e4a36f41SAndroid Build Coastguard Workerget_prop(virtualizationmanager, hypervisor_prop) 67*e4a36f41SAndroid Build Coastguard Workerget_prop(virtualizationmanager, hypervisor_restricted_prop) 68*e4a36f41SAndroid Build Coastguard Worker 69*e4a36f41SAndroid Build Coastguard Worker# Allow virtualizationmanager to be read custom pvmfw.img configuration 70*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`get_prop(virtualizationmanager, hypervisor_pvmfw_prop)') 71*e4a36f41SAndroid Build Coastguard Workerdontaudit virtualizationmanager hypervisor_pvmfw_prop:file read; 72*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -dumpstate userdebug_or_eng(`-virtualizationmanager') } hypervisor_pvmfw_prop:file no_rw_file_perms; 73*e4a36f41SAndroid Build Coastguard Worker 74*e4a36f41SAndroid Build Coastguard Worker# Allow virtualizationmanager to be read custom virtualizationmanager configuration 75*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`get_prop(virtualizationmanager, hypervisor_virtualizationmanager_prop)') 76*e4a36f41SAndroid Build Coastguard Workerdontaudit virtualizationmanager hypervisor_virtualizationmanager_prop:file read; 77*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init -dumpstate userdebug_or_eng(`-virtualizationmanager') } hypervisor_virtualizationmanager_prop:file no_rw_file_perms; 78*e4a36f41SAndroid Build Coastguard Worker 79*e4a36f41SAndroid Build Coastguard Worker# Allow virtualizationmanager service to talk to tombstoned to push guest ramdumps 80*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(virtualizationmanager, tombstoned_crash, tombstoned) 81*e4a36f41SAndroid Build Coastguard Worker 82*e4a36f41SAndroid Build Coastguard Worker# Append ramdumps to tombstone files passed as fds from tombstoned 83*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager tombstone_data_file:file { append getattr }; 84*e4a36f41SAndroid Build Coastguard Workerallow virtualizationmanager tombstoned:fd use; 85*e4a36f41SAndroid Build Coastguard Worker 86*e4a36f41SAndroid Build Coastguard Worker# Allow virtualizationmanager to read file system DT for VM reference DT and AVF debug policy 87*e4a36f41SAndroid Build Coastguard Workerr_dir_file(virtualizationmanager, proc_dt_avf) 88*e4a36f41SAndroid Build Coastguard Workerr_dir_file(virtualizationmanager, sysfs_dt_avf) 89*e4a36f41SAndroid Build Coastguard Worker 90*e4a36f41SAndroid Build Coastguard Worker# virtualizationmanager to be client of secretkeeper HAL. It ferries SecretManagement messages 91*e4a36f41SAndroid Build Coastguard Worker# from pVM to HAL. 92*e4a36f41SAndroid Build Coastguard Workerhal_client_domain(virtualizationmanager, hal_secretkeeper); 93*e4a36f41SAndroid Build Coastguard Worker 94*e4a36f41SAndroid Build Coastguard Worker# Let virtualizationmanager open test artifacts under /data/local/tmp with file path. 95*e4a36f41SAndroid Build Coastguard Worker# (e.g. custom debug policy) 96*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(` 97*e4a36f41SAndroid Build Coastguard Worker allow virtualizationmanager shell_data_file:dir search; 98*e4a36f41SAndroid Build Coastguard Worker allow virtualizationmanager shell_data_file:file open; 99*e4a36f41SAndroid Build Coastguard Worker') 100*e4a36f41SAndroid Build Coastguard Worker 101*e4a36f41SAndroid Build Coastguard Worker# Allow virtualizationmanager to read microdroid related files in vendor partition 102*e4a36f41SAndroid Build Coastguard Workerr_dir_file(virtualizationmanager, vendor_microdroid_file) 103*e4a36f41SAndroid Build Coastguard Worker 104*e4a36f41SAndroid Build Coastguard Worker# Do not allow writing vendor_microdroid_file from any process. 105*e4a36f41SAndroid Build Coastguard Workerneverallow { domain recovery_only(`userdebug_or_eng(`-fastbootd')') } vendor_microdroid_file:dir no_w_dir_perms; 106*e4a36f41SAndroid Build Coastguard Workerneverallow { domain recovery_only(`userdebug_or_eng(`-fastbootd')') } vendor_microdroid_file:file no_w_file_perms; 107*e4a36f41SAndroid Build Coastguard Worker 108*e4a36f41SAndroid Build Coastguard Worker# Allow reading files under /proc/[crosvm pid]/, for collecting CPU & memory usage inside VM. 109*e4a36f41SAndroid Build Coastguard Workerr_dir_file(virtualizationmanager, crosvm); 110*e4a36f41SAndroid Build Coastguard Worker 111*e4a36f41SAndroid Build Coastguard Worker# For debug purposes we try to get the canonical path from /proc/self/fd/N. That triggers 112*e4a36f41SAndroid Build Coastguard Worker# a harmless denial for CompOS log files, so ignore that. 113*e4a36f41SAndroid Build Coastguard Workerdontaudit virtualizationmanager apex_module_data_file:dir search; 114*e4a36f41SAndroid Build Coastguard Worker 115*e4a36f41SAndroid Build Coastguard Workeris_flag_enabled(RELEASE_AVF_ENABLE_DEVICE_ASSIGNMENT, ` 116*e4a36f41SAndroid Build Coastguard Worker # virtualizationmanager holds references to bound devices, returned from vfio_handler 117*e4a36f41SAndroid Build Coastguard Worker binder_call(virtualizationmanager, vfio_handler) 118*e4a36f41SAndroid Build Coastguard Worker') 119