Andrew Walbran | 4b80a3f | 2021-05-21 13:21:43 +0000 | [diff] [blame] | 1 | type virtualizationservice, domain, coredomain; |
| 2 | type virtualizationservice_exec, system_file_type, exec_type, file_type; |
| 3 | |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 4 | # The domain needs to be a 'mlstrustedsubject' to change the memlock rlimit of |
| 5 | # the virtualizationmanager domain running at a more constrained MLS level. |
| 6 | typeattribute virtualizationservice mlstrustedsubject; |
| 7 | |
Andrew Walbran | 4b80a3f | 2021-05-21 13:21:43 +0000 | [diff] [blame] | 8 | # When init runs a file labelled with virtualizationservice_exec, run it in the |
| 9 | # virtualizationservice domain. |
| 10 | init_daemon_domain(virtualizationservice) |
| 11 | |
| 12 | # Let the virtualizationservice domain use Binder. |
| 13 | binder_use(virtualizationservice) |
| 14 | |
| 15 | # Let the virtualizationservice domain register the virtualization_service with ServiceManager. |
| 16 | add_service(virtualizationservice, virtualization_service) |
| 17 | |
Inseob Kim | 825056d | 2023-08-01 11:00:49 +0900 | [diff] [blame] | 18 | # Let virtualizationservice find and communicate with vfio_handler. |
| 19 | allow virtualizationservice vfio_handler_service:service_manager find; |
| 20 | binder_call(virtualizationservice, vfio_handler) |
| 21 | |
David Brazdil | ccf9164 | 2023-01-12 21:10:33 +0000 | [diff] [blame] | 22 | # Allow calling into the system server to find "permission_service". |
| 23 | binder_call(virtualizationservice, system_server) |
| 24 | allow virtualizationservice permission_service:service_manager find; |
| 25 | |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 26 | # Let virtualizationservice remove memlock rlimit of virtualizationmanager. This is necessary |
| 27 | # to mlock VM memory and page tables. |
David Brazdil | 88f98d9 | 2022-10-28 13:57:58 +0100 | [diff] [blame] | 28 | allow virtualizationservice self:capability sys_resource; |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 29 | allow virtualizationservice virtualizationmanager:process setrlimit; |
David Brazdil | 88f98d9 | 2022-10-28 13:57:58 +0100 | [diff] [blame] | 30 | |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 31 | # Let virtualizationservice set the owner of a VM's temporary directory. |
| 32 | allow virtualizationservice self:capability chown; |
Andrew Walbran | 4b80a3f | 2021-05-21 13:21:43 +0000 | [diff] [blame] | 33 | |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 34 | # 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 Walbran | 4b80a3f | 2021-05-21 13:21:43 +0000 | [diff] [blame] | 36 | allow virtualizationservice virtualizationservice_data_file:dir create_dir_perms; |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 37 | allow virtualizationservice virtualizationservice_data_file:{ file sock_file } unlink; |
Inseob Kim | bbe514d | 2023-08-03 12:53:48 +0900 | [diff] [blame^] | 38 | allow virtualizationservice virtualizationservice_data_file:file write; |
Keir Fraser | ad58b8d | 2022-07-11 14:27:40 +0000 | [diff] [blame] | 39 | |
Jiyong Park | 5e20d83 | 2021-07-12 21:11:33 +0900 | [diff] [blame] | 40 | # Allow to use fd (e.g. /dev/pts/0) inherited from adbd so that we can redirect output from |
| 41 | # crosvm to the console |
| 42 | allow virtualizationservice adbd:fd use; |
| 43 | allow virtualizationservice adbd:unix_stream_socket { read write }; |
Andrew Walbran | 9b2fa1b | 2021-07-01 15:58:26 +0000 | [diff] [blame] | 44 | |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 45 | # Let virtualizationservice to accept vsock connection from the guest VMs to singleton services |
| 46 | # such as the guest tombstone server. |
Jiyong Park | f408371 | 2021-07-10 14:35:06 +0900 | [diff] [blame] | 47 | allow virtualizationservice self:vsock_socket { create_socket_perms_no_ioctl listen accept }; |
Jiyong Park | b804de2 | 2021-09-16 21:06:20 +0900 | [diff] [blame] | 48 | |
| 49 | # Allow virtualizationservice to read/write its own sysprop. Only the process can do so. |
| 50 | set_prop(virtualizationservice, virtualizationservice_prop) |
Alan Stokes | 3fad86b | 2022-01-04 17:34:53 +0000 | [diff] [blame] | 51 | |
Alan Stokes | 8a881c1 | 2022-01-21 12:18:08 +0000 | [diff] [blame] | 52 | # Allow writing stats to statsd |
| 53 | unix_socket_send(virtualizationservice, statsdw, statsd) |
| 54 | |
Shikha Panwar | a9f1dc9 | 2022-03-24 09:05:59 +0000 | [diff] [blame] | 55 | # Allow virtualization service to talk to tombstoned to push guest tombstones |
| 56 | unix_socket_connect(virtualizationservice, tombstoned_crash, tombstoned) |
| 57 | |
| 58 | # Append to tombstone files passed as fds from tombstoned |
| 59 | allow virtualizationservice tombstone_data_file:file { append getattr }; |
| 60 | allow virtualizationservice tombstoned:fd use; |
| 61 | |
Inseob Kim | 825056d | 2023-08-01 11:00:49 +0900 | [diff] [blame] | 62 | # Allow virtualizationservice to check if VFIO is supported |
| 63 | allow virtualizationservice vfio_device:chr_file getattr; |
| 64 | allow virtualizationservice vfio_device:dir r_dir_perms; |
| 65 | |
Inseob Kim | bbe514d | 2023-08-03 12:53:48 +0900 | [diff] [blame^] | 66 | # Allow virtualizationservice to access VM DTBO via a file created by virtualizationmanager. |
| 67 | allow virtualizationservice virtualizationmanager:fd use; |
Inseob Kim | 825056d | 2023-08-01 11:00:49 +0900 | [diff] [blame] | 68 | |
Jiyong Park | b804de2 | 2021-09-16 21:06:20 +0900 | [diff] [blame] | 69 | neverallow { |
| 70 | domain |
| 71 | -init |
| 72 | -virtualizationservice |
| 73 | } virtualizationservice_prop:property_service set; |
Alan Stokes | 991087c | 2022-08-31 16:09:44 +0100 | [diff] [blame] | 74 | |
| 75 | neverallow { |
| 76 | domain |
| 77 | -init |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 78 | -virtualizationmanager |
Alan Stokes | 991087c | 2022-08-31 16:09:44 +0100 | [diff] [blame] | 79 | -virtualizationservice |
| 80 | } virtualizationservice_data_file:file { open create }; |
David Brazdil | 55d808c | 2022-12-15 13:38:42 +0000 | [diff] [blame] | 81 | |
| 82 | neverallow virtualizationservice { |
| 83 | domain |
| 84 | -virtualizationmanager |
| 85 | -virtualizationservice |
| 86 | }:process setrlimit; |
Inseob Kim | 825056d | 2023-08-01 11:00:49 +0900 | [diff] [blame] | 87 | |
| 88 | # Only virtualizationservice can communicate to vfio_handler |
| 89 | neverallow { domain -virtualizationservice -servicemanager } vfio_handler:binder call; |