blob: 972f3762fbd892677a93d88be6eff89c2fc17109 [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 Kim094e8e82023-11-17 18:03:46 +090018is_flag_enabled(RELEASE_AVF_ENABLE_DEVICE_ASSIGNMENT, `
19 # Let virtualizationservice find and communicate with vfio_handler.
20 allow virtualizationservice vfio_handler_service:service_manager find;
21 binder_call(virtualizationservice, vfio_handler)
22')
Inseob Kim825056d2023-08-01 11:00:49 +090023
Alice Wange79bbf92023-11-14 07:38:18 +000024# Allow the virtualizationservice domain to serve a remotely provisioned component for
25# pVM remote attestation.
26hal_server_domain(virtualizationservice, hal_remotelyprovisionedcomponent_avf)
27
David Brazdilccf91642023-01-12 21:10:33 +000028# Allow calling into the system server to find "permission_service".
29binder_call(virtualizationservice, system_server)
30allow virtualizationservice permission_service:service_manager find;
31
Alice Wang260daf52024-01-18 16:18:47 +000032# Allow virtualizationservice to retrieve the remotely provisioned keys from rkpd.
33binder_call(virtualizationservice, remote_provisioning_service)
34allow virtualizationservice remote_provisioning_service:service_manager find;
35
David Brazdil55d808c2022-12-15 13:38:42 +000036# Let virtualizationservice remove memlock rlimit of virtualizationmanager. This is necessary
37# to mlock VM memory and page tables.
David Brazdil88f98d92022-10-28 13:57:58 +010038allow virtualizationservice self:capability sys_resource;
David Brazdil55d808c2022-12-15 13:38:42 +000039allow virtualizationservice virtualizationmanager:process setrlimit;
David Brazdil88f98d92022-10-28 13:57:58 +010040
David Brazdil55d808c2022-12-15 13:38:42 +000041# Let virtualizationservice set the owner of a VM's temporary directory.
42allow virtualizationservice self:capability chown;
Andrew Walbran4b80a3f2021-05-21 13:21:43 +000043
David Brazdil55d808c2022-12-15 13:38:42 +000044# Let virtualizationservice create and delete temporary directories of VMs. To remove old
45# directories, it needs the permission to unlink the files created by virtualizationmanager.
Andrew Walbran4b80a3f2021-05-21 13:21:43 +000046allow virtualizationservice virtualizationservice_data_file:dir create_dir_perms;
Seungjae Yoof0aaa152023-09-07 15:37:40 +090047allow virtualizationservice virtualizationservice_data_file:sock_file unlink;
48allow virtualizationservice virtualizationservice_data_file:file create_file_perms;
Keir Fraserad58b8d2022-07-11 14:27:40 +000049
Jiyong Park5e20d832021-07-12 21:11:33 +090050# Allow to use fd (e.g. /dev/pts/0) inherited from adbd so that we can redirect output from
51# crosvm to the console
52allow virtualizationservice adbd:fd use;
53allow virtualizationservice adbd:unix_stream_socket { read write };
Andrew Walbran9b2fa1b2021-07-01 15:58:26 +000054
Alice Wang40519f72023-08-31 11:37:30 +000055# Allow to connnect to and run VirtMgr to start the service VM for remote attestation.
56virtualizationservice_use(virtualizationservice)
57
58# Allow virtualizationservice to read and write in the apex data directory
59# /data/misc/apexdata/com.android.virt
60allow virtualizationservice apex_module_data_file:dir search;
61allow virtualizationservice apex_virt_data_file:dir create_dir_perms;
62allow virtualizationservice apex_virt_data_file:file create_file_perms;
63
David Brazdil55d808c2022-12-15 13:38:42 +000064# Let virtualizationservice to accept vsock connection from the guest VMs to singleton services
65# such as the guest tombstone server.
Jiyong Parkf4083712021-07-10 14:35:06 +090066allow virtualizationservice self:vsock_socket { create_socket_perms_no_ioctl listen accept };
Jiyong Parkb804de22021-09-16 21:06:20 +090067
68# Allow virtualizationservice to read/write its own sysprop. Only the process can do so.
69set_prop(virtualizationservice, virtualizationservice_prop)
Alan Stokes3fad86b2022-01-04 17:34:53 +000070
Alan Stokes8a881c12022-01-21 12:18:08 +000071# Allow writing stats to statsd
72unix_socket_send(virtualizationservice, statsdw, statsd)
73
Shikha Panwara9f1dc92022-03-24 09:05:59 +000074# Allow virtualization service to talk to tombstoned to push guest tombstones
75unix_socket_connect(virtualizationservice, tombstoned_crash, tombstoned)
76
77# Append to tombstone files passed as fds from tombstoned
78allow virtualizationservice tombstone_data_file:file { append getattr };
79allow virtualizationservice tombstoned:fd use;
80
Inseob Kim825056d2023-08-01 11:00:49 +090081# Allow virtualizationservice to check if VFIO is supported
82allow virtualizationservice vfio_device:chr_file getattr;
83allow virtualizationservice vfio_device:dir r_dir_perms;
84
Inseob Kimbbe514d2023-08-03 12:53:48 +090085# Allow virtualizationservice to access VM DTBO via a file created by virtualizationmanager.
86allow virtualizationservice virtualizationmanager:fd use;
Inseob Kim825056d2023-08-01 11:00:49 +090087
Inseob Kimd61618b2023-08-30 14:04:24 +090088# Allow virtualizationservice to access vendor_configs_file to get the list of assignable devices.
89r_dir_file(virtualizationservice, vendor_configs_file)
90
Jiyong Parkb804de22021-09-16 21:06:20 +090091neverallow {
92 domain
93 -init
94 -virtualizationservice
95} virtualizationservice_prop:property_service set;
Alan Stokes991087c2022-08-31 16:09:44 +010096
97neverallow {
98 domain
99 -init
David Brazdil55d808c2022-12-15 13:38:42 +0000100 -virtualizationmanager
Alan Stokes991087c2022-08-31 16:09:44 +0100101 -virtualizationservice
102} virtualizationservice_data_file:file { open create };
David Brazdil55d808c2022-12-15 13:38:42 +0000103
104neverallow virtualizationservice {
105 domain
106 -virtualizationmanager
107 -virtualizationservice
108}:process setrlimit;
Inseob Kim825056d2023-08-01 11:00:49 +0900109
Inseob Kim094e8e82023-11-17 18:03:46 +0900110is_flag_enabled(RELEASE_AVF_ENABLE_DEVICE_ASSIGNMENT, `
Inseob Kimfb0ed7f2024-01-03 09:32:18 +0900111 # Only virtualizationservice and virtualizationmanager can communicate to vfio_handler
112 neverallow { domain -virtualizationmanager -virtualizationservice -servicemanager } vfio_handler:binder call;
Inseob Kim094e8e82023-11-17 18:03:46 +0900113')