aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2018-09-13 15:06:12 -0400
committerDavid S. Miller <davem@davemloft.net>2018-09-13 15:06:12 -0400
commitbffb9b51a230e61cc3870f30cc158a8a003eb55f (patch)
tree671ee18bec29c6e18ce03d8aab30527174d3fc03 /net
parent79140335ac12e71d9270dabe030274a297d8a2cf (diff)
parente6a57d22f787e73635ce0d29eef0abb77928b3e9 (diff)
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth
Johan Hedberg says: ==================== pull request: bluetooth 2018-09-13 A few Bluetooth fixes for the 4.19-rc series: - Fixed rw_semaphore leak in hci_ldisc - Fixed local Out-of-Band pairing data handling Let me know if there are any issues pulling. Thanks. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/smp.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index ae91e2d40056..3a7b0773536b 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -83,6 +83,7 @@ enum {
83 83
84struct smp_dev { 84struct smp_dev {
85 /* Secure Connections OOB data */ 85 /* Secure Connections OOB data */
86 bool local_oob;
86 u8 local_pk[64]; 87 u8 local_pk[64];
87 u8 local_rand[16]; 88 u8 local_rand[16];
88 bool debug_key; 89 bool debug_key;
@@ -599,6 +600,8 @@ int smp_generate_oob(struct hci_dev *hdev, u8 hash[16], u8 rand[16])
599 600
600 memcpy(rand, smp->local_rand, 16); 601 memcpy(rand, smp->local_rand, 16);
601 602
603 smp->local_oob = true;
604
602 return 0; 605 return 0;
603} 606}
604 607
@@ -1785,7 +1788,7 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
1785 * successfully received our local OOB data - therefore set the 1788 * successfully received our local OOB data - therefore set the
1786 * flag to indicate that local OOB is in use. 1789 * flag to indicate that local OOB is in use.
1787 */ 1790 */
1788 if (req->oob_flag == SMP_OOB_PRESENT) 1791 if (req->oob_flag == SMP_OOB_PRESENT && SMP_DEV(hdev)->local_oob)
1789 set_bit(SMP_FLAG_LOCAL_OOB, &smp->flags); 1792 set_bit(SMP_FLAG_LOCAL_OOB, &smp->flags);
1790 1793
1791 /* SMP over BR/EDR requires special treatment */ 1794 /* SMP over BR/EDR requires special treatment */
@@ -1967,7 +1970,7 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)
1967 * successfully received our local OOB data - therefore set the 1970 * successfully received our local OOB data - therefore set the
1968 * flag to indicate that local OOB is in use. 1971 * flag to indicate that local OOB is in use.
1969 */ 1972 */
1970 if (rsp->oob_flag == SMP_OOB_PRESENT) 1973 if (rsp->oob_flag == SMP_OOB_PRESENT && SMP_DEV(hdev)->local_oob)
1971 set_bit(SMP_FLAG_LOCAL_OOB, &smp->flags); 1974 set_bit(SMP_FLAG_LOCAL_OOB, &smp->flags);
1972 1975
1973 smp->prsp[0] = SMP_CMD_PAIRING_RSP; 1976 smp->prsp[0] = SMP_CMD_PAIRING_RSP;
@@ -2697,7 +2700,13 @@ static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb)
2697 * key was set/generated. 2700 * key was set/generated.
2698 */ 2701 */
2699 if (test_bit(SMP_FLAG_LOCAL_OOB, &smp->flags)) { 2702 if (test_bit(SMP_FLAG_LOCAL_OOB, &smp->flags)) {
2700 struct smp_dev *smp_dev = chan->data; 2703 struct l2cap_chan *hchan = hdev->smp_data;
2704 struct smp_dev *smp_dev;
2705
2706 if (!hchan || !hchan->data)
2707 return SMP_UNSPECIFIED;
2708
2709 smp_dev = hchan->data;
2701 2710
2702 tfm_ecdh = smp_dev->tfm_ecdh; 2711 tfm_ecdh = smp_dev->tfm_ecdh;
2703 } else { 2712 } else {
@@ -3230,6 +3239,7 @@ static struct l2cap_chan *smp_add_cid(struct hci_dev *hdev, u16 cid)
3230 return ERR_CAST(tfm_ecdh); 3239 return ERR_CAST(tfm_ecdh);
3231 } 3240 }
3232 3241
3242 smp->local_oob = false;
3233 smp->tfm_aes = tfm_aes; 3243 smp->tfm_aes = tfm_aes;
3234 smp->tfm_cmac = tfm_cmac; 3244 smp->tfm_cmac = tfm_cmac;
3235 smp->tfm_ecdh = tfm_ecdh; 3245 smp->tfm_ecdh = tfm_ecdh;