From: Tomas Bortoli <tomasbortoli@gmail.com>
To: marcel@holtmann.org, johan.hedberg@gmail.com
Cc: davem@davemloft.net, linux-bluetooth@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
syzkaller@googlegroups.com,
Tomas Bortoli <tomasbortoli@gmail.com>
Subject: [PATCH] net/bluetooth: Fix bound check in event handling
Date: Mon, 4 Mar 2019 21:20:43 +0100 [thread overview]
Message-ID: <20190304202043.3691-1-tomasbortoli@gmail.com> (raw)
In-Reply-To: <20190228195939.30685-1-tomasbortoli@gmail.com>
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@gmail.com>
Reported-by: syzbot+cec7a50c412a2c03f8f5@syzkaller.appspotmail.com
Reported-by: syzbot+660883c56e2fa65d4497@syzkaller.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
next prev parent reply other threads:[~2019-03-04 20:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-28 19:59 [PATCH] net/bluetooth: Fix bound check in event handling Tomas Bortoli
2019-03-02 16:46 ` Marcel Holtmann
2019-03-02 23:17 ` Tomas Bortoli
2019-03-04 15:04 ` Dan Carpenter
2019-03-04 19:58 ` Tomas Bortoli
2019-03-04 20:20 ` Tomas Bortoli [this message]
2019-03-30 7:17 ` Dan Carpenter
2019-03-30 8:23 ` [kbuild] " Dan Carpenter
2019-03-30 22:37 ` Tomas Bortoli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190304202043.3691-1-tomasbortoli@gmail.com \
--to=tomasbortoli@gmail.com \
--cc=davem@davemloft.net \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
--cc=syzkaller@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).