linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: hci_event: potential out of bounds parsing ADV events
@ 2019-03-30  7:25 Dan Carpenter
  2019-03-30  9:20 ` Tomas Bortoli
  0 siblings, 1 reply; 23+ messages in thread
From: Dan Carpenter @ 2019-03-30  7:25 UTC (permalink / raw)
  To: Marcel Holtmann, Jaganath Kanakkassery
  Cc: Johan Hedberg, Tomas Bortoli, linux-bluetooth, kernel-janitors

There is a potential out of bounds if "ev->length" is too high or if the
number of reports are too many.

Fixes: c215e9397b00 ("Bluetooth: Process extended ADV report event")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Not tested.  I suck at pointer math, and I don't know why the protocol
requires a "+ 1".  Please review carefully.

 net/bluetooth/hci_event.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 609fd6871c5a..ee945b3d12e1 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -5417,6 +5417,7 @@ static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	u8 num_reports = skb->data[0];
 	void *ptr = &skb->data[1];
+	void *end = &skb->data[skb->len];
 
 	hci_dev_lock(hdev);
 
@@ -5425,6 +5426,8 @@ static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
 		u8 legacy_evt_type;
 		u16 evt_type;
 
+		if (ptr + sizeof(*ev) + ev->length + 1 > end)
+			break;
 		evt_type = __le16_to_cpu(ev->evt_type);
 		legacy_evt_type = ext_evt_type_to_legacy(evt_type);
 		if (legacy_evt_type != LE_ADV_INVALID) {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2019-04-05 21:23 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-30  7:25 [PATCH] Bluetooth: hci_event: potential out of bounds parsing ADV events Dan Carpenter
2019-03-30  9:20 ` Tomas Bortoli
2019-03-30 22:44   ` Tomas Bortoli
2019-04-01  6:32     ` Dan Carpenter
2019-04-01 17:24       ` Tomas Bortoli
2019-04-01 17:41         ` Dan Carpenter
2019-04-03  6:54         ` Jaganath K
2019-04-01 18:03   ` Cong Wang
2019-04-02  6:33     ` Dan Carpenter
2019-04-02 17:42       ` Cong Wang
2019-04-02 18:46         ` Tomas Bortoli
2019-04-02 19:55         ` Dan Carpenter
2019-04-03 22:55           ` Cong Wang
2019-04-04  8:06             ` Dan Carpenter
2019-04-05 17:16               ` Cong Wang
2019-04-05 20:48                 ` Dan Carpenter
2019-04-05 21:05                   ` Tomas Bortoli
2019-04-05 21:14                     ` Dan Carpenter
     [not found]                       ` <CAAHj5qj3PciY8ngqSGzH3=TQcm5vCghb0Z_0Y3DFQjTLMUM-9Q@mail.gmail.com>
2019-04-05 21:23                         ` Dan Carpenter
2019-04-02 20:13         ` Dan Carpenter
2019-04-03 22:51           ` Cong Wang
2019-04-04  6:35             ` Dan Carpenter
2019-04-05 16:28               ` Cong Wang

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).