]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.130/bluetooth-align-minimum-encryption-key-size-for-le-and-br-edr-connections.patch
Linux 4.14.130
[thirdparty/kernel/stable-queue.git] / releases / 4.14.130 / bluetooth-align-minimum-encryption-key-size-for-le-and-br-edr-connections.patch
CommitLineData
bb48b19a
GKH
1From d5bb334a8e171b262e48f378bd2096c0ea458265 Mon Sep 17 00:00:00 2001
2From: Marcel Holtmann <marcel@holtmann.org>
3Date: Wed, 24 Apr 2019 22:19:17 +0200
4Subject: Bluetooth: Align minimum encryption key size for LE and BR/EDR connections
5
6From: Marcel Holtmann <marcel@holtmann.org>
7
8commit d5bb334a8e171b262e48f378bd2096c0ea458265 upstream.
9
10The minimum encryption key size for LE connections is 56 bits and to
11align LE with BR/EDR, enforce 56 bits of minimum encryption key size for
12BR/EDR connections as well.
13
14Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
15Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
16Cc: stable@vger.kernel.org
17Signed-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@@ -178,6 +178,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@@ -1165,6 +1165,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