Skip to content

Commit df6f718

Browse files
peilin-yegregkh
authored andcommitted
Bluetooth: Prevent out-of-bounds read in hci_inquiry_result_with_rssi_evt()
commit 629b49c 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]>
1 parent 855a93a commit df6f718

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

net/bluetooth/hci_event.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3623,6 +3623,9 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
36233623
struct inquiry_info_with_rssi_and_pscan_mode *info;
36243624
info = (void *) (skb->data + 1);
36253625

3626+
if (skb->len < num_rsp * sizeof(*info) + 1)
3627+
goto unlock;
3628+
36263629
for (; num_rsp; num_rsp--, info++) {
36273630
u32 flags;
36283631

@@ -3644,6 +3647,9 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
36443647
} else {
36453648
struct inquiry_info_with_rssi *info = (void *) (skb->data + 1);
36463649

3650+
if (skb->len < num_rsp * sizeof(*info) + 1)
3651+
goto unlock;
3652+
36473653
for (; num_rsp; num_rsp--, info++) {
36483654
u32 flags;
36493655

@@ -3664,6 +3670,7 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
36643670
}
36653671
}
36663672

3673+
unlock:
36673674
hci_dev_unlock(hdev);
36683675
}
36693676

0 commit comments

Comments
 (0)