Skip to content

Commit 3a56ef7

Browse files
pskrgagholtmann
authored andcommitted
Bluetooth: stop proccessing malicious adv data
Syzbot reported slab-out-of-bounds read in hci_le_adv_report_evt(). The problem was in missing validaion check. We should check if data is not malicious and we can read next data block. If we won't check ptr validness, code can read a way beyond skb->end and it can cause problems, of course. Fixes: e95beb4 ("Bluetooth: hci_le_adv_report_evt code refactoring") Reported-and-tested-by: [email protected] Signed-off-by: Pavel Skripkin <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent dd2ac1d commit 3a56ef7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

net/bluetooth/hci_event.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5906,7 +5906,8 @@ static void hci_le_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
59065906
struct hci_ev_le_advertising_info *ev = ptr;
59075907
s8 rssi;
59085908

5909-
if (ev->length <= HCI_MAX_AD_LENGTH) {
5909+
if (ev->length <= HCI_MAX_AD_LENGTH &&
5910+
ev->data + ev->length <= skb_tail_pointer(skb)) {
59105911
rssi = ev->data[ev->length];
59115912
process_adv_report(hdev, ev->evt_type, &ev->bdaddr,
59125913
ev->bdaddr_type, NULL, 0, rssi,
@@ -5916,6 +5917,11 @@ static void hci_le_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
59165917
}
59175918

59185919
ptr += sizeof(*ev) + ev->length + 1;
5920+
5921+
if (ptr > (void *) skb_tail_pointer(skb) - sizeof(*ev)) {
5922+
bt_dev_err(hdev, "Malicious advertising data. Stopping processing");
5923+
break;
5924+
}
59195925
}
59205926

59215927
hci_dev_unlock(hdev);

0 commit comments

Comments
 (0)