blob: 42e51811e86695edaaa2d792031b6bbf60a4d851 [file] [log] [blame]
Andrew Walbrana995e842021-03-29 17:19:12 +00001type crosvm, domain, coredomain;
2type crosvm_exec, system_file_type, exec_type, file_type;
3type crosvm_tmpfs, file_type;
4
Andrew Walbrana995e842021-03-29 17:19:12 +00005# Let crosvm open /dev/kvm.
6allow crosvm kvm_device:chr_file rw_file_perms;
7
8# Most other domains shouldn't access /dev/kvm.
9neverallow { domain -crosvm -ueventd -shell } kvm_device:chr_file getattr;
10neverallow { domain -crosvm -ueventd } kvm_device:chr_file ~getattr;
Andrew Walbran9b2fa1b2021-07-01 15:58:26 +000011
Jiyong Park5e20d832021-07-12 21:11:33 +090012# Let crosvm create temporary files.
13tmpfs_domain(crosvm)
14
15# Let crosvm receive file descriptors from VirtualizationService.
16allow crosvm virtualizationservice:fd use;
17
18# Let crosvm read the composite disk images (virtualizationservice_data_file), APEXes
19# (staging_data_file), APKs (apk_data_file and shell_data_file where the latter is for test apks in
20# /data/local/tmp), and instance.img (app_data_file). Note that the open permission is not given as
21# the files are passed as file descriptors.
22allow crosvm {
23 virtualizationservice_data_file
24 staging_data_file
25 apk_data_file
26 app_data_file
27 userdebug_or_eng(`shell_data_file')
28}:file { getattr read ioctl lock };
29
30# Allow searching the directory where the composite disk images are.
31allow crosvm virtualizationservice_data_file:dir search;
32
33# TODO(b/193402941) delete this. This for now is required because crosvm needs to open the files for
34# the GPT headers of the composite disks.
35allow crosvm virtualizationservice_data_file:file open;
36
37# Don't allow crosvm to open files that it doesn't own.
38neverallow crosvm {
39 #TODO(b/193402941) uncomment the following line
40 #virtualizationservice_data_file
41 staging_data_file
42 apk_data_file
43 app_data_file
44 userdebug_or_eng(`-shell_data_file')
45}:file open;
46
47# The instance image and the composite image should be writable as well because they could represent
48# mutable disks.
49allow crosvm {
50 virtualizationservice_data_file
51 app_data_file
52}:file write;
53
54# Allow crosvm to pipe console log to shell or app which could be the owner of a VM.
55allow crosvm { adbd appdomain }:fd use;
56allow crosvm adbd:unix_stream_socket { read write };
57allow crosvm appdomain:fifo_file { read write };
58
59# The console log can also be written to /data/local/tmp. This is not safe as the log then can be
60# visible to the processes which don't own the VM. Therefore, this is a debugging only feature.
61userdebug_or_eng(`allow crosvm shell_data_file:file w_file_perms;')