[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190304202043.3691-1-tomasbortoli@gmail.com>
Date: Mon, 4 Mar 2019 21:20:43 +0100
From: Tomas Bortoli <tomasbortoli@...il.com>
To: marcel@...tmann.org, johan.hedberg@...il.com
Cc: davem@...emloft.net, linux-bluetooth@...r.kernel.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
syzkaller@...glegroups.com, Tomas Bortoli <tomasbortoli@...il.com>
Subject: [PATCH] net/bluetooth: Fix bound check in event handling
hci_inquiry_result_with_rssi_evt() can perform out of bound reads
on skb->data as a bound check is missing.
Signed-off-by: Tomas Bortoli <tomasbortoli@...il.com>
Reported-by: syzbot+cec7a50c412a2c03f8f5@...kaller.appspotmail.com
Reported-by: syzbot+660883c56e2fa65d4497@...kaller.appspotmail.com
---
v2:
- changed sizeof(info) into sizeof(*info), as it should be.
- simplified expression in if
net/bluetooth/hci_event.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index ac2826ce162b..4cbad1e1a322 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3978,11 +3978,15 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) {
struct inquiry_info_with_rssi_and_pscan_mode *info;
+ void *data_end = (void *)skb->data + skb->len;
info = (void *) (skb->data + 1);
for (; num_rsp; num_rsp--, info++) {
u32 flags;
+ if ((void *)info + sizeof(*info) > data_end)
+ break;
+
bacpy(&data.bdaddr, &info->bdaddr);
data.pscan_rep_mode = info->pscan_rep_mode;
data.pscan_period_mode = info->pscan_period_mode;
--
2.11.0
Powered by blists - more mailing lists