blob: 14662fa8a5a5b40cb0a57dbf1802ec9f58c6cd21 [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
Inseob Kim825056d2023-08-01 11:00:49 +090018# Let virtualizationservice find and communicate with vfio_handler.
19allow virtualizationservice vfio_handler_service:service_manager find;
20binder_call(virtualizationservice, vfio_handler)
21
David Brazdilccf91642023-01-12 21:10:33 +000022# Allow calling into the system server to find "permission_service".
23binder_call(virtualizationservice, system_server)
24allow virtualizationservice permission_service:service_manager find;
25
David Brazdil55d808c2022-12-15 13:38:42 +000026# Let virtualizationservice remove memlock rlimit of virtualizationmanager. This is necessary
27# to mlock VM memory and page tables.
David Brazdil88f98d92022-10-28 13:57:58 +010028allow virtualizationservice self:capability sys_resource;
David Brazdil55d808c2022-12-15 13:38:42 +000029allow virtualizationservice virtualizationmanager:process setrlimit;
David Brazdil88f98d92022-10-28 13:57:58 +010030
David Brazdil55d808c2022-12-15 13:38:42 +000031# Let virtualizationservice set the owner of a VM's temporary directory.
32allow virtualizationservice self:capability chown;
Andrew Walbran4b80a3f2021-05-21 13:21:43 +000033
David Brazdil55d808c2022-12-15 13:38:42 +000034# Let virtualizationservice create and delete temporary directories of VMs. To remove old
35# directories, it needs the permission to unlink the files created by virtualizationmanager.
Andrew Walbran4b80a3f2021-05-21 13:21:43 +000036allow virtualizationservice virtualizationservice_data_file:dir create_dir_perms;
David Brazdil55d808c2022-12-15 13:38:42 +000037allow virtualizationservice virtualizationservice_data_file:{ file sock_file } unlink;
Inseob Kimbbe514d2023-08-03 12:53:48 +090038allow virtualizationservice virtualizationservice_data_file:file write;
Keir Fraserad58b8d2022-07-11 14:27:40 +000039
Jiyong Park5e20d832021-07-12 21:11:33 +090040# Allow to use fd (e.g. /dev/pts/0) inherited from adbd so that we can redirect output from
41# crosvm to the console
42allow virtualizationservice adbd:fd use;
43allow virtualizationservice adbd:unix_stream_socket { read write };
Andrew Walbran9b2fa1b2021-07-01 15:58:26 +000044
David Brazdil55d808c2022-12-15 13:38:42 +000045# Let virtualizationservice to accept vsock connection from the guest VMs to singleton services
46# such as the guest tombstone server.
Jiyong Parkf4083712021-07-10 14:35:06 +090047allow virtualizationservice self:vsock_socket { create_socket_perms_no_ioctl listen accept };
Jiyong Parkb804de22021-09-16 21:06:20 +090048
49# Allow virtualizationservice to read/write its own sysprop. Only the process can do so.
50set_prop(virtualizationservice, virtualizationservice_prop)
Alan Stokes3fad86b2022-01-04 17:34:53 +000051
Alan Stokes8a881c12022-01-21 12:18:08 +000052# Allow writing stats to statsd
53unix_socket_send(virtualizationservice, statsdw, statsd)
54
Shikha Panwara9f1dc92022-03-24 09:05:59 +000055# Allow virtualization service to talk to tombstoned to push guest tombstones
56unix_socket_connect(virtualizationservice, tombstoned_crash, tombstoned)
57
58# Append to tombstone files passed as fds from tombstoned
59allow virtualizationservice tombstone_data_file:file { append getattr };
60allow virtualizationservice tombstoned:fd use;
61
Inseob Kim825056d2023-08-01 11:00:49 +090062# Allow virtualizationservice to check if VFIO is supported
63allow virtualizationservice vfio_device:chr_file getattr;
64allow virtualizationservice vfio_device:dir r_dir_perms;
65
Inseob Kimbbe514d2023-08-03 12:53:48 +090066# Allow virtualizationservice to access VM DTBO via a file created by virtualizationmanager.
67allow virtualizationservice virtualizationmanager:fd use;
Inseob Kim825056d2023-08-01 11:00:49 +090068
Jiyong Parkb804de22021-09-16 21:06:20 +090069neverallow {
70 domain
71 -init
72 -virtualizationservice
73} virtualizationservice_prop:property_service set;
Alan Stokes991087c2022-08-31 16:09:44 +010074
75neverallow {
76 domain
77 -init
David Brazdil55d808c2022-12-15 13:38:42 +000078 -virtualizationmanager
Alan Stokes991087c2022-08-31 16:09:44 +010079 -virtualizationservice
80} virtualizationservice_data_file:file { open create };
David Brazdil55d808c2022-12-15 13:38:42 +000081
82neverallow virtualizationservice {
83 domain
84 -virtualizationmanager
85 -virtualizationservice
86}:process setrlimit;
Inseob Kim825056d2023-08-01 11:00:49 +090087
88# Only virtualizationservice can communicate to vfio_handler
89neverallow { domain -virtualizationservice -servicemanager } vfio_handler:binder call;