Skip to content
Snippets Groups Projects
Commit 7cda44f4 authored by Alex Klyubin's avatar Alex Klyubin
Browse files

Mark all clients of Allocator HAL

This change associates all domains which are clients of Allocator HAL
with hal_allocator_client and the, required for all HAL client
domains, halclientdomain.

This enables this commit to remove the now unnecessary hwallocator_use
macro because its binder_call(..., hal_allocator_server) is covered by
binder_call(hal_allocator_client, hal_allocator_server) added in this
commit.

Unfortunately apps, except isolated app, are clients of Allocator HAL
as well. This makes it hard to use the hal_client_domain(...,
hal_allocator) macro because it translates into "typeattribute" which
currently does not support being provided with a set of types, such as
{ appdomain -isolated_app }. As a workaround, hopefully until
typeattribute is improved, this commit expresses the necessary
association operation in CIL. private/technical_debt.cil introduced by
this commit is appended into the platform policy CIL file, thus
ensuring that the hack has effect on the final monolithic policy.

P. S. This change also removes Allocator HAL access from isolated_app.
Isolated app shouldn't have access to this HAL anyway.

Test: Google Play Music plays back radios
Test: Google Camera records video with sound and that video is then
      successfully played back with sound
Test: YouTube app plays back clips with sound
Test: YouTube in Chrome plays back clips with sound
Bug: 34170079
Change-Id: Id00bba6fde83e7cf04fb58bc1c353c2f66333f92
parent f5446eb1
No related branches found
No related tags found
No related merge requests found
...@@ -124,6 +124,11 @@ sepolicy_build_files := security_classes \ ...@@ -124,6 +124,11 @@ sepolicy_build_files := security_classes \
genfs_contexts \ genfs_contexts \
port_contexts port_contexts
# CIL files which contain workarounds for current limitation of human-readable
# module policy language. These files are appended to the CIL files produced
# from module language files.
sepolicy_build_cil_workaround_files := technical_debt.cil
my_target_arch := $(TARGET_ARCH) my_target_arch := $(TARGET_ARCH)
ifneq (,$(filter mips mips64,$(TARGET_ARCH))) ifneq (,$(filter mips mips64,$(TARGET_ARCH)))
my_target_arch := mips my_target_arch := mips
...@@ -250,9 +255,13 @@ $(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY)) ...@@ -250,9 +255,13 @@ $(PLAT_PUBLIC_POLICY) $(PLAT_PRIVATE_POLICY))
$(hide) sed '/dontaudit/d' $@ > $@.dontaudit $(hide) sed '/dontaudit/d' $@ > $@.dontaudit
plat_policy_nvr := $(intermediates)/plat_policy_nvr.cil plat_policy_nvr := $(intermediates)/plat_policy_nvr.cil
$(plat_policy_nvr): $(plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy $(plat_policy_nvr): PRIVATE_ADDITIONAL_CIL_FILES := \
$(call build_policy, $(sepolicy_build_cil_workaround_files), $(PLAT_PRIVATE_POLICY))
$(plat_policy_nvr): $(plat_policy.conf) $(HOST_OUT_EXECUTABLES)/checkpolicy \
$(call build_policy, $(sepolicy_build_cil_workaround_files), $(PLAT_PRIVATE_POLICY))
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c $(POLICYVERS) -o $@ $< $(hide) $(HOST_OUT_EXECUTABLES)/checkpolicy -M -C -c $(POLICYVERS) -o $@ $<
$(hide) cat $(PRIVATE_ADDITIONAL_CIL_FILES) >> $@
$(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(plat_policy_nvr) $(LOCAL_BUILT_MODULE): PRIVATE_CIL_FILES := $(plat_policy_nvr)
$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(plat_policy_nvr) $(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/secilc $(plat_policy_nvr)
...@@ -1114,6 +1123,7 @@ plat_policy_nvr := ...@@ -1114,6 +1123,7 @@ plat_policy_nvr :=
plat_pub_policy.cil := plat_pub_policy.cil :=
reqd_policy_mask.cil := reqd_policy_mask.cil :=
sepolicy_build_files := sepolicy_build_files :=
sepolicy_build_cil_workaround_files :=
with_asan := with_asan :=
include $(call all-makefiles-under,$(LOCAL_PATH)) include $(call all-makefiles-under,$(LOCAL_PATH))
...@@ -155,7 +155,6 @@ binder_call(appdomain, ephemeral_app) ...@@ -155,7 +155,6 @@ binder_call(appdomain, ephemeral_app)
# hidl access for mediacodec # hidl access for mediacodec
# TODO(b/34454312): only allow getting and talking to mediacodec service # TODO(b/34454312): only allow getting and talking to mediacodec service
hwbinder_use(appdomain) hwbinder_use(appdomain)
hwallocator_use(appdomain)
# Already connected, unnamed sockets being passed over some other IPC # Already connected, unnamed sockets being passed over some other IPC
# hence no sock_file or connectto permission. This appears to be how # hence no sock_file or connectto permission. This appears to be how
......
...@@ -12,10 +12,9 @@ binder_call(audioserver, binderservicedomain) ...@@ -12,10 +12,9 @@ binder_call(audioserver, binderservicedomain)
binder_call(audioserver, appdomain) binder_call(audioserver, appdomain)
binder_service(audioserver) binder_service(audioserver)
hal_client_domain(audioserver, hal_allocator)
hal_client_domain(audioserver, hal_audio) hal_client_domain(audioserver, hal_audio)
allow audioserver system_file:dir r_dir_perms;
userdebug_or_eng(` userdebug_or_eng(`
# used for TEE sink - pcm capture for debug. # used for TEE sink - pcm capture for debug.
allow audioserver media_data_file:dir create_dir_perms; allow audioserver media_data_file:dir create_dir_perms;
......
...@@ -168,7 +168,7 @@ binder_service(system_server) ...@@ -168,7 +168,7 @@ binder_service(system_server)
# Perform HwBinder IPC. # Perform HwBinder IPC.
hwbinder_use(system_server) hwbinder_use(system_server)
hwallocator_use(system_server) hal_client_domain(system_server, hal_allocator)
binder_call(system_server, hal_contexthub) binder_call(system_server, hal_contexthub)
hal_client_domain(system_server, hal_contexthub) hal_client_domain(system_server, hal_contexthub)
hal_client_domain(system_server, hal_fingerprint) hal_client_domain(system_server, hal_fingerprint)
......
; THIS IS A WORKAROUND for the current limitations of the module policy language
; This should be used sparingly until we figure out a saner way to achieve the
; stuff below, for example, by improving typeattribute statement of module
; language.
;
; NOTE: This file has no effect on recovery policy.
; Apps, except isolated apps, are clients of Allocator HAL
; Unfortunately, we can't currently express this in module policy language:
; typeattribute { appdomain -isolated_app } hal_allocator_client;
; typeattribute hal_allocator_client halclientdomain;
(typeattributeset hal_allocator_client ((and (appdomain) ((not (isolated_app))))))
(typeattributeset halclientdomain (hal_allocator_client))
# HwBinder IPC from client to server
binder_call(hal_allocator_client, hal_allocator_server)
...@@ -2,14 +2,8 @@ ...@@ -2,14 +2,8 @@
binder_call(hal_audio_client, hal_audio_server) binder_call(hal_audio_client, hal_audio_server)
binder_call(hal_audio_server, hal_audio_client) binder_call(hal_audio_server, hal_audio_client)
# Both client and the server need to use hwallocator
hwallocator_use(hal_audio_client)
hwallocator_use(hal_audio_server)
allow hal_audio ion_device:chr_file r_file_perms; allow hal_audio ion_device:chr_file r_file_perms;
allow hal_audio system_file:dir { open read };
userdebug_or_eng(` userdebug_or_eng(`
# used for pcm capture for debug. # used for pcm capture for debug.
allow hal_audio audiohal_data_file:dir create_dir_perms; allow hal_audio audiohal_data_file:dir create_dir_perms;
......
...@@ -25,10 +25,7 @@ allow mediacodec hal_camera:fd use; ...@@ -25,10 +25,7 @@ allow mediacodec hal_camera:fd use;
crash_dump_fallback(mediacodec) crash_dump_fallback(mediacodec)
# hidl access hal_client_domain(mediacodec, hal_allocator)
hwbinder_use(mediacodec)
hwallocator_use(mediacodec)
allow mediacodec system_file:dir { open read };
# Recieve gralloc buffer FDs from bufferhubd. Note that mediacodec never # Recieve gralloc buffer FDs from bufferhubd. Note that mediacodec never
# directly connects to bufferhubd via PDX. Instead, a VR app acts as a bridge # directly connects to bufferhubd via PDX. Instead, a VR app acts as a bridge
......
...@@ -136,9 +136,7 @@ allow mediaserver hal_camera:fd use; ...@@ -136,9 +136,7 @@ allow mediaserver hal_camera:fd use;
allow mediaserver system_server:fd use; allow mediaserver system_server:fd use;
# hidl access hal_client_domain(mediaserver, hal_allocator)
hwbinder_use(mediaserver)
hwallocator_use(mediaserver)
### ###
### neverallow rules ### neverallow rules
......
...@@ -327,14 +327,6 @@ define(`binder_service', ` ...@@ -327,14 +327,6 @@ define(`binder_service', `
typeattribute $1 binderservicedomain; typeattribute $1 binderservicedomain;
') ')
#####################################
# hwallocator_use(domain)
# Allow a domain to use Hidl shared memory
define(`hwallocator_use', `
# Call into the allocator hal
binder_call($1, hal_allocator_server);
')
##################################### #####################################
# wakelock_use(domain) # wakelock_use(domain)
# Allow domain to manage wake locks # Allow domain to manage wake locks
......
...@@ -3,3 +3,5 @@ hal_server_domain(hal_audio_default, hal_audio) ...@@ -3,3 +3,5 @@ hal_server_domain(hal_audio_default, hal_audio)
type hal_audio_default_exec, exec_type, file_type; type hal_audio_default_exec, exec_type, file_type;
init_daemon_domain(hal_audio_default) init_daemon_domain(hal_audio_default)
hal_client_domain(hal_audio_default, hal_allocator)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment