Linux bluetooth development
 help / color / mirror / Atom feed
From: Pauli Virtanen <pav@iki.fi>
To: linux-bluetooth@vger.kernel.org
Cc: Pauli Virtanen <pav@iki.fi>
Subject: [PATCH BlueZ 1/2] emulator: bthost: don't crash on ecred_conn_req with too many scid
Date: Sun, 30 Aug 2026 01:47:58 +0300	[thread overview]
Message-ID: <fab8ccab695b50d726bdc00423d8ca915edcf11e.1788043574.git.pav@iki.fi> (raw)

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


             reply	other threads:[~2026-08-29 22:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-29 22:47 Pauli Virtanen [this message]
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

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=fab8ccab695b50d726bdc00423d8ca915edcf11e.1788043574.git.pav@iki.fi \
    --to=pav@iki.fi \
    --cc=linux-bluetooth@vger.kernel.org \
    /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