Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] emulator: bthost: don't crash on ecred_conn_req with too many scid
@ 2026-08-29 22:47 Pauli Virtanen
  2026-08-29 22:47 ` [PATCH BlueZ 2/2] tools/l2cap-tester: add test for too many ECRED deferred sockets Pauli Virtanen
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Pauli Virtanen @ 2026-08-29 22:47 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

l2cap_ecred_conn_req() crashes if the request contains more SCID than
specification allows (5).

Respond 0x000C - All connections refused – invalid parameters to such
invalid requests.
---
 emulator/bthost.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/emulator/bthost.c b/emulator/bthost.c
index 46c6a52f5..d23b709ea 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -2607,6 +2607,13 @@ static bool l2cap_ecred_conn_req(struct bthost *bthost, struct btconn *conn,
 	len -= sizeof(rsp.pdu);
 	num_scid = len / sizeof(*req->scid);
 
+	if (num_scid > (int)ARRAY_SIZE(rsp.dcid)) {
+		rsp.pdu.result = cpu_to_le16(0x000c); /* Refuse all - Invalid */
+		bthost_debug(bthost, "invalid ECRED_CONN_REQ (num_scid = %d)",
+								num_scid);
+		goto respond;
+	}
+
 	for (; i < num_scid; i++)
 		rsp.dcid[i] = cpu_to_le16(conn->next_cid++);
 
-- 
2.55.0


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

end of thread, other threads:[~2026-08-31 17:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-29 22:47 [PATCH BlueZ 1/2] emulator: bthost: don't crash on ecred_conn_req with too many scid Pauli Virtanen
2026-08-29 22:47 ` [PATCH BlueZ 2/2] tools/l2cap-tester: add test for too many ECRED deferred sockets Pauli Virtanen
2026-08-30  1:30 ` [BlueZ,1/2] emulator: bthost: don't crash on ecred_conn_req with too many scid bluez.test.bot
2026-08-31 17:30 ` [PATCH BlueZ 1/2] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox