a03c7377f202286bb568aa0bb8f4cbb23742a4e1
[openwrt/staging/thess.git] /
1 From 3e2981c7e55d75dc93a2f2e9bb6be2b9704c05f5 Mon Sep 17 00:00:00 2001
2 From: Marcel Holtmann <marcel@holtmann.org>
3 Date: Wed, 22 May 2019 09:05:40 +0200
4 Subject: [PATCH] Bluetooth: Check key sizes only when Secure Simple
5 Pairing is enabled
6
7 The encryption is only mandatory to be enforced when both sides are using
8 Secure Simple Pairing and this means the key size check makes only sense
9 in that case.
10
11 On legacy Bluetooth 2.0 and earlier devices like mice the encryption was
12 optional and thus causing an issue if the key size check is not bound to
13 using Secure Simple Pairing.
14
15 Fixes: d5bb334a8e17 ("Bluetooth: Align minimum encryption key size for LE and BR/EDR connections")
16 Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
17 Cc: stable@vger.kernel.org
18 ---
19 net/bluetooth/hci_conn.c | 9 +++++++--
20 1 file changed, 7 insertions(+), 2 deletions(-)
21
22 --- a/net/bluetooth/hci_conn.c
23 +++ b/net/bluetooth/hci_conn.c
24 @@ -1285,8 +1285,13 @@ int hci_conn_check_link_mode(struct hci_
25 return 0;
26 }
27
28 - if (hci_conn_ssp_enabled(conn) &&
29 - !test_bit(HCI_CONN_ENCRYPT, &conn->flags))
30 + /* If Secure Simple Pairing is not enabled, then legacy connection
31 + * setup is used and no encryption or key sizes can be enforced.
32 + */
33 + if (!hci_conn_ssp_enabled(conn))
34 + return 1;
35 +
36 + if (!test_bit(HCI_CONN_ENCRYPT, &conn->flags))
37 return 0;
38
39 return 1;