Skip to content

Commit 572af11

Browse files
csonsinogregkh
authored andcommitted
Bluetooth: validate BLE connection interval updates
[ Upstream commit c49a868 ] Problem: The Linux Bluetooth stack yields complete control over the BLE connection interval to the remote device. The Linux Bluetooth stack provides access to the BLE connection interval min and max values through /sys/kernel/debug/bluetooth/hci0/ conn_min_interval and /sys/kernel/debug/bluetooth/hci0/conn_max_interval. These values are used for initial BLE connections, but the remote device has the ability to request a connection parameter update. In the event that the remote side requests to change the connection interval, the Linux kernel currently only validates that the desired value is within the acceptable range in the Bluetooth specification (6 - 3200, corresponding to 7.5ms - 4000ms). There is currently no validation that the desired value requested by the remote device is within the min/max limits specified in the conn_min_interval/conn_max_interval configurations. This essentially leads to Linux yielding complete control over the connection interval to the remote device. The proposed patch adds a verification step to the connection parameter update mechanism, ensuring that the desired value is within the min/max bounds of the current connection. If the desired value is outside of the current connection min/max values, then the connection parameter update request is rejected and the negative response is returned to the remote device. Recall that the initial connection is established using the local conn_min_interval/conn_max_interval values, so this allows the Linux administrator to retain control over the BLE connection interval. The one downside that I see is that the current default Linux values for conn_min_interval and conn_max_interval typically correspond to 30ms and 50ms respectively. If this change were accepted, then it is feasible that some devices would no longer be able to negotiate to their desired connection interval values. This might be remedied by setting the default Linux conn_min_interval and conn_max_interval values to the widest supported range (6 - 3200 / 7.5ms - 4000ms). This could lead to the same behavior as the current implementation, where the remote device could request to change the connection interval value to any value that is permitted by the Bluetooth specification, and Linux would accept the desired value. Signed-off-by: Carey Sonsino <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 83e8d4c commit 572af11

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

net/bluetooth/hci_event.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5588,6 +5588,11 @@ static void hci_le_remote_conn_param_req_evt(struct hci_dev *hdev,
55885588
return send_conn_param_neg_reply(hdev, handle,
55895589
HCI_ERROR_UNKNOWN_CONN_ID);
55905590

5591+
if (min < hcon->le_conn_min_interval ||
5592+
max > hcon->le_conn_max_interval)
5593+
return send_conn_param_neg_reply(hdev, handle,
5594+
HCI_ERROR_INVALID_LL_PARAMS);
5595+
55915596
if (hci_check_conn_params(min, max, latency, timeout))
55925597
return send_conn_param_neg_reply(hdev, handle,
55935598
HCI_ERROR_INVALID_LL_PARAMS);

net/bluetooth/l2cap_core.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5297,7 +5297,14 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
52975297

52985298
memset(&rsp, 0, sizeof(rsp));
52995299

5300-
err = hci_check_conn_params(min, max, latency, to_multiplier);
5300+
if (min < hcon->le_conn_min_interval ||
5301+
max > hcon->le_conn_max_interval) {
5302+
BT_DBG("requested connection interval exceeds current bounds.");
5303+
err = -EINVAL;
5304+
} else {
5305+
err = hci_check_conn_params(min, max, latency, to_multiplier);
5306+
}
5307+
53015308
if (err)
53025309
rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_REJECTED);
53035310
else

0 commit comments

Comments
 (0)