Skip to contentSkip to conversation

Bluetooth: Check key sizes only when Secure Simple Pairing is enabled

RFC In review Marcel Holtmann 3 participants 3 messages May 22, 2019 – Jun 4, 2019

Subsystems (2)
lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

RFC 1/1 Bluetooth: Check key sizes only when Secure Simple Pairing is enabled

The encryption is only mandatory to be enforced when both sides are using Secure Simple Pairing and this means the key size check makes only sense in that case.

On legacy Bluetooth 2.0 and earlier devices like mice the encryption was optional and thus causing an issue if the key size check is not bound to using Secure Simple Pairing.

Fixes d5bb334a8e17 ("Bluetooth: Align minimum encryption key size for LE and BR/EDR connections")
---
 net/bluetooth/hci_conn.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
net/bluetooth/hci_conn.c +7 -2
index 3cf0764d5793..7516cdde3373 100644
@@ -1272,8 +1272,13 @@ int hci_conn_check_link_mode(struct hci_conn *conn)
 			return 0;
 	}
 
-	if (hci_conn_ssp_enabled(conn) &&
-	    !test_bit(HCI_CONN_ENCRYPT, &conn->flags))
+	/* If Secure Simple Pairing is not enabled, then legacy connection
+	 * setup is used and no encryption or key sizes can be enforced.
+	 */
+	if (!hci_conn_ssp_enabled(conn))
+		return 1;
+
+	if (!test_bit(HCI_CONN_ENCRYPT, &conn->flags))
 		return 0;
 
 	/* The minimum encryption key size needs to be enforced by the
Signature · 1 line
2.20.1
Tested-by on v1 1/1
#1 lore raw
Quoted 5 lines · Marcel Holtmann

The encryption is only mandatory to be enforced when both sides are using Secure Simple Pairing and this means the key size check makes only sense in that case.

Quoted 7 lines

On legacy Bluetooth 2.0 and earlier devices like mice the encryption was optional and thus causing an issue if the key size check is not bound to using Secure Simple Pairing.

Fixes d5bb334a8e17 ("Bluetooth: Align minimum encryption key size for LE and BR/EDR connections")
Quoted 27 lines
---
 net/bluetooth/hci_conn.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
net/bluetooth/hci_conn.c +7 -3
index 3cf0764d5793..7516cdde3373 100644
@@ -1272,8 +1272,13 @@ int hci_conn_check_link_mode(struct hci_conn *conn)
                        return 0;
        }
 
-       if (hci_conn_ssp_enabled(conn) &&
-           !test_bit(HCI_CONN_ENCRYPT, &conn->flags))
+       /* If Secure Simple Pairing is not enabled, then legacy connection
+        * setup is used and no encryption or key sizes can be enforced.
+        */
+       if (!hci_conn_ssp_enabled(conn))
+               return 1;
+
+       if (!test_bit(HCI_CONN_ENCRYPT, &conn->flags))
                return 0;
 
        /* The minimum encryption key size needs to be enforced by the
--

2.20.1

#2 lore raw
Quoted 14 lines · Vasily Khoruzhick

On Wed, May 22, 2019 at 12:05 AM Marcel Holtmann <[email protected]

Quoted 13 lines

wrote:
The encryption is only mandatory to be enforced when both sides are using
Secure Simple Pairing and this means the key size check makes only sense
in that case.

On legacy Bluetooth 2.0 and earlier devices like mice the encryption was
optional and thus causing an issue if the key size check is not bound to
using Secure Simple Pairing.

Quoted 6 lines
Quoted 4 lines
Fixes d5bb334a8e17 ("Bluetooth: Align minimum encryption key size

for LE and BR/EDR connections")

I've asked for this patch to be included in the current Fedora release:
https://lists.fedoraproject.org/archives/list/[email protected]/thread/YE5OGFZRDJL2TFJK3RWU7AAWV3PFRMNB/

Hopefully, that means that it gets a bit more testing and gets merged upstream.

Cheers