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