Alex Klyubin | 238ce79 | 2017-02-07 10:47:18 -0800 | [diff] [blame] | 1 | # audioserver - audio services daemon |
| 2 | |
Alex Klyubin | f5446eb | 2017-03-23 14:27:32 -0700 | [diff] [blame] | 3 | typeattribute audioserver coredomain; |
| 4 | |
Alex Klyubin | 238ce79 | 2017-02-07 10:47:18 -0800 | [diff] [blame] | 5 | type audioserver_exec, exec_type, file_type; |
dcashman | cc39f63 | 2016-07-22 13:13:11 -0700 | [diff] [blame] | 6 | init_daemon_domain(audioserver) |
Alex Klyubin | 238ce79 | 2017-02-07 10:47:18 -0800 | [diff] [blame] | 7 | |
| 8 | r_dir_file(audioserver, sdcard_type) |
| 9 | |
| 10 | binder_use(audioserver) |
| 11 | binder_call(audioserver, binderservicedomain) |
| 12 | binder_call(audioserver, appdomain) |
| 13 | binder_service(audioserver) |
| 14 | |
Alex Klyubin | 7cda44f | 2017-03-21 14:28:53 -0700 | [diff] [blame] | 15 | hal_client_domain(audioserver, hal_allocator) |
Alex Klyubin | 2d70446 | 2017-04-10 11:40:53 -0700 | [diff] [blame] | 16 | # /system/lib64/hw for always-passthrough Allocator HAL ashmem / mapper .so |
| 17 | r_dir_file(audioserver, system_file) |
| 18 | |
Alex Klyubin | ac2b4cd | 2017-02-13 14:40:49 -0800 | [diff] [blame] | 19 | hal_client_domain(audioserver, hal_audio) |
Alex Klyubin | 238ce79 | 2017-02-07 10:47:18 -0800 | [diff] [blame] | 20 | |
Alex Klyubin | 238ce79 | 2017-02-07 10:47:18 -0800 | [diff] [blame] | 21 | userdebug_or_eng(` |
| 22 | # used for TEE sink - pcm capture for debug. |
| 23 | allow audioserver media_data_file:dir create_dir_perms; |
| 24 | allow audioserver audioserver_data_file:dir create_dir_perms; |
| 25 | allow audioserver audioserver_data_file:file create_file_perms; |
| 26 | |
| 27 | # ptrace to processes in the same domain for memory leak detection |
| 28 | allow audioserver self:process ptrace; |
| 29 | ') |
| 30 | |
Alex Klyubin | 238ce79 | 2017-02-07 10:47:18 -0800 | [diff] [blame] | 31 | add_service(audioserver, audioserver_service) |
Svet Ganov | b9a1e7b | 2018-01-16 21:14:34 -0800 | [diff] [blame] | 32 | allow audioserver activity_service:service_manager find; |
Alex Klyubin | 238ce79 | 2017-02-07 10:47:18 -0800 | [diff] [blame] | 33 | allow audioserver appops_service:service_manager find; |
| 34 | allow audioserver batterystats_service:service_manager find; |
| 35 | allow audioserver permission_service:service_manager find; |
| 36 | allow audioserver power_service:service_manager find; |
| 37 | allow audioserver scheduling_policy_service:service_manager find; |
| 38 | |
Aniket Kumar Lata | d3d7800 | 2018-01-31 20:20:08 -0800 | [diff] [blame] | 39 | # Allow read/write access to bluetooth-specific properties |
| 40 | set_prop(audioserver, bluetooth_prop) |
Ajay Panicker | e32d940 | 2018-02-27 11:43:23 -0800 | [diff] [blame] | 41 | |
Alex Klyubin | 238ce79 | 2017-02-07 10:47:18 -0800 | [diff] [blame] | 42 | # Grant access to audio files to audioserver |
| 43 | allow audioserver audio_data_file:dir ra_dir_perms; |
| 44 | allow audioserver audio_data_file:file create_file_perms; |
| 45 | |
Phil Burk | 2b7f74e | 2017-04-19 13:21:27 -0700 | [diff] [blame] | 46 | # allow access to ALSA MMAP FDs for AAudio API |
| 47 | allow audioserver audio_device:chr_file { read write }; |
| 48 | |
Joel Galenson | 6e8bfa2 | 2018-03-19 17:13:48 -0700 | [diff] [blame^] | 49 | not_full_treble(`allow audioserver audio_device:dir r_dir_perms;') |
| 50 | not_full_treble(`allow audioserver audio_device:chr_file rw_file_perms;') |
| 51 | |
Mikhail Naganov | 9450a87 | 2017-04-27 18:54:52 -0700 | [diff] [blame] | 52 | # For A2DP bridge which is loaded directly into audioserver |
| 53 | unix_socket_connect(audioserver, bluetooth, bluetooth) |
| 54 | |
Svet Ganov | b9a1e7b | 2018-01-16 21:14:34 -0800 | [diff] [blame] | 55 | # Allow shell commands from ADB for CTS testing/dumping |
| 56 | allow audioserver adbd:fd use; |
| 57 | allow audioserver adbd:unix_stream_socket { read write }; |
| 58 | |
| 59 | # Allow shell commands from ADB for CTS testing/dumping |
| 60 | userdebug_or_eng(` |
| 61 | allow audioserver su:fd use; |
| 62 | allow audioserver su:fifo_file { read write }; |
| 63 | allow audioserver su:unix_stream_socket { read write }; |
| 64 | ') |
| 65 | |
Alex Klyubin | 238ce79 | 2017-02-07 10:47:18 -0800 | [diff] [blame] | 66 | ### |
| 67 | ### neverallow rules |
| 68 | ### |
| 69 | |
| 70 | # audioserver should never execute any executable without a |
| 71 | # domain transition |
| 72 | neverallow audioserver { file_type fs_type }:file execute_no_trans; |
| 73 | |
Nick Kralevich | 38c1282 | 2017-02-16 12:34:51 -0800 | [diff] [blame] | 74 | # The goal of the mediaserver split is to place media processing code into |
| 75 | # restrictive sandboxes with limited responsibilities and thus limited |
| 76 | # permissions. Example: Audioserver is only responsible for controlling audio |
| 77 | # hardware and processing audio content. Cameraserver does the same for camera |
| 78 | # hardware/content. Etc. |
| 79 | # |
| 80 | # Media processing code is inherently risky and thus should have limited |
| 81 | # permissions and be isolated from the rest of the system and network. |
| 82 | # Lengthier explanation here: |
| 83 | # https://android-developers.googleblog.com/2016/05/hardening-media-stack.html |
Alex Klyubin | 238ce79 | 2017-02-07 10:47:18 -0800 | [diff] [blame] | 84 | neverallow audioserver domain:{ tcp_socket udp_socket rawip_socket } *; |