Skip to content

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 629b49c upstream.

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

Cc: stable@vger.kernel.org
Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
peilin-ye authored and gregkh committed Aug 11, 2020
1 parent f00e012 commit be1c835
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 @@ -4166,6 +4166,9 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
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++) {
u32 flags;

Expand All @@ -4187,6 +4190,9 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
} 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++) {
u32 flags;

Expand All @@ -4207,6 +4213,7 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
}
}

unlock:
hci_dev_unlock(hdev);
}

Expand Down

0 comments on commit be1c835

Please sign in to comment.