]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: Add new quirk for broken read key length on ATS2851
authorVinicius Peixoto <nukelet64@gmail.com>
Tue, 27 Feb 2024 01:43:26 +0000 (22:43 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 13 Apr 2024 11:07:33 +0000 (13:07 +0200)
[ Upstream commit 48201a3b3f398be6a01f78a14b18bd5d31c47458 ]

The ATS2851 controller erroneously reports support for the "Read
Encryption Key Length" HCI command. This makes it unable to connect
to any devices, since this command is issued by the kernel during the
connection process in response to an "Encryption Change" HCI event.

Add a new quirk (HCI_QUIRK_BROKEN_ENC_KEY_SIZE) to hint that the command
is unsupported, preventing it from interrupting the connection process.

This is the error log from btmon before this patch:

> HCI Event: Encryption Change (0x08) plen 4
        Status: Success (0x00)
        Handle: 2048 Address: ...
        Encryption: Enabled with E0 (0x01)
< HCI Command: Read Encryption Key Size (0x05|0x0008) plen 2
        Handle: 2048 Address: ...
> HCI Event: Command Status (0x0f) plen 4
      Read Encryption Key Size (0x05|0x0008) ncmd 1
        Status: Unknown HCI Command (0x01)

Signed-off-by: Vinicius Peixoto <nukelet64@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/bluetooth/btusb.c
include/net/bluetooth/hci.h
net/bluetooth/hci_event.c

index 8dbdc51976e7b357a4b9333dc45c2204f44cf5b7..1976593bc804e10c25cf6d114d9dccb24d9740c8 100644 (file)
@@ -4477,6 +4477,7 @@ static int btusb_probe(struct usb_interface *intf,
                set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
                set_bit(HCI_QUIRK_BROKEN_SET_RPA_TIMEOUT, &hdev->quirks);
                set_bit(HCI_QUIRK_BROKEN_EXT_SCAN, &hdev->quirks);
+               set_bit(HCI_QUIRK_BROKEN_READ_ENC_KEY_SIZE, &hdev->quirks);
        }
 
        if (!reset)
index 03e68a8e229f5f7262e8e7e8cc3019757f8ad43b..35c5f75a3a5ee2f5d95c71384ec5313419ec2a16 100644 (file)
@@ -339,6 +339,14 @@ enum {
         * during the hdev->setup vendor callback.
         */
        HCI_QUIRK_BROKEN_LE_CODED,
+
+       /*
+        * When this quirk is set, the HCI_OP_READ_ENC_KEY_SIZE command is
+        * skipped during an HCI_EV_ENCRYPT_CHANGE event. This is required
+        * for Actions Semiconductor ATS2851 based controllers, which erroneously
+        * claim to support it.
+        */
+       HCI_QUIRK_BROKEN_READ_ENC_KEY_SIZE,
 };
 
 /* HCI device flags */
index bb0e5902a3e607bc9a9e2b18ec5fe7ff73861825..80e71ce32f09faf032236d56b866b6a707f38f00 100644 (file)
@@ -3679,7 +3679,8 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, void *data,
                 * controller really supports it. If it doesn't, assume
                 * the default size (16).
                 */
-               if (!(hdev->commands[20] & 0x10)) {
+               if (!(hdev->commands[20] & 0x10) ||
+                   test_bit(HCI_QUIRK_BROKEN_READ_ENC_KEY_SIZE, &hdev->quirks)) {
                        conn->enc_key_size = HCI_LINK_KEY_SIZE;
                        goto notify;
                }