Skip to content

Commit

Permalink
Bluetooth: Host: SSP: Correct BR bonding type
Browse files Browse the repository at this point in the history
Currently, the bonding type of Authentication
_Requirements parameter is always `Dedicated
Bonding` if the device is pairing initiator.

But if the bonding is performed during
connection setup or channel establishment as
a precursor to accessing a service, the
bonding type should be `General bonding`.

Add a flag BT_CONN_BR_GENERAL_BONDING.
Set the flag if the bonding is performed in
the L2CAP_BR/RFCOMM channel establishment.

Set bonding type depends on the flag when
receiving IO cap request.

Signed-off-by: Lyle Zhu <[email protected]>
  • Loading branch information
lylezhu2012 authored and aescolar committed Oct 2, 2024
1 parent 1005a73 commit 08ceb14
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
7 changes: 7 additions & 0 deletions subsys/bluetooth/host/classic/l2cap_br.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,13 @@ l2cap_br_conn_security(struct bt_l2cap_chan *chan, const uint16_t psm)
* since service/profile requires that.
*/
if (check == 0) {
/*
* General Bonding refers to the process of performing bonding
* during connection setup or channel establishment procedures
* as a precursor to accessing a service.
* For current case, it is dedicated bonding.
*/
atomic_set_bit(chan->conn->flags, BT_CONN_BR_GENERAL_BONDING);
return L2CAP_CONN_SECURITY_PENDING;
}

Expand Down
7 changes: 7 additions & 0 deletions subsys/bluetooth/host/classic/rfcomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,13 @@ static enum security_result rfcomm_dlc_security(struct bt_rfcomm_dlc *dlc)
}

if (!bt_conn_set_security(conn, dlc->required_sec_level)) {
/*
* General Bonding refers to the process of performing bonding
* during connection setup or channel establishment procedures
* as a precursor to accessing a service.
* For current case, it is dedicated bonding.
*/
atomic_set_bit(conn->flags, BT_CONN_BR_GENERAL_BONDING);
/* If Security elevation is initiated or in progress */
return RFCOMM_SECURITY_PENDING;
}
Expand Down
12 changes: 10 additions & 2 deletions subsys/bluetooth/host/classic/ssp.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,17 @@ void bt_hci_io_capa_req(struct net_buf *buf)
*/
if (atomic_test_bit(conn->flags, BT_CONN_BR_PAIRING_INITIATOR)) {
if (get_io_capa() != BT_IO_NO_INPUT_OUTPUT) {
auth = BT_HCI_DEDICATED_BONDING_MITM;
if (atomic_test_bit(conn->flags, BT_CONN_BR_GENERAL_BONDING)) {
auth = BT_HCI_GENERAL_BONDING_MITM;
} else {
auth = BT_HCI_DEDICATED_BONDING_MITM;
}
} else {
auth = BT_HCI_DEDICATED_BONDING;
if (atomic_test_bit(conn->flags, BT_CONN_BR_GENERAL_BONDING)) {
auth = BT_HCI_GENERAL_BONDING;
} else {
auth = BT_HCI_DEDICATED_BONDING;
}
}
} else {
auth = ssp_get_auth(conn);
Expand Down
1 change: 1 addition & 0 deletions subsys/bluetooth/host/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -2612,6 +2612,7 @@ static void reset_pairing(struct bt_conn *conn)
atomic_clear_bit(conn->flags, BT_CONN_BR_PAIRING);
atomic_clear_bit(conn->flags, BT_CONN_BR_PAIRING_INITIATOR);
atomic_clear_bit(conn->flags, BT_CONN_BR_LEGACY_SECURE);
atomic_clear_bit(conn->flags, BT_CONN_BR_GENERAL_BONDING);
}
#endif /* CONFIG_BT_CLASSIC */

Expand Down
1 change: 1 addition & 0 deletions subsys/bluetooth/host/conn_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ enum {
BT_CONN_USER, /* user I/O when pairing */
BT_CONN_BR_PAIRING, /* BR connection in pairing context */
BT_CONN_BR_NOBOND, /* SSP no bond pairing tracker */
BT_CONN_BR_GENERAL_BONDING, /* BR general bonding */
BT_CONN_BR_PAIRING_INITIATOR, /* local host starts authentication */
BT_CONN_CLEANUP, /* Disconnected, pending cleanup */
BT_CONN_AUTO_INIT_PROCEDURES_DONE, /* Auto-initiated procedures have run */
Expand Down

0 comments on commit 08ceb14

Please sign in to comment.