7e4c07524065fa5f4a3b4616a0dec464d3e0b13b
[openwrt/staging/nbd.git] /
1 From 52946839b2da6b841c93be0bc598686c5cfb43bd 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 497/782] 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 @@ -1272,8 +1272,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;