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 EDDDF223E69; Thu, 12 Dec 2024 17:09:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734023356; cv=none; b=EduhbYliOiQQ5sHFWNuewDEPwJL9Ld+a51OzuazbYksU5odhlBeQhNq7RGLmzWCzrR/dLWdSgz+FznK4O74nU864SsmuqGcyK8rhwZhvXgnVijnbJMBwJX62u0nj4l+fza1Ge1PR6ErUu5rTYUWtxuWb2Va6WQCjE/cLVWaEPv8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734023356; c=relaxed/simple; bh=JHqdMTP68qDUsCSDbKY7yHKdKO8tyAYdnbToAZlyFqA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dd/VW87hb8/V8D2qSQQ6G93dBYHE7Ln69KDH3VDuKK8FgW+FYcvGP2rVPYmm/BKNJWOJK/wQPNVSbRlkPBoHNSNMcY2dQgwZ8uOLc/fnn2sAZhSE6cb1rIxPMjKrzKd7RFso/fGYM4V4hXAicAPfgLGKvXLaQyFH2C7RoBNp8pc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=W7q98cTn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="W7q98cTn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79127C4CECE; Thu, 12 Dec 2024 17:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1734023355; bh=JHqdMTP68qDUsCSDbKY7yHKdKO8tyAYdnbToAZlyFqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W7q98cTnrUrxIrp424XXNH2LkLOO1FqXmwZNQQW0nxvQGGKwrQTrVxJQroQx+9LHv kcqRCaYogM7yv98hZkdG7ph553EgvZzzcAgF1BzsgQilswabRpKq1f2cjTvNE/kq08 msVsIQKREueXp6rL4ZVe4873B6K1ls2ROrfTKIug= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+6ea290ba76d8c1eb1ac2@syzkaller.appspotmail.com, Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 5.15 507/565] Bluetooth: hci_core: Fix not checking skb length on hci_acldata_packet Date: Thu, 12 Dec 2024 16:01:42 +0100 Message-ID: <20241212144331.811553964@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241212144311.432886635@linuxfoundation.org> References: <20241212144311.432886635@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Luiz Augusto von Dentz [ Upstream commit 3fe288a8214e7dd784d1f9b7c9e448244d316b47 ] This fixes not checking if skb really contains an ACL header otherwise the code may attempt to access some uninitilized/invalid memory past the valid skb->data. Reported-by: syzbot+6ea290ba76d8c1eb1ac2@syzkaller.appspotmail.com Tested-by: syzbot+6ea290ba76d8c1eb1ac2@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=6ea290ba76d8c1eb1ac2 Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/hci_core.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 7dff3f1a2a9eb..7ed5d6e47e4f3 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -4943,18 +4943,22 @@ static void hci_tx_work(struct work_struct *work) /* ACL data packet */ static void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb) { - struct hci_acl_hdr *hdr = (void *) skb->data; + struct hci_acl_hdr *hdr; struct hci_conn *conn; __u16 handle, flags; - skb_pull(skb, HCI_ACL_HDR_SIZE); + hdr = skb_pull_data(skb, sizeof(*hdr)); + if (!hdr) { + bt_dev_err(hdev, "ACL packet too small"); + goto drop; + } handle = __le16_to_cpu(hdr->handle); flags = hci_flags(handle); handle = hci_handle(handle); - BT_DBG("%s len %d handle 0x%4.4x flags 0x%4.4x", hdev->name, skb->len, - handle, flags); + bt_dev_dbg(hdev, "len %d handle 0x%4.4x flags 0x%4.4x", skb->len, + handle, flags); hdev->stat.acl_rx++; @@ -4973,6 +4977,7 @@ static void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb) handle); } +drop: kfree_skb(skb); } -- 2.43.0