xref: /aosp_15_r20/system/sepolicy/prebuilts/api/29.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 power_service:service_manager find;
40*e4a36f41SAndroid Build Coastguard Workerallow audioserver scheduling_policy_service:service_manager find;
41*e4a36f41SAndroid Build Coastguard Workerallow audioserver mediametrics_service:service_manager find;
42*e4a36f41SAndroid Build Coastguard Workerallow audioserver sensor_privacy_service:service_manager find;
43*e4a36f41SAndroid Build Coastguard Worker
44*e4a36f41SAndroid Build Coastguard Worker# Allow read/write access to bluetooth-specific properties
45*e4a36f41SAndroid Build Coastguard Workerset_prop(audioserver, bluetooth_a2dp_offload_prop)
46*e4a36f41SAndroid Build Coastguard Workerset_prop(audioserver, bluetooth_audio_hal_prop)
47*e4a36f41SAndroid Build Coastguard Workerset_prop(audioserver, bluetooth_prop)
48*e4a36f41SAndroid Build Coastguard Workerset_prop(audioserver, exported_bluetooth_prop)
49*e4a36f41SAndroid Build Coastguard Worker
50*e4a36f41SAndroid Build Coastguard Worker# Grant access to audio files to audioserver
51*e4a36f41SAndroid Build Coastguard Workerallow audioserver audio_data_file:dir ra_dir_perms;
52*e4a36f41SAndroid Build Coastguard Workerallow audioserver audio_data_file:file create_file_perms;
53*e4a36f41SAndroid Build Coastguard Worker
54*e4a36f41SAndroid Build Coastguard Worker# allow access to ALSA MMAP FDs for AAudio API
55*e4a36f41SAndroid Build Coastguard Workerallow audioserver audio_device:chr_file { read write };
56*e4a36f41SAndroid Build Coastguard Worker
57*e4a36f41SAndroid Build Coastguard Workernot_full_treble(`allow audioserver audio_device:dir r_dir_perms;')
58*e4a36f41SAndroid Build Coastguard Workernot_full_treble(`allow audioserver audio_device:chr_file rw_file_perms;')
59*e4a36f41SAndroid Build Coastguard Worker
60*e4a36f41SAndroid Build Coastguard Worker# For A2DP bridge which is loaded directly into audioserver
61*e4a36f41SAndroid Build Coastguard Workerunix_socket_connect(audioserver, bluetooth, bluetooth)
62*e4a36f41SAndroid Build Coastguard Worker
63*e4a36f41SAndroid Build Coastguard Worker# Allow shell commands from ADB and shell for CTS testing/dumping
64*e4a36f41SAndroid Build Coastguard Workerallow audioserver adbd:fd use;
65*e4a36f41SAndroid Build Coastguard Workerallow audioserver adbd:unix_stream_socket { read write };
66*e4a36f41SAndroid Build Coastguard Workerallow audioserver shell:fifo_file { read write };
67*e4a36f41SAndroid Build Coastguard Worker
68*e4a36f41SAndroid Build Coastguard Worker# Allow shell commands from ADB for CTS testing/dumping
69*e4a36f41SAndroid Build Coastguard Workeruserdebug_or_eng(`
70*e4a36f41SAndroid Build Coastguard Worker  allow audioserver su:fd use;
71*e4a36f41SAndroid Build Coastguard Worker  allow audioserver su:fifo_file { read write };
72*e4a36f41SAndroid Build Coastguard Worker  allow audioserver su:unix_stream_socket { read write };
73*e4a36f41SAndroid Build Coastguard Worker')
74*e4a36f41SAndroid Build Coastguard Worker
75*e4a36f41SAndroid Build Coastguard Worker# Allow write access to log tag property
76*e4a36f41SAndroid Build Coastguard Workerset_prop(audioserver, log_tag_prop);
77*e4a36f41SAndroid Build Coastguard Worker
78*e4a36f41SAndroid Build Coastguard Worker###
79*e4a36f41SAndroid Build Coastguard Worker### neverallow rules
80*e4a36f41SAndroid Build Coastguard Worker###
81*e4a36f41SAndroid Build Coastguard Worker
82*e4a36f41SAndroid Build Coastguard Worker# audioserver should never execute any executable without a
83*e4a36f41SAndroid Build Coastguard Worker# domain transition
84*e4a36f41SAndroid Build Coastguard Workerneverallow audioserver { file_type fs_type }:file execute_no_trans;
85*e4a36f41SAndroid Build Coastguard Worker
86*e4a36f41SAndroid Build Coastguard Worker# The goal of the mediaserver split is to place media processing code into
87*e4a36f41SAndroid Build Coastguard Worker# restrictive sandboxes with limited responsibilities and thus limited
88*e4a36f41SAndroid Build Coastguard Worker# permissions. Example: Audioserver is only responsible for controlling audio
89*e4a36f41SAndroid Build Coastguard Worker# hardware and processing audio content. Cameraserver does the same for camera
90*e4a36f41SAndroid Build Coastguard Worker# hardware/content. Etc.
91*e4a36f41SAndroid Build Coastguard Worker#
92*e4a36f41SAndroid Build Coastguard Worker# Media processing code is inherently risky and thus should have limited
93*e4a36f41SAndroid Build Coastguard Worker# permissions and be isolated from the rest of the system and network.
94*e4a36f41SAndroid Build Coastguard Worker# Lengthier explanation here:
95*e4a36f41SAndroid Build Coastguard Worker# https://android-developers.googleblog.com/2016/05/hardening-media-stack.html
96*e4a36f41SAndroid Build Coastguard Workerneverallow audioserver domain:{ tcp_socket udp_socket rawip_socket } *;
97*e4a36f41SAndroid Build Coastguard Worker
98*e4a36f41SAndroid Build Coastguard Worker# Allow using wake locks
99*e4a36f41SAndroid Build Coastguard Workerwakelock_use(audioserver)
100