Jeff Vander Stoep | ff1e018 | 2017-04-13 07:51:36 -0700 | [diff] [blame] | 1 | # bluetooth app |
Alex Klyubin | 801b5ec | 2017-02-06 15:27:19 -0800 | [diff] [blame] | 2 | |
Alan Stokes | 81e4e87 | 2020-02-11 14:43:05 +0000 | [diff] [blame] | 3 | typeattribute bluetooth coredomain, mlstrustedsubject; |
Alex Klyubin | 801b5ec | 2017-02-06 15:27:19 -0800 | [diff] [blame] | 4 | |
| 5 | app_domain(bluetooth) |
| 6 | net_domain(bluetooth) |
| 7 | |
dcashman | cc39f63 | 2016-07-22 13:13:11 -0700 | [diff] [blame] | 8 | # Socket creation under /data/misc/bluedroid. |
| 9 | type_transition bluetooth bluetooth_data_file:sock_file bluetooth_socket; |
dcashman | 2e00e63 | 2016-10-12 14:58:09 -0700 | [diff] [blame] | 10 | |
Alex Klyubin | 801b5ec | 2017-02-06 15:27:19 -0800 | [diff] [blame] | 11 | # Allow access to net_admin ioctls |
| 12 | allowxperm bluetooth self:udp_socket ioctl priv_sock_ioctls; |
| 13 | |
| 14 | wakelock_use(bluetooth); |
| 15 | |
| 16 | # Data file accesses. |
| 17 | allow bluetooth bluetooth_data_file:dir create_dir_perms; |
Jakub Pawlowski | 86f7945 | 2022-04-07 16:03:39 +0200 | [diff] [blame] | 18 | allow bluetooth bluetooth_data_file:notdevfile_class_set { create_file_perms link }; |
Alex Klyubin | 801b5ec | 2017-02-06 15:27:19 -0800 | [diff] [blame] | 19 | allow bluetooth bluetooth_logs_data_file:dir rw_dir_perms; |
| 20 | allow bluetooth bluetooth_logs_data_file:file create_file_perms; |
| 21 | |
| 22 | # Socket creation under /data/misc/bluedroid. |
| 23 | allow bluetooth bluetooth_socket:sock_file create_file_perms; |
| 24 | |
Benjamin Gordon | 9b2e0cb | 2017-11-09 15:51:26 -0700 | [diff] [blame] | 25 | allow bluetooth self:global_capability_class_set net_admin; |
| 26 | allow bluetooth self:global_capability2_class_set wake_alarm; |
Alex Klyubin | 801b5ec | 2017-02-06 15:27:19 -0800 | [diff] [blame] | 27 | |
| 28 | # tethering |
| 29 | allow bluetooth self:packet_socket create_socket_perms_no_ioctl; |
Benjamin Gordon | 9b2e0cb | 2017-11-09 15:51:26 -0700 | [diff] [blame] | 30 | allow bluetooth self:global_capability_class_set { net_admin net_raw net_bind_service }; |
Alex Klyubin | 801b5ec | 2017-02-06 15:27:19 -0800 | [diff] [blame] | 31 | allow bluetooth self:tun_socket create_socket_perms_no_ioctl; |
| 32 | allow bluetooth tun_device:chr_file rw_file_perms; |
Nick Kralevich | 049c03d | 2018-11-10 09:03:10 -0800 | [diff] [blame] | 33 | allowxperm bluetooth tun_device:chr_file ioctl { TUNGETIFF TUNSETIFF }; |
Alex Klyubin | 801b5ec | 2017-02-06 15:27:19 -0800 | [diff] [blame] | 34 | allow bluetooth efs_file:dir search; |
| 35 | |
Jack He | a61f7f6 | 2017-04-18 18:06:41 -0700 | [diff] [blame] | 36 | # allow Bluetooth to access uhid device for HID profile |
| 37 | allow bluetooth uhid_device:chr_file rw_file_perms; |
| 38 | |
Jason Macnak | a933980 | 2022-02-24 18:32:16 +0000 | [diff] [blame] | 39 | allow bluetooth gpu_device:chr_file rw_file_perms; |
| 40 | allow bluetooth gpu_device:dir r_dir_perms; |
| 41 | |
Alex Klyubin | 801b5ec | 2017-02-06 15:27:19 -0800 | [diff] [blame] | 42 | # proc access. |
| 43 | allow bluetooth proc_bluetooth_writable:file rw_file_perms; |
| 44 | |
wescande | 4b6a6aa | 2021-08-23 16:59:08 +0200 | [diff] [blame] | 45 | # For Bluetooth to check what profile are available |
| 46 | allow bluetooth proc_filesystems:file r_file_perms; |
| 47 | get_prop(bluetooth, incremental_prop) |
| 48 | |
Rubin Xu | a274858 | 2022-05-12 14:49:10 +0100 | [diff] [blame] | 49 | # For Bluetooth to check security logging state |
| 50 | get_prop(bluetooth, device_logging_prop) |
| 51 | |
Alex Klyubin | 801b5ec | 2017-02-06 15:27:19 -0800 | [diff] [blame] | 52 | # Allow write access to bluetooth specific properties |
Lee Shombert | 097f979 | 2020-01-17 10:06:16 -0800 | [diff] [blame] | 53 | set_prop(bluetooth, binder_cache_bluetooth_server_prop); |
| 54 | neverallow { domain -bluetooth -init } |
| 55 | binder_cache_bluetooth_server_prop:property_service set; |
Jaekyun Seok | 224921d | 2018-04-09 12:07:32 +0900 | [diff] [blame] | 56 | set_prop(bluetooth, bluetooth_a2dp_offload_prop) |
Cheney Ni | e55a74b | 2019-03-18 11:07:32 +0800 | [diff] [blame] | 57 | set_prop(bluetooth, bluetooth_audio_hal_prop) |
Silen Sun | a6cb5e8 | 2025-02-20 22:45:27 -0800 | [diff] [blame^] | 58 | set_prop(bluetooth, bluetooth_lea_mode_prop) |
Alex Klyubin | 801b5ec | 2017-02-06 15:27:19 -0800 | [diff] [blame] | 59 | set_prop(bluetooth, bluetooth_prop) |
Jaekyun Seok | 224921d | 2018-04-09 12:07:32 +0900 | [diff] [blame] | 60 | set_prop(bluetooth, exported_bluetooth_prop) |
Alex Klyubin | 801b5ec | 2017-02-06 15:27:19 -0800 | [diff] [blame] | 61 | set_prop(bluetooth, pan_result_prop) |
| 62 | |
| 63 | allow bluetooth audioserver_service:service_manager find; |
| 64 | allow bluetooth bluetooth_service:service_manager find; |
| 65 | allow bluetooth drmserver_service:service_manager find; |
| 66 | allow bluetooth mediaserver_service:service_manager find; |
| 67 | allow bluetooth radio_service:service_manager find; |
Alex Klyubin | 801b5ec | 2017-02-06 15:27:19 -0800 | [diff] [blame] | 68 | allow bluetooth app_api_service:service_manager find; |
| 69 | allow bluetooth system_api_service:service_manager find; |
Remi NGUYEN VAN | 44fd885 | 2019-01-13 15:41:48 +0900 | [diff] [blame] | 70 | allow bluetooth network_stack_service:service_manager find; |
Michael Sun | df54a52 | 2020-10-14 00:31:01 +0000 | [diff] [blame] | 71 | allow bluetooth system_suspend_control_service:service_manager find; |
Josh Wu | 759b4ef | 2021-12-27 07:36:01 -0800 | [diff] [blame] | 72 | allow bluetooth hal_audio_service:service_manager find; |
Alex Klyubin | 801b5ec | 2017-02-06 15:27:19 -0800 | [diff] [blame] | 73 | |
Alex Klyubin | 801b5ec | 2017-02-06 15:27:19 -0800 | [diff] [blame] | 74 | # already open bugreport file descriptors may be shared with |
| 75 | # the bluetooth process, from a file in |
| 76 | # /data/data/com.android.shell/files/bugreports/bugreport-*. |
| 77 | allow bluetooth shell_data_file:file read; |
| 78 | |
Philip Cuadra | 6eee6eb | 2017-03-23 10:03:49 -0700 | [diff] [blame] | 79 | # Bluetooth audio needs RT scheduling to meet deadlines, allow sys_nice |
Benjamin Gordon | 9b2e0cb | 2017-11-09 15:51:26 -0700 | [diff] [blame] | 80 | allow bluetooth self:global_capability_class_set sys_nice; |
Philip Cuadra | 6eee6eb | 2017-03-23 10:03:49 -0700 | [diff] [blame] | 81 | |
Alex Klyubin | 168435f | 2017-02-16 20:14:56 -0800 | [diff] [blame] | 82 | hal_client_domain(bluetooth, hal_bluetooth) |
Alex Klyubin | 9e6b24c | 2017-03-16 18:48:40 -0700 | [diff] [blame] | 83 | hal_client_domain(bluetooth, hal_telephony) |
Alex Klyubin | 801b5ec | 2017-02-06 15:27:19 -0800 | [diff] [blame] | 84 | |
Sunny Kapdi | bc0c88f | 2017-10-30 12:58:20 -0700 | [diff] [blame] | 85 | # Bluetooth A2DP offload requires binding with audio HAL |
| 86 | hal_client_domain(bluetooth, hal_audio) |
| 87 | |
Alex Klyubin | 801b5ec | 2017-02-06 15:27:19 -0800 | [diff] [blame] | 88 | read_runtime_log_tags(bluetooth) |
| 89 | |
| 90 | ### |
| 91 | ### Neverallow rules |
| 92 | ### |
| 93 | ### These are things that the bluetooth app should NEVER be able to do |
| 94 | ### |
| 95 | |
| 96 | # Superuser capabilities. |
Philip Cuadra | 6eee6eb | 2017-03-23 10:03:49 -0700 | [diff] [blame] | 97 | # Bluetooth requires net_{admin,raw,bind_service} and wake_alarm and block_suspend and sys_nice. |
Benjamin Gordon | 9b2e0cb | 2017-11-09 15:51:26 -0700 | [diff] [blame] | 98 | neverallow bluetooth self:global_capability_class_set ~{ net_admin net_raw net_bind_service sys_nice}; |
| 99 | neverallow bluetooth self:global_capability2_class_set ~{ wake_alarm block_suspend }; |