blob: f41e7ccf7ccdadabebdba514732b875a3218d0f4 [file] [log] [blame]
Andrew Walbran4b80a3f2021-05-21 13:21:43 +00001type virtualizationservice, domain, coredomain;
2type virtualizationservice_exec, system_file_type, exec_type, file_type;
3
4# When init runs a file labelled with virtualizationservice_exec, run it in the
5# virtualizationservice domain.
6init_daemon_domain(virtualizationservice)
7
8# Let the virtualizationservice domain use Binder.
9binder_use(virtualizationservice)
Jiyong Park5e20d832021-07-12 21:11:33 +090010# ... and host a binder service
11binder_service(virtualizationservice)
Jiyong Park5e20d832021-07-12 21:11:33 +090012
13# Allow calling into the system server so that it can check permissions.
14binder_call(virtualizationservice, system_server)
15allow virtualizationservice permission_service:service_manager find;
Jooyung Han970166f2021-10-05 17:22:45 +090016# Allow virtualizationservice to access "package_native" service for staged apex info.
17allow virtualizationservice package_native_service:service_manager find;
Andrew Walbran4b80a3f2021-05-21 13:21:43 +000018
19# Let the virtualizationservice domain register the virtualization_service with ServiceManager.
20add_service(virtualizationservice, virtualization_service)
21
22# When virtualizationservice execs a file with the crosvm_exec label, run it in the crosvm domain.
23domain_auto_trans(virtualizationservice, crosvm_exec, crosvm)
24
David Brazdil88f98d92022-10-28 13:57:58 +010025# Let virtualizationservice (and specifically its children) mlock VM memory and page tables.
26allow virtualizationservice self:capability sys_resource;
27
Andrew Walbran4b80a3f2021-05-21 13:21:43 +000028# Let virtualizationservice kill crosvm.
29allow virtualizationservice crosvm:process sigkill;
30
31# Let virtualizationservice access its data directory.
32allow virtualizationservice virtualizationservice_data_file:file create_file_perms;
33allow virtualizationservice virtualizationservice_data_file:dir create_dir_perms;
Andrew Walbran9b2fa1b2021-07-01 15:58:26 +000034
Keir Fraserad58b8d2022-07-11 14:27:40 +000035# Let virtualizationservice manage crosvm control sockets.
36allow virtualizationservice virtualizationservice_data_file:sock_file create_file_perms;
37
Jiyong Park5e20d832021-07-12 21:11:33 +090038# Allow to use fd (e.g. /dev/pts/0) inherited from adbd so that we can redirect output from
39# crosvm to the console
40allow virtualizationservice adbd:fd use;
41allow virtualizationservice adbd:unix_stream_socket { read write };
Andrew Walbran9b2fa1b2021-07-01 15:58:26 +000042
43# Let virtualizationservice read and write files from its various clients, but not open them
44# directly as they must be passed over Binder by the client.
45allow virtualizationservice apk_data_file:file { getattr read };
Jiyong Park5e20d832021-07-12 21:11:33 +090046# Write access is needed for mutable partitions like instance.img
Alan Stokese2a002c2021-07-28 14:05:25 +010047allow virtualizationservice {
48 app_data_file
49 apex_compos_data_file
Alan Stokes30608522022-10-24 12:32:34 +010050 privapp_data_file
Alan Stokese2a002c2021-07-28 14:05:25 +010051}:file { getattr read write };
52
Andrew Walbran9b2fa1b2021-07-01 15:58:26 +000053# shell_data_file is used for automated tests and manual debugging.
54allow virtualizationservice shell_data_file:file { getattr read write };
Jiyong Parkf4083712021-07-10 14:35:06 +090055
Jiyong Park5e20d832021-07-12 21:11:33 +090056# Allow virtualizationservice to read apex-info-list.xml and access the APEX files listed there.
57allow virtualizationservice apex_info_file:file r_file_perms;
Jooyung Han6d4179a2021-07-16 13:05:40 +090058allow virtualizationservice apex_data_file:dir search;
59allow virtualizationservice staging_data_file:file r_file_perms;
Jooyung Han970166f2021-10-05 17:22:45 +090060allow virtualizationservice staging_data_file:dir search;
Jooyung Han6d4179a2021-07-16 13:05:40 +090061
Alan Stokes3fad86b2022-01-04 17:34:53 +000062# Run derive_classpath in our domain
63allow virtualizationservice derive_classpath_exec:file rx_file_perms;
64allow virtualizationservice apex_mnt_dir:dir r_dir_perms;
Alan Stokes8a881c12022-01-21 12:18:08 +000065# Ignore harmless denials on /proc/self/fd
66dontaudit virtualizationservice self:dir write;
Alan Stokes3fad86b2022-01-04 17:34:53 +000067
Jiyong Parkf4083712021-07-10 14:35:06 +090068# Let virtualizationservice to accept vsock connection from the guest VMs
69allow virtualizationservice self:vsock_socket { create_socket_perms_no_ioctl listen accept };
Jiyong Parkb804de22021-09-16 21:06:20 +090070
71# Allow virtualizationservice to read/write its own sysprop. Only the process can do so.
72set_prop(virtualizationservice, virtualizationservice_prop)
Alan Stokes3fad86b2022-01-04 17:34:53 +000073
Andrew Scull792b03d2022-02-01 18:41:31 +000074# Allow virtualizationservice to inspect hypervisor capabilities.
75get_prop(virtualizationservice, hypervisor_prop)
76
Alan Stokes8a881c12022-01-21 12:18:08 +000077# Allow writing stats to statsd
78unix_socket_send(virtualizationservice, statsdw, statsd)
79
Shikha Panwara9f1dc92022-03-24 09:05:59 +000080# Allow virtualization service to talk to tombstoned to push guest tombstones
81unix_socket_connect(virtualizationservice, tombstoned_crash, tombstoned)
82
83# Append to tombstone files passed as fds from tombstoned
84allow virtualizationservice tombstone_data_file:file { append getattr };
85allow virtualizationservice tombstoned:fd use;
86
Jiyong Parkb804de22021-09-16 21:06:20 +090087neverallow {
88 domain
89 -init
90 -virtualizationservice
91} virtualizationservice_prop:property_service set;
Alan Stokes991087c2022-08-31 16:09:44 +010092
93neverallow {
94 domain
95 -init
96 -virtualizationservice
97} virtualizationservice_data_file:file { open create };