xref: /aosp_15_r20/system/sepolicy/prebuilts/api/34.0/private/audioserver.te (revision e4a36f4174b17bbab9dc043f4a65dc8d87377290)
1*e4a36f41SAndroid Build Coastguard Worker# audioserver - audio services daemon
2*e4a36f41SAndroid Build Coastguard Worker
3*e4a36f41SAndroid Build Coastguard Workertypeattribute audioserver coredomain;
4*e4a36f41SAndroid Build Coastguard Worker
5*e4a36f41SAndroid Build Coastguard Workertype audioserver_exec, exec_type, file_type, system_file_type;
6*e4a36f41SAndroid Build Coastguard Workerinit_daemon_domain(audioserver)
7*e4a36f41SAndroid Build Coastguard Workertmpfs_domain(audioserver)
8*e4a36f41SAndroid Build Coastguard Worker
9*e4a36f41SAndroid Build Coastguard Workerr_dir_file(audioserver, sdcard_type)
10*e4a36f41SAndroid Build Coastguard Workerr_dir_file(audioserver, fuse)
11*e4a36f41SAndroid Build Coastguard Worker
12*e4a36f41SAndroid Build Coastguard Workerbinder_use(audioserver)
13*e4a36f41SAndroid Build Coastguard Workerbinder_call(audioserver, binderservicedomain)
14*e4a36f41SAndroid Build Coastguard Workerbinder_call(audioserver, appdomain)
15*e4a36f41SAndroid Build Coastguard Workerbinder_service(audioserver)
16*e4a36f41SAndroid Build Coastguard Worker
17*e4a36f41SAndroid Build Coastguard Workerhal_client_domain(audioserver, hal_allocator)
18*e4a36f41SAndroid Build Coastguard Worker# /system/lib64/hw for always-passthrough Allocator HAL ashmem / mapper .so
19*e4a36f41SAndroid Build Coastguard Workerr_dir_file(audioserver, system_file)
20*e4a36f41SAndroid Build Coastguard Worker
21*e4a36f41SAndroid Build Coastguard Workerhal_client_domain(audioserver, hal_audio)
22*e4a36f41SAndroid Build Coastguard Worker
23*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
24*e4a36f41SAndroid Build Coastguard Worker  # used for TEE sink - pcm capture for debug.
25*e4a36f41SAndroid Build Coastguard Worker  allow audioserver media_data_file:dir create_dir_perms;
26*e4a36f41SAndroid Build Coastguard Worker  allow audioserver audioserver_data_file:dir create_dir_perms;
27*e4a36f41SAndroid Build Coastguard Worker  allow audioserver audioserver_data_file:file create_file_perms;
28*e4a36f41SAndroid Build Coastguard Worker
29*e4a36f41SAndroid Build Coastguard Worker  # ptrace to processes in the same domain for memory leak detection
30*e4a36f41SAndroid Build Coastguard Worker  allow audioserver self:process ptrace;
31*e4a36f41SAndroid Build Coastguard Worker')
32*e4a36f41SAndroid Build Coastguard Worker
33*e4a36f41SAndroid Build Coastguard Workeradd_service(audioserver, audioserver_service)
34*e4a36f41SAndroid Build Coastguard Workerallow audioserver activity_service:service_manager find;
35*e4a36f41SAndroid Build Coastguard Workerallow audioserver appops_service:service_manager find;
36*e4a36f41SAndroid Build Coastguard Workerallow audioserver batterystats_service:service_manager find;
37*e4a36f41SAndroid Build Coastguard Workerallow audioserver external_vibrator_service:service_manager find;
38*e4a36f41SAndroid Build Coastguard Workerallow audioserver package_native_service:service_manager find;
39*e4a36f41SAndroid Build Coastguard Workerallow audioserver permission_service:service_manager find;
40*e4a36f41SAndroid Build Coastguard Workerallow audioserver permission_checker_service:service_manager find;
41*e4a36f41SAndroid Build Coastguard Workerallow audioserver power_service:service_manager find;
42*e4a36f41SAndroid Build Coastguard Workerallow audioserver scheduling_policy_service:service_manager find;
43*e4a36f41SAndroid Build Coastguard Workerallow audioserver mediametrics_service:service_manager find;
44*e4a36f41SAndroid Build Coastguard Workerallow audioserver sensor_privacy_service:service_manager find;
45*e4a36f41SAndroid Build Coastguard Workerallow audioserver soundtrigger_middleware_service:service_manager find;
46*e4a36f41SAndroid Build Coastguard Workerallow audioserver audio_service:service_manager find;
47*e4a36f41SAndroid Build Coastguard Worker
48*e4a36f41SAndroid Build Coastguard Worker# Allow read/write access to bluetooth-specific properties
49*e4a36f41SAndroid Build Coastguard Workerset_prop(audioserver, bluetooth_a2dp_offload_prop)
50*e4a36f41SAndroid Build Coastguard Workerset_prop(audioserver, bluetooth_audio_hal_prop)
51*e4a36f41SAndroid Build Coastguard Workerset_prop(audioserver, bluetooth_prop)
52*e4a36f41SAndroid Build Coastguard Workerset_prop(audioserver, exported_bluetooth_prop)
53*e4a36f41SAndroid Build Coastguard Worker
54*e4a36f41SAndroid Build Coastguard Worker# Grant access to audio files to audioserver
55*e4a36f41SAndroid Build Coastguard Workerallow audioserver audio_data_file:dir ra_dir_perms;
56*e4a36f41SAndroid Build Coastguard Workerallow audioserver audio_data_file:file create_file_perms;
57*e4a36f41SAndroid Build Coastguard Worker
58*e4a36f41SAndroid Build Coastguard Worker# allow access to ALSA MMAP FDs for AAudio API
59*e4a36f41SAndroid Build Coastguard Workerallow audioserver audio_device:chr_file { read write };
60*e4a36f41SAndroid Build Coastguard Worker
61*e4a36f41SAndroid Build Coastguard Workernot_full_treble(`allow audioserver audio_device:dir r_dir_perms;')
62*e4a36f41SAndroid Build Coastguard Workernot_full_treble(`allow audioserver audio_device:chr_file rw_file_perms;')
63*e4a36f41SAndroid Build Coastguard Worker
64*e4a36f41SAndroid Build Coastguard Worker# For A2DP bridge which is loaded directly into audioserver
65*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(audioserver, bluetooth, bluetooth)
66*e4a36f41SAndroid Build Coastguard Worker
67*e4a36f41SAndroid Build Coastguard Worker# Allow shell commands from ADB and shell for CTS testing/dumping
68*e4a36f41SAndroid Build Coastguard Workerallow audioserver adbd:fd use;
69*e4a36f41SAndroid Build Coastguard Workerallow audioserver adbd:unix_stream_socket { read write };
70*e4a36f41SAndroid Build Coastguard Workerallow audioserver shell:fifo_file { read write };
71*e4a36f41SAndroid Build Coastguard Worker
72*e4a36f41SAndroid Build Coastguard Worker# Allow shell commands from ADB for CTS testing/dumping
73*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
74*e4a36f41SAndroid Build Coastguard Worker  allow audioserver su:fd use;
75*e4a36f41SAndroid Build Coastguard Worker  allow audioserver su:fifo_file { read write };
76*e4a36f41SAndroid Build Coastguard Worker  allow audioserver su:unix_stream_socket { read write };
77*e4a36f41SAndroid Build Coastguard Worker')
78*e4a36f41SAndroid Build Coastguard Worker
79*e4a36f41SAndroid Build Coastguard Worker# Allow write access to log tag property
80*e4a36f41SAndroid Build Coastguard Workerset_prop(audioserver, log_tag_prop);
81*e4a36f41SAndroid Build Coastguard Worker
82*e4a36f41SAndroid Build Coastguard Worker###
83*e4a36f41SAndroid Build Coastguard Worker### neverallow rules
84*e4a36f41SAndroid Build Coastguard Worker###
85*e4a36f41SAndroid Build Coastguard Worker
86*e4a36f41SAndroid Build Coastguard Worker# audioserver should never execute any executable without a
87*e4a36f41SAndroid Build Coastguard Worker# domain transition
88*e4a36f41SAndroid Build Coastguard Workerneverallow audioserver { file_type fs_type }:file execute_no_trans;
89*e4a36f41SAndroid Build Coastguard Worker
90*e4a36f41SAndroid Build Coastguard Worker# The goal of the mediaserver split is to place media processing code into
91*e4a36f41SAndroid Build Coastguard Worker# restrictive sandboxes with limited responsibilities and thus limited
92*e4a36f41SAndroid Build Coastguard Worker# permissions. Example: Audioserver is only responsible for controlling audio
93*e4a36f41SAndroid Build Coastguard Worker# hardware and processing audio content. Cameraserver does the same for camera
94*e4a36f41SAndroid Build Coastguard Worker# hardware/content. Etc.
95*e4a36f41SAndroid Build Coastguard Worker#
96*e4a36f41SAndroid Build Coastguard Worker# Media processing code is inherently risky and thus should have limited
97*e4a36f41SAndroid Build Coastguard Worker# permissions and be isolated from the rest of the system and network.
98*e4a36f41SAndroid Build Coastguard Worker# Lengthier explanation here:
99*e4a36f41SAndroid Build Coastguard Worker# https://android-developers.googleblog.com/2016/05/hardening-media-stack.html
100*e4a36f41SAndroid Build Coastguard Workerneverallow audioserver domain:{ udp_socket rawip_socket } *;
101*e4a36f41SAndroid Build Coastguard Workerneverallow audioserver { domain userdebug_or_eng(`-su') }:tcp_socket *;
102*e4a36f41SAndroid Build Coastguard Worker
103*e4a36f41SAndroid Build Coastguard Worker# Allow using wake locks
104*e4a36f41SAndroid Build Coastguard Workerwakelock_use(audioserver)
105*e4a36f41SAndroid Build Coastguard Worker
106*e4a36f41SAndroid Build Coastguard Worker# Allow reading audio config props, e.g. af.fast_track_multiplier
107*e4a36f41SAndroid Build Coastguard Workerget_prop(audioserver, audio_config_prop)
108