From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3696F1FB4 for ; Fri, 3 Feb 2023 10:24:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2BB6C433D2; Fri, 3 Feb 2023 10:24:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675419861; bh=QLV2qPiMkDC8a/Zx6mHpZOT/GuMGUF9S6IrDyqksRRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SxPwo7ks3zmRdv1HvqCBb/mIo4uuZfAPBX0KrBD/cr8+t3pg1r/ReibtdGJPVe0IE i5lFSHZgh8MJN0fsVBH2dM+wPEgBGl0aRnHQ/5nLHf+cQTALDex6+yCFXaPhUdVWvp QidvQv/Z5/BAP11SGWNPyDeCZGh4XblrqZpPOM/k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Soenke Huster , Luiz Augusto von Dentz , Ovidiu Panait Subject: [PATCH 5.15 15/20] Bluetooth: fix null ptr deref on hci_sync_conn_complete_evt Date: Fri, 3 Feb 2023 11:13:42 +0100 Message-Id: <20230203101008.636068341@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230203101007.985835823@linuxfoundation.org> References: <20230203101007.985835823@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Soenke Huster commit 3afee2118132e93e5f6fa636dfde86201a860ab3 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 Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Ovidiu Panait Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/hci_event.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4415,6 +4415,19 @@ static void hci_sync_conn_complete_evt(s 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);