From: Li Qiang <liqiang01@kylinos.cn>
To: linux-bluetooth@vger.kernel.org
Cc: marcel@holtmann.org, luiz.dentz@gmail.com,
linux-kernel@vger.kernel.org, Li Qiang <liqiang01@kylinos.cn>
Subject: [PATCH 3/5] Bluetooth: hci_bcsp: validate received packet lengths
Date: Thu, 16 Jul 2026 16:47:30 +0800 [thread overview]
Message-ID: <6fb9de3e499424f7980a158798ea02b040b73b8f.1784191283.git.liqiang01@kylinos.cn> (raw)
In-Reply-To: <cover.1784191283.git.liqiang01@kylinos.cn>
The BCSP transmit path reads an HCI command header when an extension
packet has only been tested for a nonzero length. Its LE configuration
packet handler also indexes bytes through offset seven without a length
check.
Validate the complete command and LE configuration packet headers
before accessing their fields.
Signed-off-by: Li Qiang <liqiang01@kylinos.cn>
---
drivers/bluetooth/hci_bcsp.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c
index db56eead27ce..0323db21c428 100644
--- a/drivers/bluetooth/hci_bcsp.c
+++ b/drivers/bluetooth/hci_bcsp.c
@@ -194,7 +194,7 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data,
return NULL;
}
- if (hciextn && chan == 5) {
+ if (hciextn && chan == 5 && len > HCI_COMMAND_HDR_SIZE) {
__le16 opcode = ((struct hci_command_hdr *)data)->opcode;
/* Vendor specific commands */
@@ -402,6 +402,9 @@ static void bcsp_handle_le_pkt(struct hci_uart *hu)
u8 sync_pkt[4] = { 0xda, 0xdc, 0xed, 0xed };
/* spot "conf" pkts and reply with a "conf rsp" pkt */
+ if (bcsp->rx_skb->len < 8)
+ return;
+
if (bcsp->rx_skb->data[1] >> 4 == 4 && bcsp->rx_skb->data[2] == 0 &&
!memcmp(&bcsp->rx_skb->data[4], conf_pkt, 4)) {
struct sk_buff *nskb = alloc_skb(4, GFP_ATOMIC);
--
2.43.0
next prev parent reply other threads:[~2026-07-16 8:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 8:47 [PATCH 0/5] Bluetooth: harden packet and transport parsing Li Qiang
2026-07-16 8:47 ` [PATCH 1/5] Bluetooth: bfusb: validate received block boundaries Li Qiang
2026-07-16 8:47 ` [PATCH 2/5] Bluetooth: btmrvl: validate event packet lengths Li Qiang
2026-07-16 8:47 ` Li Qiang [this message]
2026-07-16 8:47 ` [PATCH 4/5] Bluetooth: hci_ldisc: reject invalid tty write lengths Li Qiang
2026-07-16 8:47 ` [PATCH 5/5] Bluetooth: hci_qca: validate controller memdump frames Li Qiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6fb9de3e499424f7980a158798ea02b040b73b8f.1784191283.git.liqiang01@kylinos.cn \
--to=liqiang01@kylinos.cn \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox