All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 12/12] btmon: fix segfault caused by buffer over-read
@ 2018-10-16 20:25 Matias Karhumaa
  0 siblings, 0 replies; only message in thread
From: Matias Karhumaa @ 2018-10-16 20:25 UTC (permalink / raw)
  To: linux-bluetooth

Fix segfault caused by buffer over-read in service_rsp function of
monitor/sdp.c.

This bug can be triggered locally reading malformed btmon capture file
and also over the air by sending specifically crafted SDP Search
Attribute response to device running btmon.

Bug was found by fuzzing btmon with AFL.
---
 monitor/sdp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/monitor/sdp.c b/monitor/sdp.c
index 13a8807c7..36708f426 100644
--- a/monitor/sdp.c
+++ b/monitor/sdp.c
@@ -585,6 +585,10 @@ static void service_rsp(const struct l2cap_frame *frame, struct tid_data *tid)
 	}
 
 	count = get_be16(frame->data + 2);
+	if (count * 4 > frame->size) {
+		print_text(COLOR_ERROR, "invalid record count");
+                return;
+	}
 
 	print_field("Total record count: %d", get_be16(frame->data));
 	print_field("Current record count: %d", count);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-10-16 20:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-16 20:25 [PATCH 12/12] btmon: fix segfault caused by buffer over-read Matias Karhumaa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.