platform_system_sepolicy/private/mediametrics.te
Inseob Kim 75806ef3c5 Minimize public policy
Ideally, public should only contain APIs (types / attributes) for
vendor. The other statements like allow/neverallow/typeattributes are
regarded as implementation detail for platform and should be in private.

Bug: 232023812
Test: m selinux_policy
Test: diff <(git diff --staged | grep "^-" | cut -b2- | sort) \
           <(git diff --staged | grep "^+" | cut -b2- | sort)
Test: remove comments on plat_sepolicy.cil, replace base_typeattr_*
      to base_typeattr and then compare old and new plat_sepolicy.cil
Change-Id: I5e7d2da4465ab0216de6bacdf03077d37f6ffe12
2024-03-28 00:33:46 +00:00

50 lines
1.8 KiB
Text

typeattribute mediametrics coredomain;
init_daemon_domain(mediametrics)
# Needed for stats callback registration to statsd.
allow mediametrics stats_service:service_manager find;
allow mediametrics statsmanager_service:service_manager find;
binder_call(mediametrics, statsd)
binder_use(mediametrics)
binder_call(mediametrics, binderservicedomain)
binder_service(mediametrics)
add_service(mediametrics, mediametrics_service)
allow mediametrics system_server:fd use;
r_dir_file(mediametrics, cgroup)
r_dir_file(mediametrics, cgroup_v2)
allow mediametrics proc_meminfo:file r_file_perms;
# allows interactions with dumpsys to GMScore
allow mediametrics { app_data_file privapp_data_file }:file write;
# allow access to package manager for uid->apk mapping
allow mediametrics package_native_service:service_manager find;
# Allow metrics service to send information to statsd socket.
unix_socket_send(mediametrics, statsdw, statsd)
###
### neverallow rules
###
# mediametrics should never execute any executable without a
# domain transition
neverallow mediametrics { file_type fs_type }:file execute_no_trans;
# The goal of the mediaserver split is to place media processing code into
# restrictive sandboxes with limited responsibilities and thus limited
# permissions. Example: Audioserver is only responsible for controlling audio
# hardware and processing audio content. Cameraserver does the same for camera
# hardware/content. Etc.
#
# Media processing code is inherently risky and thus should have limited
# permissions and be isolated from the rest of the system and network.
# Lengthier explanation here:
# https://android-developers.googleblog.com/2016/05/hardening-media-stack.html
neverallow mediametrics domain:{ udp_socket rawip_socket } *;
neverallow mediametrics { domain userdebug_or_eng(`-su') }:tcp_socket *;