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 | |
| 4 | # When init runs a file labelled with virtualizationservice_exec, run it in the |
| 5 | # virtualizationservice domain. |
| 6 | init_daemon_domain(virtualizationservice) |
| 7 | |
| 8 | # Let the virtualizationservice domain use Binder. |
| 9 | binder_use(virtualizationservice) |
Jiyong Park | 5e20d83 | 2021-07-12 21:11:33 +0900 | [diff] [blame] | 10 | # ... and host a binder service |
| 11 | binder_service(virtualizationservice) |
Jiyong Park | 5e20d83 | 2021-07-12 21:11:33 +0900 | [diff] [blame] | 12 | |
| 13 | # Allow calling into the system server so that it can check permissions. |
| 14 | binder_call(virtualizationservice, system_server) |
| 15 | allow virtualizationservice permission_service:service_manager find; |
Jooyung Han | 970166f | 2021-10-05 17:22:45 +0900 | [diff] [blame] | 16 | # Allow virtualizationservice to access "package_native" service for staged apex info. |
| 17 | allow virtualizationservice package_native_service:service_manager find; |
Andrew Walbran | 4b80a3f | 2021-05-21 13:21:43 +0000 | [diff] [blame] | 18 | |
| 19 | # Let the virtualizationservice domain register the virtualization_service with ServiceManager. |
| 20 | add_service(virtualizationservice, virtualization_service) |
| 21 | |
| 22 | # When virtualizationservice execs a file with the crosvm_exec label, run it in the crosvm domain. |
| 23 | domain_auto_trans(virtualizationservice, crosvm_exec, crosvm) |
| 24 | |
Andrew Walbran | 4b80a3f | 2021-05-21 13:21:43 +0000 | [diff] [blame] | 25 | # Let virtualizationservice kill crosvm. |
| 26 | allow virtualizationservice crosvm:process sigkill; |
| 27 | |
| 28 | # Let virtualizationservice access its data directory. |
| 29 | allow virtualizationservice virtualizationservice_data_file:file create_file_perms; |
| 30 | allow virtualizationservice virtualizationservice_data_file:dir create_dir_perms; |
Andrew Walbran | 9b2fa1b | 2021-07-01 15:58:26 +0000 | [diff] [blame] | 31 | |
Jiyong Park | 5e20d83 | 2021-07-12 21:11:33 +0900 | [diff] [blame] | 32 | # Allow to use fd (e.g. /dev/pts/0) inherited from adbd so that we can redirect output from |
| 33 | # crosvm to the console |
| 34 | allow virtualizationservice adbd:fd use; |
| 35 | allow virtualizationservice adbd:unix_stream_socket { read write }; |
Andrew Walbran | 9b2fa1b | 2021-07-01 15:58:26 +0000 | [diff] [blame] | 36 | |
| 37 | # Let virtualizationservice read and write files from its various clients, but not open them |
| 38 | # directly as they must be passed over Binder by the client. |
| 39 | allow virtualizationservice apk_data_file:file { getattr read }; |
Jiyong Park | 5e20d83 | 2021-07-12 21:11:33 +0900 | [diff] [blame] | 40 | # Write access is needed for mutable partitions like instance.img |
Alan Stokes | e2a002c | 2021-07-28 14:05:25 +0100 | [diff] [blame] | 41 | allow virtualizationservice { |
| 42 | app_data_file |
| 43 | apex_compos_data_file |
| 44 | }:file { getattr read write }; |
| 45 | |
Andrew Walbran | 9b2fa1b | 2021-07-01 15:58:26 +0000 | [diff] [blame] | 46 | # shell_data_file is used for automated tests and manual debugging. |
| 47 | allow virtualizationservice shell_data_file:file { getattr read write }; |
Jiyong Park | f408371 | 2021-07-10 14:35:06 +0900 | [diff] [blame] | 48 | |
Jiyong Park | 5e20d83 | 2021-07-12 21:11:33 +0900 | [diff] [blame] | 49 | # Allow virtualizationservice to read apex-info-list.xml and access the APEX files listed there. |
| 50 | allow virtualizationservice apex_info_file:file r_file_perms; |
Jooyung Han | 6d4179a | 2021-07-16 13:05:40 +0900 | [diff] [blame] | 51 | allow virtualizationservice apex_data_file:dir search; |
| 52 | allow virtualizationservice staging_data_file:file r_file_perms; |
Jooyung Han | 970166f | 2021-10-05 17:22:45 +0900 | [diff] [blame] | 53 | allow virtualizationservice staging_data_file:dir search; |
Jooyung Han | 6d4179a | 2021-07-16 13:05:40 +0900 | [diff] [blame] | 54 | |
Alan Stokes | 3fad86b | 2022-01-04 17:34:53 +0000 | [diff] [blame] | 55 | # Run derive_classpath in our domain |
| 56 | allow virtualizationservice derive_classpath_exec:file rx_file_perms; |
| 57 | allow virtualizationservice apex_mnt_dir:dir r_dir_perms; |
Alan Stokes | 8a881c1 | 2022-01-21 12:18:08 +0000 | [diff] [blame] | 58 | # Ignore harmless denials on /proc/self/fd |
| 59 | dontaudit virtualizationservice self:dir write; |
Alan Stokes | 3fad86b | 2022-01-04 17:34:53 +0000 | [diff] [blame] | 60 | |
Jiyong Park | f408371 | 2021-07-10 14:35:06 +0900 | [diff] [blame] | 61 | # Let virtualizationservice to accept vsock connection from the guest VMs |
| 62 | allow virtualizationservice self:vsock_socket { create_socket_perms_no_ioctl listen accept }; |
Jiyong Park | b804de2 | 2021-09-16 21:06:20 +0900 | [diff] [blame] | 63 | |
| 64 | # Allow virtualizationservice to read/write its own sysprop. Only the process can do so. |
| 65 | set_prop(virtualizationservice, virtualizationservice_prop) |
Alan Stokes | 3fad86b | 2022-01-04 17:34:53 +0000 | [diff] [blame] | 66 | |
Andrew Scull | 792b03d | 2022-02-01 18:41:31 +0000 | [diff] [blame] | 67 | # Allow virtualizationservice to inspect hypervisor capabilities. |
| 68 | get_prop(virtualizationservice, hypervisor_prop) |
| 69 | |
Alan Stokes | 8a881c1 | 2022-01-21 12:18:08 +0000 | [diff] [blame] | 70 | # Allow writing stats to statsd |
| 71 | unix_socket_send(virtualizationservice, statsdw, statsd) |
| 72 | |
Shikha Panwar | a9f1dc9 | 2022-03-24 09:05:59 +0000 | [diff] [blame] | 73 | # Allow virtualization service to talk to tombstoned to push guest tombstones |
| 74 | unix_socket_connect(virtualizationservice, tombstoned_crash, tombstoned) |
| 75 | |
| 76 | # Append to tombstone files passed as fds from tombstoned |
| 77 | allow virtualizationservice tombstone_data_file:file { append getattr }; |
| 78 | allow virtualizationservice tombstoned:fd use; |
| 79 | |
Jiyong Park | b804de2 | 2021-09-16 21:06:20 +0900 | [diff] [blame] | 80 | neverallow { |
| 81 | domain |
| 82 | -init |
| 83 | -virtualizationservice |
| 84 | } virtualizationservice_prop:property_service set; |
Alan Stokes | 991087c | 2022-08-31 16:09:44 +0100 | [diff] [blame] | 85 | |
| 86 | neverallow { |
| 87 | domain |
| 88 | -init |
| 89 | -virtualizationservice |
| 90 | } virtualizationservice_data_file:file { open create }; |