From: Roland Schober <rolandschober1968@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Roland Schober <rolandschober1968@gmail.com>
Subject: [PATCH BlueZ v3 3/9] monitor: Fix PHY decoding of LE Ext Create Connection
Date: Thu, 19 Nov 2026 09:16:15 +0100 [thread overview]
Message-ID: <20261119081621.112623-4-rolandschober1968@gmail.com> (raw)
In-Reply-To: <20261119081621.112623-1-rolandschober1968@gmail.com>
The LE Extended Create Connection decoder reads one block of connection
parameters for each bit set in Initiating_PHYs without checking that the
command carries that many blocks, so a truncated command makes it decode
octets which are not part of it:
< HCI Command: LE Extended Create Connection (0x08|0x0043) plen 10
...
Initiating PHYs: 0x01
Entry 0: LE 1M
Scan interval: 0.000 msec (0x0000)
Scan window: 0.000 msec (0x0000)
...
Check the size of the command before decoding each block, and report
octets left over after the last block:
Initiating PHYs: 0x01
invalid packet size
Fixes: e29ef3b85116 ("monitor: Add LE Extended Scan commands decoding")
Assisted-by: Claude:claude-opus-5-5
---
monitor/packet.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/monitor/packet.c b/monitor/packet.c
index 0e40300fd..c290dbf7c 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -8816,10 +8816,12 @@ static const struct bitfield_data ext_conn_phys_table[] = {
{ }
};
-static void print_ext_conn_phys(const void *data, uint8_t flags)
+static void print_ext_conn_phys(const void *data, uint8_t size,
+ uint8_t flags)
{
const struct bt_hci_le_ext_create_conn *entry;
uint8_t mask = flags;
+ bool truncated = false;
int bits_set = 0;
int i;
@@ -8827,9 +8829,20 @@ static void print_ext_conn_phys(const void *data, uint8_t flags)
for (i = 0; ext_conn_phys_table[i].str; i++) {
if (flags & (1 << ext_conn_phys_table[i].bit)) {
- entry = data + bits_set * sizeof(*entry);
mask &= ~(1 << ext_conn_phys_table[i].bit);
+ if (truncated)
+ continue;
+
+ if ((bits_set + 1) * sizeof(*entry) > size) {
+ print_text(COLOR_ERROR,
+ " invalid packet size");
+ truncated = true;
+ continue;
+ }
+
+ entry = data + bits_set * sizeof(*entry);
+
print_field("Entry %d: %s", bits_set,
ext_conn_phys_table[i].str);
print_slot_625(" Scan interval", entry->scan_interval);
@@ -8852,6 +8865,12 @@ static void print_ext_conn_phys(const void *data, uint8_t flags)
}
}
+ if (!truncated && bits_set * sizeof(*entry) < size) {
+ print_text(COLOR_ERROR, " invalid packet size");
+ packet_hexdump(data + bits_set * sizeof(*entry),
+ size - bits_set * sizeof(*entry));
+ }
+
if (mask)
print_text(COLOR_UNKNOWN_ADV_FLAG, " Unknown scanning PHYs"
" (0x%2.2x)", mask);
@@ -8880,7 +8899,7 @@ static void le_ext_create_conn_cmd(uint16_t index, const void *data,
print_own_addr_type(cmd->own_addr_type);
print_peer_addr_type("Peer address type", cmd->peer_addr_type);
print_addr("Peer address", cmd->peer_addr, cmd->peer_addr_type);
- print_ext_conn_phys(cmd->data, cmd->phys);
+ print_ext_conn_phys(cmd->data, size - sizeof(*cmd), cmd->phys);
}
static const struct bitfield_data create_sync_cte_type[] = {
--
2.47.3
next prev parent reply other threads:[~2026-11-19 8:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 8:16 [PATCH BlueZ v3 0/9] monitor: Decode Periodic Advertising with Responses Roland Schober
2026-11-19 8:16 ` [PATCH BlueZ v3 1/9] monitor: Fix handle decoding of status_handle_rsp Roland Schober
2026-11-19 9:53 ` monitor: Decode Periodic Advertising with Responses bluez.test.bot
2026-11-19 8:16 ` [PATCH BlueZ v3 2/9] monitor: Fix data length of LE PA Report decoding Roland Schober
2026-11-19 8:16 ` Roland Schober [this message]
2026-11-19 8:16 ` [PATCH BlueZ v3 4/9] monitor: Fix advertising handle of LE PA commands Roland Schober
2026-11-19 8:16 ` [PATCH BlueZ v3 5/9] monitor: Fix TX power and CTE Type of LE PA Report Roland Schober
2026-11-19 8:16 ` [PATCH BlueZ v3 6/9] monitor: Fix LE PAST Received decoding Roland Schober
2026-11-19 8:16 ` [PATCH BlueZ v3 7/9] monitor: Split LE PA Report decoding into helpers Roland Schober
2026-11-19 8:16 ` [PATCH BlueZ v3 8/9] monitor: Add PAwR HCI commands decoding Roland Schober
2026-11-19 8:16 ` [PATCH BlueZ v3 9/9] monitor: Add PAwR HCI events decoding Roland Schober
2026-11-19 16:18 ` [PATCH BlueZ v3 0/9] monitor: Decode Periodic Advertising with Responses Luiz Augusto von Dentz
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=20261119081621.112623-4-rolandschober1968@gmail.com \
--to=rolandschober1968@gmail.com \
--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 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.