Skip to content

Commit 8de58bf

Browse files
neosys007gregkh
authored andcommitted
Bluetooth: btusb: validate Realtek vendor event length
[ Upstream commit df541cd ] btusb_recv_event_realtek() reads the event code at data[0] and the Realtek subevent code at data[2] before deciding whether to consume a vendor event as a coredump. For example, the two-byte event ff 00 contains a complete vendor-event header declaring zero parameters. The old classifier still reads a nonexistent third byte and can misclassify the event as a coredump if the adjacent byte is 0x34. Require the HCI event header and first parameter to be present before inspecting the Realtek subevent code. Short events continue through the normal HCI receive path, which owns their protocol validation. Fixes: 044014c ("Bluetooth: btrtl: Add Realtek devcoredump support") Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 1125255 commit 8de58bf

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/bluetooth/btusb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2671,7 +2671,9 @@ static int btusb_setup_realtek(struct hci_dev *hdev)
26712671

26722672
static int btusb_recv_event_realtek(struct hci_dev *hdev, struct sk_buff *skb)
26732673
{
2674-
if (skb->data[0] == HCI_VENDOR_PKT && skb->data[2] == RTK_SUB_EVENT_CODE_COREDUMP) {
2674+
if (skb->len >= HCI_EVENT_HDR_SIZE + 1 &&
2675+
skb->data[0] == HCI_VENDOR_PKT &&
2676+
skb->data[2] == RTK_SUB_EVENT_CODE_COREDUMP) {
26752677
struct rtk_dev_coredump_hdr hdr = {
26762678
.code = RTK_DEVCOREDUMP_CODE_MEMDUMP,
26772679
};

0 commit comments

Comments
 (0)