add sepolicy type for widevine/drm hal in system
Bug: 371777025
Test: lunch qemu_trusty_arm64-trunk_staging-userdebug
Change-Id: I4eb0cbd376ad598c6b9dc7a9ed32e696225bc253
diff --git a/contexts/plat_file_contexts_test b/contexts/plat_file_contexts_test
index fd25d0a..bff3c87 100644
--- a/contexts/plat_file_contexts_test
+++ b/contexts/plat_file_contexts_test
@@ -808,6 +808,9 @@
/system/system_ext/lib64 system_lib_file
/system/system_ext/lib64/does_not_exist system_lib_file
+/system_ext/bin/hw/android.hardware.drm-service.widevine.system hal_widevine_system_exec
+/system/system_ext/bin/hw/android.hardware.drm-service.widevine.system hal_widevine_system_exec
+
/vendor_dlkm vendor_file
/vendor_dlkm/does_not_exist vendor_file
/vendor/vendor_dlkm vendor_file
diff --git a/private/domain.te b/private/domain.te
index 8db40a5..1de057a 100644
--- a/private/domain.te
+++ b/private/domain.te
@@ -2329,6 +2329,7 @@
# these are permissions that should be removed, and they are here for visibility.
-compos_fd_server # TODO: get connections from virtmanager
-hal_keymint_system # TODO: get connections from virtmanager
+ -hal_widevine_system # TODO: get connections from virtmanager
-vmlauncher_app # TODO: get connections from virtmanager
} *:vsock_socket { connect create accept bind };
')
diff --git a/private/file_contexts b/private/file_contexts
index 0b3e7f4..23a895e 100644
--- a/private/file_contexts
+++ b/private/file_contexts
@@ -555,6 +555,7 @@
/(system_ext|system/system_ext)/etc/aconfig(/.*)? u:object_r:system_aconfig_storage_file:s0
/(system_ext|system/system_ext)/etc/selinux/system_ext_tee_service_contexts u:object_r:tee_service_contexts_file:s0
+/(system_ext|system/system_ext)/bin/hw/android\.hardware\.drm-service\.widevine\.system u:object_r:hal_widevine_system_exec:s0
#############################
# VendorDlkm files
diff --git a/private/hal_drm.te b/private/hal_drm.te
index 211fbb7..f24c326 100644
--- a/private/hal_drm.te
+++ b/private/hal_drm.te
@@ -33,7 +33,7 @@
allow hal_drm_server shell:fifo_file write;
# Allow access to ion memory allocation device
-allow hal_drm ion_device:chr_file rw_file_perms;
+allow { hal_drm -hal_widevine_system } ion_device:chr_file rw_file_perms;
allow hal_drm hal_graphics_allocator:fd use;
# Allow access to hidl_memory allocation service
@@ -42,9 +42,9 @@
# Allow access to fds allocated by mediaserver
allow hal_drm mediaserver:fd use;
-allow hal_drm sysfs:file r_file_perms;
+allow { hal_drm -hal_widevine_system } sysfs:file r_file_perms;
-allow hal_drm tee_device:chr_file rw_file_perms;
+allow { hal_drm -hal_widevine_system } tee_device:chr_file rw_file_perms;
allow hal_drm_server { appdomain -isolated_app }:fd use;
diff --git a/private/hal_widevine_system.te b/private/hal_widevine_system.te
new file mode 100644
index 0000000..57213b3
--- /dev/null
+++ b/private/hal_widevine_system.te
@@ -0,0 +1,7 @@
+type hal_widevine_system, domain, coredomain;
+hal_server_domain(hal_widevine_system, hal_drm)
+
+type hal_widevine_system_exec, exec_type, system_file_type, file_type;
+init_daemon_domain(hal_widevine_system)
+
+allow hal_widevine_system self:vsock_socket { create_socket_perms_no_ioctl };
diff --git a/private/property.te b/private/property.te
index cd87e7a..2796d7f 100644
--- a/private/property.te
+++ b/private/property.te
@@ -79,6 +79,7 @@
system_internal_prop(system_service_enable_prop)
system_internal_prop(ctl_artd_pre_reboot_prop)
system_internal_prop(trusty_security_vm_sys_prop)
+system_internal_prop(trusty_widevine_vm_sys_prop)
system_internal_prop(hint_manager_config_prop)
# Properties which can't be written outside system
diff --git a/private/property_contexts b/private/property_contexts
index d80931c..8801a17 100644
--- a/private/property_contexts
+++ b/private/property_contexts
@@ -1808,6 +1808,9 @@
# Properties related to Trusty VMs
trusty.security_vm.nonsecure_vm_ready u:object_r:trusty_security_vm_sys_prop:s0 exact bool
trusty.security_vm.vm_cid u:object_r:trusty_security_vm_sys_prop:s0 exact int
+trusty.widevine_vm.nonsecure_vm_ready u:object_r:trusty_widevine_vm_sys_prop:s0 exact bool
+trusty.widevine_vm.vm_cid u:object_r:trusty_widevine_vm_sys_prop:s0 exact int
+trusty.widevine_vm.port u:object_r:trusty_widevine_vm_sys_prop:s0 exact int
# Properties that allows vendors to enable Trusty security VM features
trusty.security_vm.enabled u:object_r:trusty_security_vm_sys_vendor_prop:s0 exact bool