Skip to content

Commit 66d8e83

Browse files
holtmannJohan Hedberg
authored andcommitted
Bluetooth: Fix white list handling with resolvable private addresses
Devices using resolvable private addresses are required to provide an identity resolving key. These devices can not be found using the current controller white list support. This means if the kernel knows about any devices with an identity resolving key, the white list filtering must be disabled. However so far the kernel kept identity resolving keys around even for devices that are not using resolvable private addresses. The notification to userspace clearly hints to not store the key and so it is best to just remove the key from the kernel as well at that point. With this it easy now to detect when using the white list is possible or when kernel side resolving of addresses is required. Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
1 parent 8540f6c commit 66d8e83

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

net/bluetooth/hci_core.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5468,6 +5468,12 @@ static u8 update_white_list(struct hci_request *req)
54685468
return 0x00;
54695469
}
54705470

5471+
if (hci_find_irk_by_addr(hdev, &params->addr,
5472+
params->addr_type)) {
5473+
/* White list can not be used with RPAs */
5474+
return 0x00;
5475+
}
5476+
54715477
white_list_entries++;
54725478
add_to_white_list(req, params);
54735479
}
@@ -5486,6 +5492,12 @@ static u8 update_white_list(struct hci_request *req)
54865492
return 0x00;
54875493
}
54885494

5495+
if (hci_find_irk_by_addr(hdev, &params->addr,
5496+
params->addr_type)) {
5497+
/* White list can not be used with RPAs */
5498+
return 0x00;
5499+
}
5500+
54895501
white_list_entries++;
54905502
add_to_white_list(req, params);
54915503
}

net/bluetooth/smp.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,22 @@ static void smp_notify_keys(struct l2cap_conn *conn)
12911291
bacpy(&hcon->dst, &smp->remote_irk->bdaddr);
12921292
hcon->dst_type = smp->remote_irk->addr_type;
12931293
l2cap_conn_update_id_addr(hcon);
1294+
1295+
/* When receiving an indentity resolving key for
1296+
* a remote device that does not use a resolvable
1297+
* private address, just remove the key so that
1298+
* it is possible to use the controller white
1299+
* list for scanning.
1300+
*
1301+
* Userspace will have been told to not store
1302+
* this key at this point. So it is safe to
1303+
* just remove it.
1304+
*/
1305+
if (!bacmp(&smp->remote_irk->rpa, BDADDR_ANY)) {
1306+
list_del(&smp->remote_irk->list);
1307+
kfree(smp->remote_irk);
1308+
smp->remote_irk = NULL;
1309+
}
12941310
}
12951311

12961312
/* The LTKs and CSRKs should be persistent only if both sides

0 commit comments

Comments
 (0)