Skip to content

Commit dcd8bcb

Browse files
lylezhu2012kartben
authored andcommitted
Bluetooth: SSP: Reply a negative rsp if binding flags are mismatched
If the remote is in bondable mode, but the local is in non-bondable mode, the local host shall respond to an IO capability request with a negative response. In current implementation, it does not check the bonding flags of the both sides are consistent. Fix the issue by checking the consistency of bonding flags of the both sides. If they are not consistent, send a negative IO capability response with the reason pairing not allowed. Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
1 parent 1408614 commit dcd8bcb

File tree

1 file changed

+26
-8
lines changed
  • subsys/bluetooth/host/classic

1 file changed

+26
-8
lines changed

subsys/bluetooth/host/classic/ssp.c

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -683,14 +683,6 @@ void bt_hci_io_capa_req(struct net_buf *buf)
683683
}
684684
#endif
685685

686-
resp_buf = bt_hci_cmd_create(BT_HCI_OP_IO_CAPABILITY_REPLY,
687-
sizeof(*cp));
688-
if (!resp_buf) {
689-
LOG_ERR("Out of command buffers");
690-
bt_conn_unref(conn);
691-
return;
692-
}
693-
694686
/*
695687
* Set authentication requirements when acting as pairing initiator to
696688
* 'dedicated bond' with MITM protection set if local IO capa
@@ -718,13 +710,39 @@ void bt_hci_io_capa_req(struct net_buf *buf)
718710
}
719711
} else {
720712
auth = ssp_get_auth(conn);
713+
714+
/*
715+
* Core v6.0, Vol 3, Part C, Section 4.3.1 Non-bondable mode
716+
* When a Bluetooth device is in non-bondable mode it shall not accept a
717+
* pairing request that results in bonding. Devices in non-bondable mode
718+
* may accept connections that do not request or require bonding.
719+
*
720+
* If the peer supports bonding mode, but the local is in non-bondable
721+
* mode, it will send a negative response with error code
722+
* `BT_HCI_ERR_PAIRING_NOT_ALLOWED`.
723+
*/
724+
if (!atomic_test_bit(conn->flags, BT_CONN_BR_BONDABLE) &&
725+
(conn->br.remote_auth > BT_HCI_NO_BONDING_MITM)) {
726+
LOG_WRN("Invalid remote bonding requirements");
727+
io_capa_neg_reply(&evt->bdaddr,
728+
BT_HCI_ERR_PAIRING_NOT_ALLOWED);
729+
bt_conn_unref(conn);
730+
return;
731+
}
721732
}
722733

723734
if (!atomic_test_bit(conn->flags, BT_CONN_BR_BONDABLE)) {
724735
/* If bondable is false, clear bonding flag. */
725736
auth = BT_HCI_SET_NO_BONDING(auth);
726737
}
727738

739+
resp_buf = bt_hci_cmd_create(BT_HCI_OP_IO_CAPABILITY_REPLY, sizeof(*cp));
740+
if (!resp_buf) {
741+
LOG_ERR("Out of command buffers");
742+
bt_conn_unref(conn);
743+
return;
744+
}
745+
728746
cp = net_buf_add(resp_buf, sizeof(*cp));
729747
bt_addr_copy(&cp->bdaddr, &evt->bdaddr);
730748
cp->capability = get_io_capa();

0 commit comments

Comments
 (0)