]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.0/bluetooth-align-minimum-encryption-key-size-for-le-and-br-edr-connections.patch
Linux 4.19.42
[thirdparty/kernel/stable-queue.git] / queue-5.0 / bluetooth-align-minimum-encryption-key-size-for-le-and-br-edr-connections.patch
1 From d5bb334a8e171b262e48f378bd2096c0ea458265 Mon Sep 17 00:00:00 2001
2 From: Marcel Holtmann <marcel@holtmann.org>
3 Date: Wed, 24 Apr 2019 22:19:17 +0200
4 Subject: Bluetooth: Align minimum encryption key size for LE and BR/EDR connections
5
6 From: Marcel Holtmann <marcel@holtmann.org>
7
8 commit d5bb334a8e171b262e48f378bd2096c0ea458265 upstream.
9
10 The minimum encryption key size for LE connections is 56 bits and to
11 align LE with BR/EDR, enforce 56 bits of minimum encryption key size for
12 BR/EDR connections as well.
13
14 Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
15 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
16 Cc: stable@vger.kernel.org
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18
19 ---
20 include/net/bluetooth/hci_core.h | 3 +++
21 net/bluetooth/hci_conn.c | 8 ++++++++
22 2 files changed, 11 insertions(+)
23
24 --- a/include/net/bluetooth/hci_core.h
25 +++ b/include/net/bluetooth/hci_core.h
26 @@ -190,6 +190,9 @@ struct adv_info {
27
28 #define HCI_MAX_SHORT_NAME_LENGTH 10
29
30 +/* Min encryption key size to match with SMP */
31 +#define HCI_MIN_ENC_KEY_SIZE 7
32 +
33 /* Default LE RPA expiry time, 15 minutes */
34 #define HCI_DEFAULT_RPA_TIMEOUT (15 * 60)
35
36 --- a/net/bluetooth/hci_conn.c
37 +++ b/net/bluetooth/hci_conn.c
38 @@ -1276,6 +1276,14 @@ int hci_conn_check_link_mode(struct hci_
39 !test_bit(HCI_CONN_ENCRYPT, &conn->flags))
40 return 0;
41
42 + /* The minimum encryption key size needs to be enforced by the
43 + * host stack before establishing any L2CAP connections. The
44 + * specification in theory allows a minimum of 1, but to align
45 + * BR/EDR and LE transports, a minimum of 7 is chosen.
46 + */
47 + if (conn->enc_key_size < HCI_MIN_ENC_KEY_SIZE)
48 + return 0;
49 +
50 return 1;
51 }
52