2021-03-29 19:19:12 +02:00
|
|
|
type crosvm, domain, coredomain;
|
|
|
|
type crosvm_exec, system_file_type, exec_type, file_type;
|
|
|
|
type crosvm_tmpfs, file_type;
|
|
|
|
|
2021-07-12 14:11:33 +02:00
|
|
|
# Let crosvm open /dev/kvm.
|
|
|
|
allow crosvm kvm_device:chr_file rw_file_perms;
|
|
|
|
|
|
|
|
# Most other domains shouldn't access /dev/kvm.
|
|
|
|
neverallow { domain -crosvm -ueventd -shell } kvm_device:chr_file getattr;
|
2022-01-28 16:42:48 +01:00
|
|
|
neverallow { domain -crosvm -ueventd } kvm_device:chr_file ~getattr;
|
2021-12-28 13:26:03 +01:00
|
|
|
neverallowxperm { domain -crosvm } kvm_device:chr_file ioctl ~{ KVM_CHECK_EXTENSION };
|
2021-07-12 14:11:33 +02:00
|
|
|
|
2022-01-14 14:47:05 +01:00
|
|
|
# Let crosvm mlock VM memory and page tables.
|
|
|
|
allow crosvm self:capability ipc_lock;
|
|
|
|
|
2021-03-29 19:19:12 +02:00
|
|
|
# Let crosvm create temporary files.
|
|
|
|
tmpfs_domain(crosvm)
|
|
|
|
|
2021-05-21 15:21:43 +02:00
|
|
|
# Let crosvm receive file descriptors from VirtualizationService.
|
|
|
|
allow crosvm virtualizationservice:fd use;
|
2021-03-29 19:19:12 +02:00
|
|
|
|
2022-03-09 15:05:18 +01:00
|
|
|
# Allow sending VirtualizationService the failure reason from the VM via pipe.
|
|
|
|
allow crosvm virtualizationservice:fifo_file write;
|
|
|
|
|
2021-07-12 14:11:33 +02:00
|
|
|
# Let crosvm read the composite disk images (virtualizationservice_data_file), APEXes
|
|
|
|
# (staging_data_file), APKs (apk_data_file and shell_data_file where the latter is for test apks in
|
|
|
|
# /data/local/tmp), and instance.img (app_data_file). Note that the open permission is not given as
|
|
|
|
# the files are passed as file descriptors.
|
|
|
|
allow crosvm {
|
|
|
|
virtualizationservice_data_file
|
|
|
|
staging_data_file
|
|
|
|
apk_data_file
|
|
|
|
app_data_file
|
2021-07-28 15:05:25 +02:00
|
|
|
apex_compos_data_file
|
2021-07-12 14:11:33 +02:00
|
|
|
userdebug_or_eng(`shell_data_file')
|
|
|
|
}:file { getattr read ioctl lock };
|
2021-03-29 19:19:12 +02:00
|
|
|
|
2021-07-12 14:11:33 +02:00
|
|
|
# Allow searching the directory where the composite disk images are.
|
|
|
|
allow crosvm virtualizationservice_data_file:dir search;
|
|
|
|
|
|
|
|
# Don't allow crosvm to open files that it doesn't own.
|
2021-12-24 14:10:25 +01:00
|
|
|
# This is important because a malicious application could try to start a VM with a composite disk
|
|
|
|
# image referring by name to files which it doesn't have permission to open, trying to get crosvm to
|
|
|
|
# open them on its behalf. By preventing crosvm from opening any other files we prevent this
|
|
|
|
# potential privilege escalation. See http://b/192453819 for more discussion.
|
2021-07-12 14:11:33 +02:00
|
|
|
neverallow crosvm {
|
2021-08-05 16:09:52 +02:00
|
|
|
virtualizationservice_data_file
|
2021-07-12 14:11:33 +02:00
|
|
|
staging_data_file
|
|
|
|
apk_data_file
|
|
|
|
app_data_file
|
|
|
|
userdebug_or_eng(`-shell_data_file')
|
|
|
|
}:file open;
|
|
|
|
|
|
|
|
# The instance image and the composite image should be writable as well because they could represent
|
|
|
|
# mutable disks.
|
|
|
|
allow crosvm {
|
|
|
|
virtualizationservice_data_file
|
|
|
|
app_data_file
|
2021-07-28 15:05:25 +02:00
|
|
|
apex_compos_data_file
|
2021-07-12 14:11:33 +02:00
|
|
|
}:file write;
|
|
|
|
|
|
|
|
# Allow crosvm to pipe console log to shell or app which could be the owner of a VM.
|
2021-09-02 12:10:59 +02:00
|
|
|
allow crosvm adbd:fd use;
|
2021-07-12 14:11:33 +02:00
|
|
|
allow crosvm adbd:unix_stream_socket { read write };
|
2021-07-01 17:58:26 +02:00
|
|
|
|
2022-04-04 22:20:24 +02:00
|
|
|
# For ACPI
|
|
|
|
allow crosvm self:netlink_generic_socket create_socket_perms_no_ioctl;
|
|
|
|
|
2021-07-12 14:11:33 +02:00
|
|
|
# The console log can also be written to /data/local/tmp. This is not safe as the log then can be
|
|
|
|
# visible to the processes which don't own the VM. Therefore, this is a debugging only feature.
|
|
|
|
userdebug_or_eng(`allow crosvm shell_data_file:file w_file_perms;')
|
2021-08-09 02:24:45 +02:00
|
|
|
|
|
|
|
# Don't allow crosvm to have access to ordinary vendor files that are not for VMs.
|
|
|
|
full_treble_only(`
|
|
|
|
neverallow crosvm {
|
|
|
|
vendor_file_type
|
|
|
|
-vendor_vm_file
|
|
|
|
-vendor_vm_data_file
|
|
|
|
# These types are not required for crosvm, but the access is granted to globally in domain.te
|
|
|
|
# thus should be exempted here.
|
|
|
|
-vendor_configs_file
|
|
|
|
-vndk_sp_file
|
|
|
|
-vendor_task_profiles_file
|
|
|
|
}:file *;
|
|
|
|
')
|
2021-11-25 16:59:07 +01:00
|
|
|
|
|
|
|
# app_data_file (and shell_data_file for debuggable builds) is the only
|
|
|
|
# app_data_file_type that is allowed for crosvm to read. Note that the use of
|
2021-12-24 14:10:25 +01:00
|
|
|
# app_data_file is allowed only for the instance disk image. This is enforced
|
2021-11-25 16:59:07 +01:00
|
|
|
# inside the virtualizationservice by checking the file context of all disk
|
|
|
|
# image files.
|
|
|
|
neverallow crosvm {
|
|
|
|
app_data_file_type
|
|
|
|
-app_data_file
|
|
|
|
userdebug_or_eng(`-shell_data_file')
|
|
|
|
}:file read;
|
2022-02-03 07:30:26 +01:00
|
|
|
|
|
|
|
# Only virtualizationservice can run crosvm
|
|
|
|
neverallow {
|
|
|
|
domain
|
|
|
|
-crosvm
|
|
|
|
-virtualizationservice
|
|
|
|
} crosvm_exec:file no_x_file_perms;
|