Skip to content
This repository has been archived by the owner on Sep 18, 2022. It is now read-only.

Commit

Permalink
Bluetooth: Prevent out-of-bounds read in hci_inquiry_result_with_rssi…
Browse files Browse the repository at this point in the history
…_evt()

commit 629b49c848ee71244203934347bd7730b0ddee8d upstream.

Check `num_rsp` before using it as for-loop counter. Add `unlock` label.

Cc: [email protected]
Signed-off-by: Peilin Ye <[email protected]>
Signed-off-by: Marcel Holtmann <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Lee Jones <[email protected]>
Change-Id: I50a28dd10bc77fb9c05b06278190ee2b97e8036b
  • Loading branch information
peilin-ye authored and MSe1969 committed Sep 12, 2020
1 parent 2b3447b commit e6340b8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions net/bluetooth/hci_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -2813,6 +2813,9 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct
struct inquiry_info_with_rssi_and_pscan_mode *info;
info = (void *) (skb->data + 1);

if (skb->len < num_rsp * sizeof(*info) + 1)
goto unlock;

for (; num_rsp; num_rsp--, info++) {
bacpy(&data.bdaddr, &info->bdaddr);
data.pscan_rep_mode = info->pscan_rep_mode;
Expand All @@ -2830,6 +2833,9 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct
} else {
struct inquiry_info_with_rssi *info = (void *) (skb->data + 1);

if (skb->len < num_rsp * sizeof(*info) + 1)
goto unlock;

for (; num_rsp; num_rsp--, info++) {
bacpy(&data.bdaddr, &info->bdaddr);
data.pscan_rep_mode = info->pscan_rep_mode;
Expand All @@ -2846,6 +2852,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct
}
}

unlock:
hci_dev_unlock(hdev);
}

Expand Down

0 comments on commit e6340b8

Please sign in to comment.