]> git.baikalelectronics.ru Git - kernel.git/commitdiff
Bluetooth: fix null ptr deref on hci_sync_conn_complete_evt
authorSoenke Huster <soenke.huster@eknoes.de>
Fri, 14 Jan 2022 16:44:02 +0000 (17:44 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Feb 2023 06:52:51 +0000 (07:52 +0100)
commit c1ea0909d5b368a9db53bc1ecb24c918952b6ac0 upstream.

This event is just specified for SCO and eSCO link types.
On the reception of a HCI_Synchronous_Connection_Complete for a BDADDR
of an existing LE connection, LE link type and a status that triggers the
second case of the packet processing a NULL pointer dereference happens,
as conn->link is NULL.

Signed-off-by: Soenke Huster <soenke.huster@eknoes.de>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Ovidiu Panait <ovidiu.panait@eng.windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/bluetooth/hci_event.c

index ff6625493c9f8cdca3cb3d25f9004739f4d99296..84b430986b1de89377c874fbdc1703071cba3d44 100644 (file)
@@ -4177,6 +4177,19 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev,
        struct hci_ev_sync_conn_complete *ev = (void *) skb->data;
        struct hci_conn *conn;
 
+       switch (ev->link_type) {
+       case SCO_LINK:
+       case ESCO_LINK:
+               break;
+       default:
+               /* As per Core 5.3 Vol 4 Part E 7.7.35 (p.2219), Link_Type
+                * for HCI_Synchronous_Connection_Complete is limited to
+                * either SCO or eSCO
+                */
+               bt_dev_err(hdev, "Ignoring connect complete event for invalid link type");
+               return;
+       }
+
        BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
 
        hci_dev_lock(hdev);