Skip to content

Commit 3fe288a

Browse files
committed
Bluetooth: hci_core: Fix not checking skb length on hci_acldata_packet
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: [email protected] Tested-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=6ea290ba76d8c1eb1ac2 Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent c135a5b commit 3fe288a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

net/bluetooth/hci_core.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3771,18 +3771,22 @@ static void hci_tx_work(struct work_struct *work)
37713771
/* ACL data packet */
37723772
static void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb)
37733773
{
3774-
struct hci_acl_hdr *hdr = (void *) skb->data;
3774+
struct hci_acl_hdr *hdr;
37753775
struct hci_conn *conn;
37763776
__u16 handle, flags;
37773777

3778-
skb_pull(skb, HCI_ACL_HDR_SIZE);
3778+
hdr = skb_pull_data(skb, sizeof(*hdr));
3779+
if (!hdr) {
3780+
bt_dev_err(hdev, "ACL packet too small");
3781+
goto drop;
3782+
}
37793783

37803784
handle = __le16_to_cpu(hdr->handle);
37813785
flags = hci_flags(handle);
37823786
handle = hci_handle(handle);
37833787

3784-
BT_DBG("%s len %d handle 0x%4.4x flags 0x%4.4x", hdev->name, skb->len,
3785-
handle, flags);
3788+
bt_dev_dbg(hdev, "len %d handle 0x%4.4x flags 0x%4.4x", skb->len,
3789+
handle, flags);
37863790

37873791
hdev->stat.acl_rx++;
37883792

@@ -3803,6 +3807,7 @@ static void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb)
38033807
handle);
38043808
}
38053809

3810+
drop:
38063811
kfree_skb(skb);
38073812
}
38083813

0 commit comments

Comments
 (0)