2021-05-21 15:21:43 +02:00
|
|
|
type virtualizationservice, domain, coredomain;
|
|
|
|
type virtualizationservice_exec, system_file_type, exec_type, file_type;
|
|
|
|
|
2022-12-15 14:38:42 +01:00
|
|
|
# The domain needs to be a 'mlstrustedsubject' to change the memlock rlimit of
|
|
|
|
# the virtualizationmanager domain running at a more constrained MLS level.
|
|
|
|
typeattribute virtualizationservice mlstrustedsubject;
|
|
|
|
|
2021-05-21 15:21:43 +02:00
|
|
|
# When init runs a file labelled with virtualizationservice_exec, run it in the
|
|
|
|
# virtualizationservice domain.
|
|
|
|
init_daemon_domain(virtualizationservice)
|
|
|
|
|
|
|
|
# Let the virtualizationservice domain use Binder.
|
|
|
|
binder_use(virtualizationservice)
|
|
|
|
|
2024-02-20 12:06:37 +01:00
|
|
|
# Register our services with ServiceManager.
|
2021-05-21 15:21:43 +02:00
|
|
|
add_service(virtualizationservice, virtualization_service)
|
2024-02-20 12:06:37 +01:00
|
|
|
is_flag_enabled(RELEASE_AVF_ENABLE_LLPVM_CHANGES, `
|
|
|
|
add_service(virtualizationservice, virtualization_maintenance_service)
|
|
|
|
')
|
2021-05-21 15:21:43 +02:00
|
|
|
|
2024-04-02 07:50:14 +02:00
|
|
|
is_flag_enabled(RELEASE_AVF_SUPPORT_CUSTOM_VM_WITH_PARAVIRTUALIZED_DEVICES, `
|
2023-11-17 10:03:46 +01:00
|
|
|
# Let virtualizationservice find and communicate with vfio_handler.
|
|
|
|
allow virtualizationservice vfio_handler_service:service_manager find;
|
|
|
|
binder_call(virtualizationservice, vfio_handler)
|
|
|
|
')
|
2023-08-01 04:00:49 +02:00
|
|
|
|
2023-11-14 08:38:18 +01:00
|
|
|
# Allow the virtualizationservice domain to serve a remotely provisioned component for
|
|
|
|
# pVM remote attestation.
|
|
|
|
hal_server_domain(virtualizationservice, hal_remotelyprovisionedcomponent_avf)
|
|
|
|
|
2023-01-12 22:10:33 +01:00
|
|
|
# Allow calling into the system server to find "permission_service".
|
|
|
|
binder_call(virtualizationservice, system_server)
|
|
|
|
allow virtualizationservice permission_service:service_manager find;
|
|
|
|
|
2024-01-18 17:18:47 +01:00
|
|
|
# Allow virtualizationservice to retrieve the remotely provisioned keys from rkpd.
|
|
|
|
binder_call(virtualizationservice, remote_provisioning_service)
|
|
|
|
allow virtualizationservice remote_provisioning_service:service_manager find;
|
|
|
|
|
2024-02-16 19:05:32 +01:00
|
|
|
# Allow virtualizationservice to manage VM secrets via Secretkeeper.
|
|
|
|
hal_client_domain(virtualizationservice, hal_secretkeeper)
|
|
|
|
|
2022-12-15 14:38:42 +01:00
|
|
|
# Let virtualizationservice remove memlock rlimit of virtualizationmanager. This is necessary
|
|
|
|
# to mlock VM memory and page tables.
|
2022-10-28 14:57:58 +02:00
|
|
|
allow virtualizationservice self:capability sys_resource;
|
2022-12-15 14:38:42 +01:00
|
|
|
allow virtualizationservice virtualizationmanager:process setrlimit;
|
2022-10-28 14:57:58 +02:00
|
|
|
|
2024-04-02 07:50:14 +02:00
|
|
|
is_flag_enabled(RELEASE_AVF_SUPPORT_CUSTOM_VM_WITH_PARAVIRTUALIZED_DEVICES, `
|
|
|
|
# To provide display service to an app to get surface.
|
|
|
|
# TODO(b/332677707): remove them when display service uses binder RPC.
|
|
|
|
allow virtualizationservice priv_app:binder transfer;
|
|
|
|
')
|
|
|
|
|
2022-12-15 14:38:42 +01:00
|
|
|
# Let virtualizationservice set the owner of a VM's temporary directory.
|
|
|
|
allow virtualizationservice self:capability chown;
|
2021-05-21 15:21:43 +02:00
|
|
|
|
2022-12-15 14:38:42 +01:00
|
|
|
# Let virtualizationservice create and delete temporary directories of VMs. To remove old
|
|
|
|
# directories, it needs the permission to unlink the files created by virtualizationmanager.
|
2021-05-21 15:21:43 +02:00
|
|
|
allow virtualizationservice virtualizationservice_data_file:dir create_dir_perms;
|
2023-09-07 08:37:40 +02:00
|
|
|
allow virtualizationservice virtualizationservice_data_file:sock_file unlink;
|
|
|
|
allow virtualizationservice virtualizationservice_data_file:file create_file_perms;
|
2022-07-11 16:27:40 +02:00
|
|
|
|
2021-07-12 14:11:33 +02:00
|
|
|
# Allow to use fd (e.g. /dev/pts/0) inherited from adbd so that we can redirect output from
|
|
|
|
# crosvm to the console
|
|
|
|
allow virtualizationservice adbd:fd use;
|
|
|
|
allow virtualizationservice adbd:unix_stream_socket { read write };
|
2021-07-01 17:58:26 +02:00
|
|
|
|
2023-08-31 13:37:30 +02:00
|
|
|
# Allow to connnect to and run VirtMgr to start the service VM for remote attestation.
|
|
|
|
virtualizationservice_use(virtualizationservice)
|
|
|
|
|
|
|
|
# Allow virtualizationservice to read and write in the apex data directory
|
2024-02-19 18:44:08 +01:00
|
|
|
# /data/misc/apexdata/com.android.virt. Also allow checking of the parent directory
|
|
|
|
# (needed for SQLite database creation).
|
|
|
|
allow virtualizationservice apex_module_data_file:dir { search getattr };
|
2023-08-31 13:37:30 +02:00
|
|
|
allow virtualizationservice apex_virt_data_file:dir create_dir_perms;
|
|
|
|
allow virtualizationservice apex_virt_data_file:file create_file_perms;
|
|
|
|
|
2022-12-15 14:38:42 +01:00
|
|
|
# Let virtualizationservice to accept vsock connection from the guest VMs to singleton services
|
|
|
|
# such as the guest tombstone server.
|
2021-07-10 07:35:06 +02:00
|
|
|
allow virtualizationservice self:vsock_socket { create_socket_perms_no_ioctl listen accept };
|
2021-09-16 14:06:20 +02:00
|
|
|
|
|
|
|
# Allow virtualizationservice to read/write its own sysprop. Only the process can do so.
|
|
|
|
set_prop(virtualizationservice, virtualizationservice_prop)
|
2022-01-04 18:34:53 +01:00
|
|
|
|
2022-01-21 13:18:08 +01:00
|
|
|
# Allow writing stats to statsd
|
|
|
|
unix_socket_send(virtualizationservice, statsdw, statsd)
|
|
|
|
|
2022-03-24 10:05:59 +01:00
|
|
|
# Allow virtualization service to talk to tombstoned to push guest tombstones
|
|
|
|
unix_socket_connect(virtualizationservice, tombstoned_crash, tombstoned)
|
|
|
|
|
|
|
|
# Append to tombstone files passed as fds from tombstoned
|
|
|
|
allow virtualizationservice tombstone_data_file:file { append getattr };
|
|
|
|
allow virtualizationservice tombstoned:fd use;
|
|
|
|
|
2023-08-01 04:00:49 +02:00
|
|
|
# Allow virtualizationservice to check if VFIO is supported
|
|
|
|
allow virtualizationservice vfio_device:chr_file getattr;
|
|
|
|
allow virtualizationservice vfio_device:dir r_dir_perms;
|
|
|
|
|
2023-08-03 05:53:48 +02:00
|
|
|
# Allow virtualizationservice to access VM DTBO via a file created by virtualizationmanager.
|
|
|
|
allow virtualizationservice virtualizationmanager:fd use;
|
2023-08-01 04:00:49 +02:00
|
|
|
|
2023-08-30 07:04:24 +02:00
|
|
|
# Allow virtualizationservice to access vendor_configs_file to get the list of assignable devices.
|
|
|
|
r_dir_file(virtualizationservice, vendor_configs_file)
|
|
|
|
|
2021-09-16 14:06:20 +02:00
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-init
|
|
|
|
-virtualizationservice
|
|
|
|
} virtualizationservice_prop:property_service set;
|
2022-08-31 17:09:44 +02:00
|
|
|
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-init
|
2022-12-15 14:38:42 +01:00
|
|
|
-virtualizationmanager
|
2022-08-31 17:09:44 +02:00
|
|
|
-virtualizationservice
|
|
|
|
} virtualizationservice_data_file:file { open create };
|
2022-12-15 14:38:42 +01:00
|
|
|
|
|
|
|
neverallow virtualizationservice {
|
|
|
|
domain
|
|
|
|
-virtualizationmanager
|
|
|
|
-virtualizationservice
|
2024-04-02 07:50:14 +02:00
|
|
|
# TODO(b/332677707): remove them when display service uses binder RPC.
|
|
|
|
is_flag_enabled(RELEASE_AVF_SUPPORT_CUSTOM_VM_WITH_PARAVIRTUALIZED_DEVICES, `-crosvm')
|
2022-12-15 14:38:42 +01:00
|
|
|
}:process setrlimit;
|
2023-08-01 04:00:49 +02:00
|
|
|
|
2023-11-17 10:03:46 +01:00
|
|
|
is_flag_enabled(RELEASE_AVF_ENABLE_DEVICE_ASSIGNMENT, `
|
2024-01-03 01:32:18 +01:00
|
|
|
# Only virtualizationservice and virtualizationmanager can communicate to vfio_handler
|
|
|
|
neverallow { domain -virtualizationmanager -virtualizationservice -servicemanager } vfio_handler:binder call;
|
2023-11-17 10:03:46 +01:00
|
|
|
')
|