Skip to content

Commit cad20c2

Browse files
Johan Hedbergholtmann
authored andcommitted
Bluetooth: Don't use remote address type to decide IRK persistency
There are LE devices on the market that start off by announcing their public address and then once paired switch to using private address. To be interoperable with such devices we should simply trust the fact that we're receiving an IRK from them to indicate that they may use private addresses in the future. Instead, simply tie the persistency to the bonding/no-bonding information the same way as for LTKs and CSRKs. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent 581d6fd commit cad20c2

File tree

3 files changed

+20
-33
lines changed

3 files changed

+20
-33
lines changed

include/net/bluetooth/hci_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ void mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
14581458
void mgmt_discovering(struct hci_dev *hdev, u8 discovering);
14591459
bool mgmt_powering_down(struct hci_dev *hdev);
14601460
void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, bool persistent);
1461-
void mgmt_new_irk(struct hci_dev *hdev, struct smp_irk *irk);
1461+
void mgmt_new_irk(struct hci_dev *hdev, struct smp_irk *irk, bool persistent);
14621462
void mgmt_new_csrk(struct hci_dev *hdev, struct smp_csrk *csrk,
14631463
bool persistent);
14641464
void mgmt_new_conn_param(struct hci_dev *hdev, bdaddr_t *bdaddr,

net/bluetooth/mgmt.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7873,27 +7873,13 @@ void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, bool persistent)
78737873
mgmt_event(MGMT_EV_NEW_LONG_TERM_KEY, hdev, &ev, sizeof(ev), NULL);
78747874
}
78757875

7876-
void mgmt_new_irk(struct hci_dev *hdev, struct smp_irk *irk)
7876+
void mgmt_new_irk(struct hci_dev *hdev, struct smp_irk *irk, bool persistent)
78777877
{
78787878
struct mgmt_ev_new_irk ev;
78797879

78807880
memset(&ev, 0, sizeof(ev));
78817881

7882-
/* For identity resolving keys from devices that are already
7883-
* using a public address or static random address, do not
7884-
* ask for storing this key. The identity resolving key really
7885-
* is only mandatory for devices using resolvable random
7886-
* addresses.
7887-
*
7888-
* Storing all identity resolving keys has the downside that
7889-
* they will be also loaded on next boot of they system. More
7890-
* identity resolving keys, means more time during scanning is
7891-
* needed to actually resolve these addresses.
7892-
*/
7893-
if (bacmp(&irk->rpa, BDADDR_ANY))
7894-
ev.store_hint = 0x01;
7895-
else
7896-
ev.store_hint = 0x00;
7882+
ev.store_hint = persistent;
78977883

78987884
bacpy(&ev.rpa, &irk->rpa);
78997885
bacpy(&ev.irk.addr.bdaddr, &irk->bdaddr);

net/bluetooth/smp.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,8 +1046,24 @@ static void smp_notify_keys(struct l2cap_conn *conn)
10461046
struct smp_cmd_pairing *rsp = (void *) &smp->prsp[1];
10471047
bool persistent;
10481048

1049+
if (hcon->type == ACL_LINK) {
1050+
if (hcon->key_type == HCI_LK_DEBUG_COMBINATION)
1051+
persistent = false;
1052+
else
1053+
persistent = !test_bit(HCI_CONN_FLUSH_KEY,
1054+
&hcon->flags);
1055+
} else {
1056+
/* The LTKs, IRKs and CSRKs should be persistent only if
1057+
* both sides had the bonding bit set in their
1058+
* authentication requests.
1059+
*/
1060+
persistent = !!((req->auth_req & rsp->auth_req) &
1061+
SMP_AUTH_BONDING);
1062+
}
1063+
10491064
if (smp->remote_irk) {
1050-
mgmt_new_irk(hdev, smp->remote_irk);
1065+
mgmt_new_irk(hdev, smp->remote_irk, persistent);
1066+
10511067
/* Now that user space can be considered to know the
10521068
* identity address track the connection based on it
10531069
* from now on (assuming this is an LE link).
@@ -1075,21 +1091,6 @@ static void smp_notify_keys(struct l2cap_conn *conn)
10751091
}
10761092
}
10771093

1078-
if (hcon->type == ACL_LINK) {
1079-
if (hcon->key_type == HCI_LK_DEBUG_COMBINATION)
1080-
persistent = false;
1081-
else
1082-
persistent = !test_bit(HCI_CONN_FLUSH_KEY,
1083-
&hcon->flags);
1084-
} else {
1085-
/* The LTKs and CSRKs should be persistent only if both sides
1086-
* had the bonding bit set in their authentication requests.
1087-
*/
1088-
persistent = !!((req->auth_req & rsp->auth_req) &
1089-
SMP_AUTH_BONDING);
1090-
}
1091-
1092-
10931094
if (smp->csrk) {
10941095
smp->csrk->bdaddr_type = hcon->dst_type;
10951096
bacpy(&smp->csrk->bdaddr, &hcon->dst);

0 commit comments

Comments
 (0)