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 | |
| 25 | # Let virtualizationservice exec other files (e.g. mk_cdisk) in the same domain. |
| 26 | allow virtualizationservice system_file:file execute_no_trans; |
| 27 | |
| 28 | # Let virtualizationservice kill crosvm. |
| 29 | allow virtualizationservice crosvm:process sigkill; |
| 30 | |
| 31 | # Let virtualizationservice access its data directory. |
| 32 | allow virtualizationservice virtualizationservice_data_file:file create_file_perms; |
| 33 | allow virtualizationservice virtualizationservice_data_file:dir create_dir_perms; |
Andrew Walbran | 9b2fa1b | 2021-07-01 15:58:26 +0000 | [diff] [blame] | 34 | |
Jiyong Park | 5e20d83 | 2021-07-12 21:11:33 +0900 | [diff] [blame] | 35 | # Allow to use fd (e.g. /dev/pts/0) inherited from adbd so that we can redirect output from |
| 36 | # crosvm to the console |
| 37 | allow virtualizationservice adbd:fd use; |
| 38 | allow virtualizationservice adbd:unix_stream_socket { read write }; |
Andrew Walbran | 9b2fa1b | 2021-07-01 15:58:26 +0000 | [diff] [blame] | 39 | |
| 40 | # Let virtualizationservice read and write files from its various clients, but not open them |
| 41 | # directly as they must be passed over Binder by the client. |
| 42 | allow virtualizationservice apk_data_file:file { getattr read }; |
Jiyong Park | 5e20d83 | 2021-07-12 21:11:33 +0900 | [diff] [blame] | 43 | # Write access is needed for mutable partitions like instance.img |
Alan Stokes | e2a002c | 2021-07-28 14:05:25 +0100 | [diff] [blame] | 44 | allow virtualizationservice { |
| 45 | app_data_file |
| 46 | apex_compos_data_file |
| 47 | }:file { getattr read write }; |
| 48 | |
Andrew Walbran | 9b2fa1b | 2021-07-01 15:58:26 +0000 | [diff] [blame] | 49 | # shell_data_file is used for automated tests and manual debugging. |
| 50 | allow virtualizationservice shell_data_file:file { getattr read write }; |
Jiyong Park | f408371 | 2021-07-10 14:35:06 +0900 | [diff] [blame] | 51 | |
Jiyong Park | 5e20d83 | 2021-07-12 21:11:33 +0900 | [diff] [blame] | 52 | # Allow virtualizationservice to read apex-info-list.xml and access the APEX files listed there. |
| 53 | allow virtualizationservice apex_info_file:file r_file_perms; |
Jooyung Han | 6d4179a | 2021-07-16 13:05:40 +0900 | [diff] [blame] | 54 | allow virtualizationservice apex_data_file:dir search; |
| 55 | allow virtualizationservice staging_data_file:file r_file_perms; |
Jooyung Han | 970166f | 2021-10-05 17:22:45 +0900 | [diff] [blame^] | 56 | allow virtualizationservice staging_data_file:dir search; |
Jooyung Han | 6d4179a | 2021-07-16 13:05:40 +0900 | [diff] [blame] | 57 | |
Jiyong Park | f408371 | 2021-07-10 14:35:06 +0900 | [diff] [blame] | 58 | # Let virtualizationservice to accept vsock connection from the guest VMs |
| 59 | allow virtualizationservice self:vsock_socket { create_socket_perms_no_ioctl listen accept }; |
Jiyong Park | b804de2 | 2021-09-16 21:06:20 +0900 | [diff] [blame] | 60 | |
| 61 | # Allow virtualizationservice to read/write its own sysprop. Only the process can do so. |
| 62 | set_prop(virtualizationservice, virtualizationservice_prop) |
| 63 | neverallow { |
| 64 | domain |
| 65 | -init |
| 66 | -virtualizationservice |
| 67 | } virtualizationservice_prop:property_service set; |