Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame] | 1 | # bluetooth app |
| 2 | |
| 3 | typeattribute bluetooth coredomain, mlstrustedsubject; |
| 4 | |
| 5 | app_domain(bluetooth) |
| 6 | net_domain(bluetooth) |
| 7 | |
| 8 | # Socket creation under /data/misc/bluedroid. |
| 9 | type_transition bluetooth bluetooth_data_file:sock_file bluetooth_socket; |
| 10 | |
| 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; |
| 18 | allow bluetooth bluetooth_data_file:notdevfile_class_set create_file_perms; |
| 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 | |
| 25 | allow bluetooth self:global_capability_class_set net_admin; |
| 26 | allow bluetooth self:global_capability2_class_set wake_alarm; |
| 27 | |
| 28 | # tethering |
| 29 | allow bluetooth self:packet_socket create_socket_perms_no_ioctl; |
| 30 | allow bluetooth self:global_capability_class_set { net_admin net_raw net_bind_service }; |
| 31 | allow bluetooth self:tun_socket create_socket_perms_no_ioctl; |
| 32 | allow bluetooth tun_device:chr_file rw_file_perms; |
| 33 | allowxperm bluetooth tun_device:chr_file ioctl { TUNGETIFF TUNSETIFF }; |
| 34 | allow bluetooth efs_file:dir search; |
| 35 | |
| 36 | # allow Bluetooth to access uhid device for HID profile |
| 37 | allow bluetooth uhid_device:chr_file rw_file_perms; |
| 38 | |
| 39 | # proc access. |
| 40 | allow bluetooth proc_bluetooth_writable:file rw_file_perms; |
| 41 | |
| 42 | # Allow write access to bluetooth specific properties |
| 43 | set_prop(bluetooth, binder_cache_bluetooth_server_prop); |
| 44 | neverallow { domain -bluetooth -init } |
| 45 | binder_cache_bluetooth_server_prop:property_service set; |
| 46 | set_prop(bluetooth, bluetooth_a2dp_offload_prop) |
| 47 | set_prop(bluetooth, bluetooth_audio_hal_prop) |
| 48 | set_prop(bluetooth, bluetooth_prop) |
| 49 | set_prop(bluetooth, exported_bluetooth_prop) |
| 50 | set_prop(bluetooth, pan_result_prop) |
| 51 | |
| 52 | allow bluetooth audioserver_service:service_manager find; |
| 53 | allow bluetooth bluetooth_service:service_manager find; |
| 54 | allow bluetooth drmserver_service:service_manager find; |
| 55 | allow bluetooth mediaserver_service:service_manager find; |
| 56 | allow bluetooth radio_service:service_manager find; |
| 57 | allow bluetooth app_api_service:service_manager find; |
| 58 | allow bluetooth system_api_service:service_manager find; |
| 59 | allow bluetooth network_stack_service:service_manager find; |
| 60 | allow bluetooth system_suspend_control_service:service_manager find; |
| 61 | |
| 62 | # already open bugreport file descriptors may be shared with |
| 63 | # the bluetooth process, from a file in |
| 64 | # /data/data/com.android.shell/files/bugreports/bugreport-*. |
| 65 | allow bluetooth shell_data_file:file read; |
| 66 | |
| 67 | # Bluetooth audio needs RT scheduling to meet deadlines, allow sys_nice |
| 68 | allow bluetooth self:global_capability_class_set sys_nice; |
| 69 | |
| 70 | hal_client_domain(bluetooth, hal_bluetooth) |
| 71 | hal_client_domain(bluetooth, hal_telephony) |
| 72 | |
| 73 | # Bluetooth A2DP offload requires binding with audio HAL |
| 74 | hal_client_domain(bluetooth, hal_audio) |
| 75 | |
| 76 | read_runtime_log_tags(bluetooth) |
| 77 | |
| 78 | ### |
| 79 | ### Neverallow rules |
| 80 | ### |
| 81 | ### These are things that the bluetooth app should NEVER be able to do |
| 82 | ### |
| 83 | |
| 84 | # Superuser capabilities. |
| 85 | # Bluetooth requires net_{admin,raw,bind_service} and wake_alarm and block_suspend and sys_nice. |
| 86 | neverallow bluetooth self:global_capability_class_set ~{ net_admin net_raw net_bind_service sys_nice}; |
| 87 | neverallow bluetooth self:global_capability2_class_set ~{ wake_alarm block_suspend }; |