Skip to content

Commit 629b49c

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

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
@@ -4159,6 +4159,9 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
41594159
struct inquiry_info_with_rssi_and_pscan_mode *info;
41604160
info = (void *) (skb->data + 1);
41614161

4162+
if (skb->len < num_rsp * sizeof(*info) + 1)
4163+
goto unlock;
4164+
41624165
for (; num_rsp; num_rsp--, info++) {
41634166
u32 flags;
41644167

@@ -4180,6 +4183,9 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
41804183
} else {
41814184
struct inquiry_info_with_rssi *info = (void *) (skb->data + 1);
41824185

4186+
if (skb->len < num_rsp * sizeof(*info) + 1)
4187+
goto unlock;
4188+
41834189
for (; num_rsp; num_rsp--, info++) {
41844190
u32 flags;
41854191

@@ -4200,6 +4206,7 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
42004206
}
42014207
}
42024208

4209+
unlock:
42034210
hci_dev_unlock(hdev);
42044211
}
42054212

0 commit comments

Comments
 (0)