blob: fd5cf363d4c97299d48ad73b9ce52eb47f4fcfec [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
Alan Stokes38131e72024-02-20 11:06:37 +000015# Register our services with ServiceManager.
Andrew Walbran4b80a3f2021-05-21 13:21:43 +000016add_service(virtualizationservice, virtualization_service)
Alan Stokes38131e72024-02-20 11:06:37 +000017is_flag_enabled(RELEASE_AVF_ENABLE_LLPVM_CHANGES, `
18 add_service(virtualizationservice, virtualization_maintenance_service)
19')
Andrew Walbran4b80a3f2021-05-21 13:21:43 +000020
Jeongik Chaf09f43c2024-04-02 14:50:14 +090021is_flag_enabled(RELEASE_AVF_SUPPORT_CUSTOM_VM_WITH_PARAVIRTUALIZED_DEVICES, `
Inseob Kim094e8e82023-11-17 18:03:46 +090022 # Let virtualizationservice find and communicate with vfio_handler.
23 allow virtualizationservice vfio_handler_service:service_manager find;
24 binder_call(virtualizationservice, vfio_handler)
25')
Inseob Kim825056d2023-08-01 11:00:49 +090026
Seungjae Yoof60a1e02024-05-20 14:15:22 +090027is_flag_enabled(RELEASE_AVF_ENABLE_NETWORK, `
28 # Let virtualizationservice find and communicate with vmnic.
29 allow virtualizationservice vmnic_service:service_manager find;
30 binder_call(virtualizationservice, vmnic)
31')
32
Alice Wange79bbf92023-11-14 07:38:18 +000033# Allow the virtualizationservice domain to serve a remotely provisioned component for
34# pVM remote attestation.
35hal_server_domain(virtualizationservice, hal_remotelyprovisionedcomponent_avf)
36
Alice Wang3d9ce1a2024-06-07 09:07:34 +000037# Allow the virtualizationservice to inspect whether remote attestation is supported
38# through the system property.
39get_prop(virtualizationservice, avf_virtualizationservice_prop)
40
David Brazdilccf91642023-01-12 21:10:33 +000041# Allow calling into the system server to find "permission_service".
42binder_call(virtualizationservice, system_server)
43allow virtualizationservice permission_service:service_manager find;
44
Alice Wang260daf52024-01-18 16:18:47 +000045# Allow virtualizationservice to retrieve the remotely provisioned keys from rkpd.
Alice Wangf7fc9f92024-05-15 14:33:36 +000046binder_call(virtualizationservice, remote_provisioning_service_server)
Alice Wang260daf52024-01-18 16:18:47 +000047allow virtualizationservice remote_provisioning_service:service_manager find;
48
David Drysdale3242c6a2024-02-16 18:05:32 +000049# Allow virtualizationservice to manage VM secrets via Secretkeeper.
50hal_client_domain(virtualizationservice, hal_secretkeeper)
51
David Brazdil55d808c2022-12-15 13:38:42 +000052# Let virtualizationservice remove memlock rlimit of virtualizationmanager. This is necessary
53# to mlock VM memory and page tables.
David Brazdil88f98d92022-10-28 13:57:58 +010054allow virtualizationservice self:capability sys_resource;
David Brazdil55d808c2022-12-15 13:38:42 +000055allow virtualizationservice virtualizationmanager:process setrlimit;
David Brazdil88f98d92022-10-28 13:57:58 +010056
Jeongik Chaf09f43c2024-04-02 14:50:14 +090057is_flag_enabled(RELEASE_AVF_SUPPORT_CUSTOM_VM_WITH_PARAVIRTUALIZED_DEVICES, `
58 # To provide display service to an app to get surface.
59 # TODO(b/332677707): remove them when display service uses binder RPC.
Jeongik Cha77a3ca62024-04-09 15:02:28 +090060 allow virtualizationservice vmlauncher_app:binder transfer;
Jeongik Chaf09f43c2024-04-02 14:50:14 +090061')
62
David Brazdil55d808c2022-12-15 13:38:42 +000063# Let virtualizationservice set the owner of a VM's temporary directory.
64allow virtualizationservice self:capability chown;
Andrew Walbran4b80a3f2021-05-21 13:21:43 +000065
David Brazdil55d808c2022-12-15 13:38:42 +000066# Let virtualizationservice create and delete temporary directories of VMs. To remove old
67# directories, it needs the permission to unlink the files created by virtualizationmanager.
Andrew Walbran4b80a3f2021-05-21 13:21:43 +000068allow virtualizationservice virtualizationservice_data_file:dir create_dir_perms;
Seungjae Yoof0aaa152023-09-07 15:37:40 +090069allow virtualizationservice virtualizationservice_data_file:sock_file unlink;
70allow virtualizationservice virtualizationservice_data_file:file create_file_perms;
Keir Fraserad58b8d2022-07-11 14:27:40 +000071
Jiyong Park5e20d832021-07-12 21:11:33 +090072# Allow to use fd (e.g. /dev/pts/0) inherited from adbd so that we can redirect output from
73# crosvm to the console
74allow virtualizationservice adbd:fd use;
75allow virtualizationservice adbd:unix_stream_socket { read write };
Andrew Walbran9b2fa1b2021-07-01 15:58:26 +000076
Alice Wang40519f72023-08-31 11:37:30 +000077# Allow to connnect to and run VirtMgr to start the service VM for remote attestation.
78virtualizationservice_use(virtualizationservice)
79
80# Allow virtualizationservice to read and write in the apex data directory
David Drysdalea9d70d72024-02-19 17:44:08 +000081# /data/misc/apexdata/com.android.virt. Also allow checking of the parent directory
82# (needed for SQLite database creation).
83allow virtualizationservice apex_module_data_file:dir { search getattr };
Alice Wang40519f72023-08-31 11:37:30 +000084allow virtualizationservice apex_virt_data_file:dir create_dir_perms;
85allow virtualizationservice apex_virt_data_file:file create_file_perms;
86
Alan Stokes88207c42024-06-18 17:06:36 +010087# Accept vsock connection from the guest VMs to singleton services
David Brazdil55d808c2022-12-15 13:38:42 +000088# such as the guest tombstone server.
Alan Stokes88207c42024-06-18 17:06:36 +010089allow virtualizationservice self:vsock_socket { create read getattr write setattr lock append bind getopt setopt shutdown map listen accept };
90neverallow { domain -virtualizationservice -dumpstate } virtualizationservice:vsock_socket *;
Jiyong Parkb804de22021-09-16 21:06:20 +090091
92# Allow virtualizationservice to read/write its own sysprop. Only the process can do so.
93set_prop(virtualizationservice, virtualizationservice_prop)
Alan Stokes3fad86b2022-01-04 17:34:53 +000094
Alan Stokes8a881c12022-01-21 12:18:08 +000095# Allow writing stats to statsd
96unix_socket_send(virtualizationservice, statsdw, statsd)
97
Shikha Panwara9f1dc92022-03-24 09:05:59 +000098# Allow virtualization service to talk to tombstoned to push guest tombstones
99unix_socket_connect(virtualizationservice, tombstoned_crash, tombstoned)
100
101# Append to tombstone files passed as fds from tombstoned
102allow virtualizationservice tombstone_data_file:file { append getattr };
103allow virtualizationservice tombstoned:fd use;
104
Inseob Kim825056d2023-08-01 11:00:49 +0900105# Allow virtualizationservice to check if VFIO is supported
106allow virtualizationservice vfio_device:chr_file getattr;
107allow virtualizationservice vfio_device:dir r_dir_perms;
108
Inseob Kimbbe514d2023-08-03 12:53:48 +0900109# Allow virtualizationservice to access VM DTBO via a file created by virtualizationmanager.
110allow virtualizationservice virtualizationmanager:fd use;
Inseob Kim825056d2023-08-01 11:00:49 +0900111
Inseob Kimd61618b2023-08-30 14:04:24 +0900112# Allow virtualizationservice to access vendor_configs_file to get the list of assignable devices.
113r_dir_file(virtualizationservice, vendor_configs_file)
114
Jiyong Parkb804de22021-09-16 21:06:20 +0900115neverallow {
116 domain
117 -init
118 -virtualizationservice
119} virtualizationservice_prop:property_service set;
Alan Stokes991087c2022-08-31 16:09:44 +0100120
121neverallow {
122 domain
123 -init
David Brazdil55d808c2022-12-15 13:38:42 +0000124 -virtualizationmanager
Alan Stokes991087c2022-08-31 16:09:44 +0100125 -virtualizationservice
126} virtualizationservice_data_file:file { open create };
David Brazdil55d808c2022-12-15 13:38:42 +0000127
128neverallow virtualizationservice {
129 domain
130 -virtualizationmanager
131 -virtualizationservice
Jeongik Chaf09f43c2024-04-02 14:50:14 +0900132 # TODO(b/332677707): remove them when display service uses binder RPC.
133 is_flag_enabled(RELEASE_AVF_SUPPORT_CUSTOM_VM_WITH_PARAVIRTUALIZED_DEVICES, `-crosvm')
David Brazdil55d808c2022-12-15 13:38:42 +0000134}:process setrlimit;
Inseob Kim825056d2023-08-01 11:00:49 +0900135
Seungjae Yoo80fd6182024-05-20 16:59:02 +0900136is_flag_enabled(RELEASE_AVF_ENABLE_NETWORK, `
137 # Allow virtualizationservice to deal with file descriptors of TAP interfaces.
138 allow virtualizationservice tun_device:chr_file rw_file_perms;
139 allow virtualizationservice vmnic:fd use;
140')
141
Inseob Kim094e8e82023-11-17 18:03:46 +0900142is_flag_enabled(RELEASE_AVF_ENABLE_DEVICE_ASSIGNMENT, `
Inseob Kimfb0ed7f2024-01-03 09:32:18 +0900143 # Only virtualizationservice and virtualizationmanager can communicate to vfio_handler
144 neverallow { domain -virtualizationmanager -virtualizationservice -servicemanager } vfio_handler:binder call;
Inseob Kim094e8e82023-11-17 18:03:46 +0900145')