From 99cec9d9a45f0abb442f46aae4f821f84ca830f4 Mon Sep 17 00:00:00 2001 From: Nitin Shivpure Date: Wed, 29 May 2019 14:02:49 +0530 Subject: [PATCH] BT: Add CAP_NET_ADMIN for Bluetooth Process Precondition: 1. A reference phone has internet connection and with BT tethering enabled. 2. DUT is in PANU role & Remote is NAP role Or 1. DUT has internet connection and with BT tethering enabled. 2. DUT is in NAP role & Remote is PANU role. Use case: 1. Connect DUT(PANU) to reference phone(NAP). 2. Internet browse is not working on DUT & Connection is dropped from DUT. Or 1. Connect remote(PANU) to Remote device(NAP). 2. Internet browse is not working on remote & Connection is dropped fro DUT. RCA: https://android-review.googlesource.com/c/kernel/common/+/936980 will cause this issue. If it's cherrypicked in codebase. TUNSETIFF ioctl call is being failed due to Operation not permitted error, Hence bt-pan interface is not being up.& connection is dropped. 06-04 23:18:06.856 6173 6699 D bt_btif : ioctl error:-1, errno:Operation not permitted TEST: 1. Connect DUT(PANU) to reference phone(NAP). 2. Internet browse is working on DUT Or 1. Connect remote(PANU) to Remote device(NAP). 2. Internet browse is working on remote. Fix: BT Process need CAP_NET_ADAMIN capability to make ioctl call to TUN driver from BT PAN module. Hence adding CAP_NET_ADMIN capablity for BT Bug: 133735703 Bug: 135707477 Change-Id: Ie461bfee7a8221404ed6b9852bd5d36758d094df --- core/jni/com_android_internal_os_Zygote.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 04d2706765660..7e3b343f6f635 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -1099,6 +1099,7 @@ static jlong CalculateCapabilities(JNIEnv* env, jint uid, jint gid, jintArray gi /* * Grant the following capabilities to the Bluetooth user: * - CAP_WAKE_ALARM + * - CAP_NET_ADMIN * - CAP_NET_RAW * - CAP_NET_BIND_SERVICE (for DHCP client functionality) * - CAP_SYS_NICE (for setting RT priority for audio-related threads) @@ -1106,6 +1107,7 @@ static jlong CalculateCapabilities(JNIEnv* env, jint uid, jint gid, jintArray gi if (multiuser_get_app_id(uid) == AID_BLUETOOTH) { capabilities |= (1LL << CAP_WAKE_ALARM); + capabilities |= (1LL << CAP_NET_ADMIN); capabilities |= (1LL << CAP_NET_RAW); capabilities |= (1LL << CAP_NET_BIND_SERVICE); capabilities |= (1LL << CAP_SYS_NICE);