diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-03-20 06:54:16 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-03-20 12:14:26 -0400 |
commit | 61b1a7fbda6f761ebe16a62124578ca0779d9365 (patch) | |
tree | adbfc3fa3d25de3172044fff69a0ff50cedc146d /net/bluetooth | |
parent | 39adbffe4b16285c54016d3e64471396354ae49f (diff) |
Bluetooth: Fix address value for early disconnection events
We need to ensure that we do not send events to user space with the
identity address if we have not yet notified user space of the IRK. The
code was previously trying to handle this for the mgmt_pair_device
response (which worked well enough) but this is not the only connection
related event that might be sent to user space before pairing is
successful: another important event is Device Disconnected.
The issue can actually be solved more simply than the solution
previously used for mgmt_pair_device. Since we do have the identity
address tracked as part of the remote IRK struct we can just copy it
over from there to the hci_conn struct once we've for real sent the mgmt
event for the new IRK.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/mgmt.c | 16 | ||||
-rw-r--r-- | net/bluetooth/smp.c | 16 |
2 files changed, 11 insertions, 21 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 739887c6b286..d2d4e0d5aed0 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -2762,23 +2762,11 @@ static struct pending_cmd *find_pairing(struct hci_conn *conn) | |||
2762 | 2762 | ||
2763 | static void pairing_complete(struct pending_cmd *cmd, u8 status) | 2763 | static void pairing_complete(struct pending_cmd *cmd, u8 status) |
2764 | { | 2764 | { |
2765 | const struct mgmt_cp_pair_device *cp = cmd->param; | ||
2766 | struct mgmt_rp_pair_device rp; | 2765 | struct mgmt_rp_pair_device rp; |
2767 | struct hci_conn *conn = cmd->user_data; | 2766 | struct hci_conn *conn = cmd->user_data; |
2768 | 2767 | ||
2769 | /* If we had a pairing failure we might have already received | 2768 | bacpy(&rp.addr.bdaddr, &conn->dst); |
2770 | * the remote Identity Address Information and updated the | 2769 | rp.addr.type = link_to_bdaddr(conn->type, conn->dst_type); |
2771 | * hci_conn variables with it, however we would not yet have | ||
2772 | * notified user space of the resolved identity. Therefore, use | ||
2773 | * the address given in the Pair Device command in case the | ||
2774 | * pairing failed. | ||
2775 | */ | ||
2776 | if (status) { | ||
2777 | memcpy(&rp.addr, &cp->addr, sizeof(rp.addr)); | ||
2778 | } else { | ||
2779 | bacpy(&rp.addr.bdaddr, &conn->dst); | ||
2780 | rp.addr.type = link_to_bdaddr(conn->type, conn->dst_type); | ||
2781 | } | ||
2782 | 2770 | ||
2783 | cmd_complete(cmd->sk, cmd->index, MGMT_OP_PAIR_DEVICE, status, | 2771 | cmd_complete(cmd->sk, cmd->index, MGMT_OP_PAIR_DEVICE, status, |
2784 | &rp, sizeof(rp)); | 2772 | &rp, sizeof(rp)); |
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 13919ff82e05..8d618e4654a5 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -1058,12 +1058,6 @@ static int smp_cmd_ident_addr_info(struct l2cap_conn *conn, | |||
1058 | smp->remote_irk = hci_add_irk(conn->hcon->hdev, &smp->id_addr, | 1058 | smp->remote_irk = hci_add_irk(conn->hcon->hdev, &smp->id_addr, |
1059 | smp->id_addr_type, smp->irk, &rpa); | 1059 | smp->id_addr_type, smp->irk, &rpa); |
1060 | 1060 | ||
1061 | /* Track the connection based on the Identity Address from now on */ | ||
1062 | bacpy(&hcon->dst, &smp->id_addr); | ||
1063 | hcon->dst_type = smp->id_addr_type; | ||
1064 | |||
1065 | l2cap_conn_update_id_addr(hcon); | ||
1066 | |||
1067 | smp_distribute_keys(conn); | 1061 | smp_distribute_keys(conn); |
1068 | 1062 | ||
1069 | return 0; | 1063 | return 0; |
@@ -1214,8 +1208,16 @@ static void smp_notify_keys(struct l2cap_conn *conn) | |||
1214 | struct smp_cmd_pairing *rsp = (void *) &smp->prsp[1]; | 1208 | struct smp_cmd_pairing *rsp = (void *) &smp->prsp[1]; |
1215 | bool persistent; | 1209 | bool persistent; |
1216 | 1210 | ||
1217 | if (smp->remote_irk) | 1211 | if (smp->remote_irk) { |
1218 | mgmt_new_irk(hdev, smp->remote_irk); | 1212 | mgmt_new_irk(hdev, smp->remote_irk); |
1213 | /* Now that user space can be considered to know the | ||
1214 | * identity address track the connection based on it | ||
1215 | * from now on. | ||
1216 | */ | ||
1217 | bacpy(&hcon->dst, &smp->remote_irk->bdaddr); | ||
1218 | hcon->dst_type = smp->remote_irk->addr_type; | ||
1219 | l2cap_conn_update_id_addr(hcon); | ||
1220 | } | ||
1219 | 1221 | ||
1220 | /* The LTKs and CSRKs should be persistent only if both sides | 1222 | /* The LTKs and CSRKs should be persistent only if both sides |
1221 | * had the bonding bit set in their authentication requests. | 1223 | * had the bonding bit set in their authentication requests. |