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