Skip to content

Commit cff10ce

Browse files
Johan Hedbergholtmann
authored andcommitted
Bluetooth: Fix incorrect removing of IRKs
The commit cad20c2 was supposed to fix handling of devices first using public addresses and then switching to RPAs after pairing. Unfortunately it missed a couple of key places in the code. 1. When evaluating which devices should be removed from the existing white list we also need to consider whether we have an IRK for them or not, i.e. a call to hci_find_irk_by_addr() is needed. 2. In smp_notify_keys() we should not be requiring the knowledge of the RPA, but should simply keep the IRK around if the other conditions require it. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Cc: stable@vger.kernel.org # 4.4+
1 parent a2342c5 commit cff10ce

File tree

2 files changed

+18
-26
lines changed

2 files changed

+18
-26
lines changed

net/bluetooth/hci_request.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -688,21 +688,29 @@ static u8 update_white_list(struct hci_request *req)
688688
* command to remove it from the controller.
689689
*/
690690
list_for_each_entry(b, &hdev->le_white_list, list) {
691-
struct hci_cp_le_del_from_white_list cp;
691+
/* If the device is neither in pend_le_conns nor
692+
* pend_le_reports then remove it from the whitelist.
693+
*/
694+
if (!hci_pend_le_action_lookup(&hdev->pend_le_conns,
695+
&b->bdaddr, b->bdaddr_type) &&
696+
!hci_pend_le_action_lookup(&hdev->pend_le_reports,
697+
&b->bdaddr, b->bdaddr_type)) {
698+
struct hci_cp_le_del_from_white_list cp;
699+
700+
cp.bdaddr_type = b->bdaddr_type;
701+
bacpy(&cp.bdaddr, &b->bdaddr);
692702

693-
if (hci_pend_le_action_lookup(&hdev->pend_le_conns,
694-
&b->bdaddr, b->bdaddr_type) ||
695-
hci_pend_le_action_lookup(&hdev->pend_le_reports,
696-
&b->bdaddr, b->bdaddr_type)) {
697-
white_list_entries++;
703+
hci_req_add(req, HCI_OP_LE_DEL_FROM_WHITE_LIST,
704+
sizeof(cp), &cp);
698705
continue;
699706
}
700707

701-
cp.bdaddr_type = b->bdaddr_type;
702-
bacpy(&cp.bdaddr, &b->bdaddr);
708+
if (hci_find_irk_by_addr(hdev, &b->bdaddr, b->bdaddr_type)) {
709+
/* White list can not be used with RPAs */
710+
return 0x00;
711+
}
703712

704-
hci_req_add(req, HCI_OP_LE_DEL_FROM_WHITE_LIST,
705-
sizeof(cp), &cp);
713+
white_list_entries++;
706714
}
707715

708716
/* Since all no longer valid white list entries have been

net/bluetooth/smp.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,22 +1072,6 @@ static void smp_notify_keys(struct l2cap_conn *conn)
10721072
hcon->dst_type = smp->remote_irk->addr_type;
10731073
queue_work(hdev->workqueue, &conn->id_addr_update_work);
10741074
}
1075-
1076-
/* When receiving an indentity resolving key for
1077-
* a remote device that does not use a resolvable
1078-
* private address, just remove the key so that
1079-
* it is possible to use the controller white
1080-
* list for scanning.
1081-
*
1082-
* Userspace will have been told to not store
1083-
* this key at this point. So it is safe to
1084-
* just remove it.
1085-
*/
1086-
if (!bacmp(&smp->remote_irk->rpa, BDADDR_ANY)) {
1087-
list_del_rcu(&smp->remote_irk->list);
1088-
kfree_rcu(smp->remote_irk, rcu);
1089-
smp->remote_irk = NULL;
1090-
}
10911075
}
10921076

10931077
if (smp->csrk) {

0 commit comments

Comments
 (0)