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 7026923F8F0; Sun, 24 Nov 2024 13:53:34 +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=1732456414; cv=none; b=OxOHyre1QMxVqx+9GTqRZ2qusbFnzJGXpV5sYGuSibkukSc8lM9R/VTuvFUnju9FaCJkonKn11RQshoSOHD5lK/o1y5Np52wWD9qVfILKoEtj+J4xqyi1xBkv7dkw7h2c9jKZX4Lsd7Gd7auUR9nAIJZZ9ubhauTkWUBU3uPKT4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732456414; c=relaxed/simple; bh=0uDcQpo6v+Is86M6VrKPYJFAgI8xg3ek3Rdyj4heSq0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dwI1VsEabEInEga0nQQwoB/N0YmZ+Bdv33r8+fLS/Swxji3fDocq/EHSXGd9PdtAmV1S4yD6xpW6ceu1E0yzC2bD27YcTiEduofE2237mBjjgkj8VIWKtGfr6lDd9C3u8ttxzkcW51wxrkoUHzprfLWGfBt+xcY4oocU2ALunME= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Who4Yb16; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Who4Yb16" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C956C4CECC; Sun, 24 Nov 2024 13:53:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732456414; bh=0uDcQpo6v+Is86M6VrKPYJFAgI8xg3ek3Rdyj4heSq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Who4Yb16XNViPzO923N9yWFf/UhN5P6VpOkFIAKlWlcsEq/+S4mJzSn67QZe0qO0d eD2Zng/AvxmPlqTuXl5YU+GTzrC0v5bEyGugaOmc8V9wuQnKTT0/ax5nbUaMw33srz v3/O2cDTFj6zBH7d4diZ2VkBtEbprnWKAzNABpjHiGn30PSgeC97fpRifXD7FU72VH vutEYMEPiB69rRiDdMCiWiMgZY6uuWBqSTWPndHNOrEhHdUR6At/SKWZQnw56nOcNb wl+BBNFwROnC22rvWrGWRGrCN4KKOOE7dC/svxtudyy35eayZbfBwNNjaIO4jIPExS Kj+/xUSlAG3pg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Luiz Augusto von Dentz , syzbot+6ea290ba76d8c1eb1ac2@syzkaller.appspotmail.com, Sasha Levin , marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com, linux-bluetooth@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 32/36] Bluetooth: hci_core: Fix not checking skb length on hci_acldata_packet Date: Sun, 24 Nov 2024 08:51:46 -0500 Message-ID: <20241124135219.3349183-32-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241124135219.3349183-1-sashal@kernel.org> References: <20241124135219.3349183-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.173 Content-Transfer-Encoding: 8bit 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