Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH RFC] bluetooth: fix paring problems with 0cf3:0036 and certain devices
@ 2018-06-14 19:33 Andreas Kemnade
  2018-06-14 20:35 ` Johan Hedberg
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Kemnade @ 2018-06-14 19:33 UTC (permalink / raw)
  To: marcel, johan.hedberg, davem, linux-bluetooth; +Cc: Andreas Kemnade

This is clearly a RFC patch, things should be fixed in a cleaner way.
With the bluetooth usb adapter 0cf3:0036 (Atheros), there are pairing
problems in combination with certain remove devices. The cause is that
smp_resume_cb() gets called after SMP_CMD_IDENT_INFO arrives in the end 
of a SC pairing with numerical comparison. so that there are unexpected
packet messages in dmesg and although an ltk is known, bluetoothd
considers the device as unpaired and not even the ltk is not stored.

The patch makes the smp code be more tolerant with the order but that
does not feel like a safe thing to do.
Maybe the pairing result should be given back to userspace without the
irk related stuff.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
 net/bluetooth/smp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index a2ddae2f37d7..8023b6e6342f 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -1012,6 +1012,7 @@ static u8 smp_random(struct smp_chan *smp)
 			return SMP_UNSPECIFIED;
 
 		hci_le_start_enc(hcon, ediv, rand, stk, smp->enc_key_size);
+		smp_distribute_keys(smp);
 		hcon->enc_key_size = smp->enc_key_size;
 		set_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags);
 	} else {
@@ -2837,6 +2838,7 @@ static int smp_cmd_dhkey_check(struct l2cap_conn *conn, struct sk_buff *skb)
 
 	if (hcon->out) {
 		hci_le_start_enc(hcon, 0, 0, smp->tk, smp->enc_key_size);
+		smp_distribute_keys(smp);
 		hcon->enc_key_size = smp->enc_key_size;
 	}
 
@@ -3067,7 +3069,6 @@ static void smp_resume_cb(struct l2cap_chan *chan)
 
 	cancel_delayed_work(&smp->security_timer);
 
-	smp_distribute_keys(smp);
 }
 
 static void smp_ready_cb(struct l2cap_chan *chan)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-06-15 13:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-14 19:33 [PATCH RFC] bluetooth: fix paring problems with 0cf3:0036 and certain devices Andreas Kemnade
2018-06-14 20:35 ` Johan Hedberg
2018-06-15  5:45   ` Andreas Kemnade
2018-06-15  9:01     ` Marcel Holtmann
2018-06-15 13:30       ` Andreas Kemnade

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox