blob: 28982bc1d23a0abf317adc640f93284859a53d5f [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
David Brazdil55d808c2022-12-15 13:38:42 +00004# The domain needs to be a 'mlstrustedsubject' to change the memlock rlimit of
5# the virtualizationmanager domain running at a more constrained MLS level.
6typeattribute virtualizationservice mlstrustedsubject;
7
Andrew Walbran4b80a3f2021-05-21 13:21:43 +00008# When init runs a file labelled with virtualizationservice_exec, run it in the
9# virtualizationservice domain.
10init_daemon_domain(virtualizationservice)
11
12# Let the virtualizationservice domain use Binder.
13binder_use(virtualizationservice)
14
15# Let the virtualizationservice domain register the virtualization_service with ServiceManager.
16add_service(virtualizationservice, virtualization_service)
17
David Brazdil55d808c2022-12-15 13:38:42 +000018# Let virtualizationservice remove memlock rlimit of virtualizationmanager. This is necessary
19# to mlock VM memory and page tables.
David Brazdil88f98d92022-10-28 13:57:58 +010020allow virtualizationservice self:capability sys_resource;
David Brazdil55d808c2022-12-15 13:38:42 +000021allow virtualizationservice virtualizationmanager:process setrlimit;
David Brazdil88f98d92022-10-28 13:57:58 +010022
David Brazdil55d808c2022-12-15 13:38:42 +000023# Let virtualizationservice set the owner of a VM's temporary directory.
24allow virtualizationservice self:capability chown;
Andrew Walbran4b80a3f2021-05-21 13:21:43 +000025
David Brazdil55d808c2022-12-15 13:38:42 +000026# Let virtualizationservice create and delete temporary directories of VMs. To remove old
27# directories, it needs the permission to unlink the files created by virtualizationmanager.
Andrew Walbran4b80a3f2021-05-21 13:21:43 +000028allow virtualizationservice virtualizationservice_data_file:dir create_dir_perms;
David Brazdil55d808c2022-12-15 13:38:42 +000029allow virtualizationservice virtualizationservice_data_file:{ file sock_file } unlink;
Keir Fraserad58b8d2022-07-11 14:27:40 +000030
Jiyong Park5e20d832021-07-12 21:11:33 +090031# Allow to use fd (e.g. /dev/pts/0) inherited from adbd so that we can redirect output from
32# crosvm to the console
33allow virtualizationservice adbd:fd use;
34allow virtualizationservice adbd:unix_stream_socket { read write };
Andrew Walbran9b2fa1b2021-07-01 15:58:26 +000035
David Brazdil55d808c2022-12-15 13:38:42 +000036# Let virtualizationservice to accept vsock connection from the guest VMs to singleton services
37# such as the guest tombstone server.
Jiyong Parkf4083712021-07-10 14:35:06 +090038allow virtualizationservice self:vsock_socket { create_socket_perms_no_ioctl listen accept };
Jiyong Parkb804de22021-09-16 21:06:20 +090039
40# Allow virtualizationservice to read/write its own sysprop. Only the process can do so.
41set_prop(virtualizationservice, virtualizationservice_prop)
Alan Stokes3fad86b2022-01-04 17:34:53 +000042
Alan Stokes8a881c12022-01-21 12:18:08 +000043# Allow writing stats to statsd
44unix_socket_send(virtualizationservice, statsdw, statsd)
45
Shikha Panwara9f1dc92022-03-24 09:05:59 +000046# Allow virtualization service to talk to tombstoned to push guest tombstones
47unix_socket_connect(virtualizationservice, tombstoned_crash, tombstoned)
48
49# Append to tombstone files passed as fds from tombstoned
50allow virtualizationservice tombstone_data_file:file { append getattr };
51allow virtualizationservice tombstoned:fd use;
52
Jiyong Parkb804de22021-09-16 21:06:20 +090053neverallow {
54 domain
55 -init
56 -virtualizationservice
57} virtualizationservice_prop:property_service set;
Alan Stokes991087c2022-08-31 16:09:44 +010058
59neverallow {
60 domain
61 -init
David Brazdil55d808c2022-12-15 13:38:42 +000062 -virtualizationmanager
Alan Stokes991087c2022-08-31 16:09:44 +010063 -virtualizationservice
64} virtualizationservice_data_file:file { open create };
David Brazdil55d808c2022-12-15 13:38:42 +000065
66neverallow virtualizationservice {
67 domain
68 -virtualizationmanager
69 -virtualizationservice
70}:process setrlimit;