Skip to content

Commit 5c5f1f6

Browse files
rpthibeaultVudentz
authored andcommitted
Bluetooth: hci_event: validate skb length for unknown CC opcode
In hci_cmd_complete_evt(), if the command complete event has an unknown opcode, we assume the first byte of the remaining skb->data contains the return status. However, parameter data has previously been pulled in hci_event_func(), which may leave the skb empty. If so, using skb->data[0] for the return status uses un-init memory. The fix is to check skb->len before using skb->data. Reported-by: syzbot+a9a4bedfca6aa9d7fa24@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=a9a4bedfca6aa9d7fa24 Tested-by: syzbot+a9a4bedfca6aa9d7fa24@syzkaller.appspotmail.com Fixes: afcb336 ("Bluetooth: hci_event: Fix vendor (unknown) opcode status handling") Signed-off-by: Raphael Pinsonneault-Thibeault <rpthibeault@gmail.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent e576349 commit 5c5f1f6

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

net/bluetooth/hci_event.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4218,6 +4218,13 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, void *data,
42184218
}
42194219

42204220
if (i == ARRAY_SIZE(hci_cc_table)) {
4221+
if (!skb->len) {
4222+
bt_dev_err(hdev, "Unexpected cc 0x%4.4x with no status",
4223+
*opcode);
4224+
*status = HCI_ERROR_UNSPECIFIED;
4225+
return;
4226+
}
4227+
42214228
/* Unknown opcode, assume byte 0 contains the status, so
42224229
* that e.g. __hci_cmd_sync() properly returns errors
42234230
* for vendor specific commands send by HCI drivers.

0 commit comments

Comments
 (0)