* [PATCH BlueZ 1/5] monitor: Fix overflow of the name buffer in print_eir
2026-11-20 22:26 [PATCH BlueZ 0/5] monitor: Fix reads beyond advertising data Roland Schober
@ 2026-11-20 22:26 ` Roland Schober
2026-11-20 22:26 ` [PATCH BlueZ 2/5] monitor: Fix reading Flags beyond empty AD structures Roland Schober
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Roland Schober @ 2026-11-20 22:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Roland Schober
print_eir() copies the Shortened Local Name, the Complete Local Name
and the Broadcast Name into a buffer of 239 octets, which is enough for
the 240 octets of an Extended Inquiry Response. Advertising data from
other packets can have longer AD structures: an LE Periodic Advertising
Report with a Complete Local Name of 240 octets makes AddressSanitizer
report a write beyond the buffer.
Size the buffer for the largest AD structure.
Fixes: 854c945433fc ("monitor: Add full EIR parsing support")
Fixes: 99deeea86f15 ("btmon: Decode Broadcast Name")
Assisted-by: Claude:claude-fable-5-2
---
monitor/packet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/monitor/packet.c b/monitor/packet.c
index eddf8706a..bce3bb819 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -4418,7 +4418,7 @@ static void print_eir(const char *label, const uint8_t *eir, uint8_t eir_len,
uint8_t field_len = eir[0];
const uint8_t *data = &eir[2];
uint8_t data_len;
- char name[239], label[100];
+ char name[255], label[100];
uint8_t flags, mask;
/* Check for the end of EIR */
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH BlueZ 2/5] monitor: Fix reading Flags beyond empty AD structures
2026-11-20 22:26 [PATCH BlueZ 0/5] monitor: Fix reads beyond advertising data Roland Schober
2026-11-20 22:26 ` [PATCH BlueZ 1/5] monitor: Fix overflow of the name buffer in print_eir Roland Schober
@ 2026-11-20 22:26 ` Roland Schober
2026-11-20 22:26 ` [PATCH BlueZ 3/5] monitor: Fix reading beyond a short Mesh Beacon Roland Schober
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Roland Schober @ 2026-11-20 22:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Roland Schober
print_eir() reads the first data octet of the Flags and of the Security
Manager OOB Flags without checking that there is one. An AD structure
which only has its type, at the end of the advertising data, makes it
read one octet beyond the data.
Fixes: 854c945433fc ("monitor: Add full EIR parsing support")
Assisted-by: Claude:claude-fable-5-2
---
monitor/packet.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/monitor/packet.c b/monitor/packet.c
index bce3bb819..4f63cc0fb 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -4437,6 +4437,8 @@ static void print_eir(const char *label, const uint8_t *eir, uint8_t eir_len,
switch (eir[1]) {
case BT_EIR_FLAGS:
+ if (data_len < 1)
+ break;
flags = *data;
print_field("Flags: 0x%2.2x", flags);
@@ -4534,6 +4536,8 @@ static void print_eir(const char *label, const uint8_t *eir, uint8_t eir_len,
break;
case BT_EIR_SMP_OOB_FLAGS:
+ if (data_len < 1)
+ break;
print_field("SMP OOB Flags: 0x%2.2x", *data);
break;
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH BlueZ 3/5] monitor: Fix reading beyond a short Mesh Beacon
2026-11-20 22:26 [PATCH BlueZ 0/5] monitor: Fix reads beyond advertising data Roland Schober
2026-11-20 22:26 ` [PATCH BlueZ 1/5] monitor: Fix overflow of the name buffer in print_eir Roland Schober
2026-11-20 22:26 ` [PATCH BlueZ 2/5] monitor: Fix reading Flags beyond empty AD structures Roland Schober
@ 2026-11-20 22:26 ` Roland Schober
2026-11-20 22:26 ` [PATCH BlueZ 4/5] monitor: Fix reading beyond the Apple manufacturer data Roland Schober
2026-11-20 22:26 ` [PATCH BlueZ 5/5] monitor: Fix decoding of Public Broadcast Announcements Roland Schober
4 siblings, 0 replies; 6+ messages in thread
From: Roland Schober @ 2026-11-20 22:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Roland Schober
The Unprovisioned Device Beacon has the beacon type, 16 octets of
Device UUID and 2 octets of OOB Information, but print_mesh_beacon()
decodes the OOB Information of a beacon with 18 octets, which lacks its
second octet. Require 19 octets, and dump the octets after the OOB
Information, not from its second octet on, if there is no URI Hash.
Fixes: 0ba12681f3e4 ("monitor: Add basic decoding for Mesh Beacon")
Assisted-by: Claude:claude-fable-5-2
---
monitor/packet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/monitor/packet.c b/monitor/packet.c
index 4f63cc0fb..6646dc147 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -4205,7 +4205,7 @@ static void print_mesh_beacon(const uint8_t *data, uint8_t len)
switch (data[0]) {
case 0x00:
print_field(" Unprovisioned Device Beacon (0x00)");
- if (len < 18) {
+ if (len < 19) {
packet_hexdump(data + 1, len - 1);
break;
}
@@ -4218,7 +4218,7 @@ static void print_mesh_beacon(const uint8_t *data, uint8_t len)
print_bitfield(4, oob, mesh_oob_table);
if (len < 23) {
- packet_hexdump(data + 18, len - 18);
+ packet_hexdump(data + 19, len - 19);
break;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH BlueZ 4/5] monitor: Fix reading beyond the Apple manufacturer data
2026-11-20 22:26 [PATCH BlueZ 0/5] monitor: Fix reads beyond advertising data Roland Schober
` (2 preceding siblings ...)
2026-11-20 22:26 ` [PATCH BlueZ 3/5] monitor: Fix reading beyond a short Mesh Beacon Roland Schober
@ 2026-11-20 22:26 ` Roland Schober
2026-11-20 22:26 ` [PATCH BlueZ 5/5] monitor: Fix decoding of Public Broadcast Announcements Roland Schober
4 siblings, 0 replies; 6+ messages in thread
From: Roland Schober @ 2026-11-20 22:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Roland Schober
print_manufacturer_apple() reads the type before it checks that there
is one, and prints the identifier as a string although nothing
terminates it, so up to 98 octets which follow the AD structure are
printed with it.
Check the length first and print the identifier with its length.
Fixes: 35b0d0c7c281 ("monitor: Decode Apple identifier and iBeacon data structures")
Assisted-by: Claude:claude-fable-5-2
---
monitor/packet.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/monitor/packet.c b/monitor/packet.c
index 6646dc147..042a2ecb6 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -3763,18 +3763,16 @@ static void print_fec(uint8_t fec)
static void print_manufacturer_apple(const void *data, uint8_t data_len)
{
- uint8_t type = *((uint8_t *) data);
+ uint8_t type;
if (data_len < 1)
return;
- if (type == 0x01) {
- char identifier[100];
+ type = *((uint8_t *) data);
- snprintf(identifier, sizeof(identifier) - 1, "%s",
+ if (type == 0x01) {
+ print_field(" Identifier: %.*s", data_len - 1,
(const char *) (data + 1));
-
- print_field(" Identifier: %s", identifier);
return;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH BlueZ 5/5] monitor: Fix decoding of Public Broadcast Announcements
2026-11-20 22:26 [PATCH BlueZ 0/5] monitor: Fix reads beyond advertising data Roland Schober
` (3 preceding siblings ...)
2026-11-20 22:26 ` [PATCH BlueZ 4/5] monitor: Fix reading beyond the Apple manufacturer data Roland Schober
@ 2026-11-20 22:26 ` Roland Schober
4 siblings, 0 replies; 6+ messages in thread
From: Roland Schober @ 2026-11-20 22:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Roland Schober
print_pbp_announcement() takes the result of util_iov_pull_u8() the
wrong way round: a well formed announcement is reported as "invalid
features", and an empty one is decoded from uninitialised variables,
which can hand a NULL pointer to bt_bap_debug_metadata().
Check the metadata length against the remaining data as well.
Fixes: 3171f7fd3685 ("monitor: Add decoding support for Public Broadcast Announcements")
Assisted-by: Claude:claude-fable-5-2
---
monitor/packet.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/monitor/packet.c b/monitor/packet.c
index 042a2ecb6..7fdab7cc5 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -4101,7 +4101,7 @@ static void print_pbp_announcement(const uint8_t *data, uint8_t data_len)
iov.iov_base = (void *) data;
iov.iov_len = data_len;
- if (util_iov_pull_u8(&iov, &feat)) {
+ if (!util_iov_pull_u8(&iov, &feat)) {
print_text(COLOR_ERROR, " invalid features");
return;
}
@@ -4113,7 +4113,7 @@ static void print_pbp_announcement(const uint8_t *data, uint8_t data_len)
print_text(COLOR_UNKNOWN_SERVICE_CLASS,
" Unknown feature (0x%2.2x)", mask);
- if (util_iov_pull_u8(&iov, &len)) {
+ if (!util_iov_pull_u8(&iov, &len)) {
print_text(COLOR_ERROR, " invalid metadata length");
return;
}
@@ -4122,6 +4122,11 @@ static void print_pbp_announcement(const uint8_t *data, uint8_t data_len)
return;
meta.iov_base = util_iov_pull_mem(&iov, len);
+ if (!meta.iov_base) {
+ print_text(COLOR_ERROR, " invalid metadata");
+ return;
+ }
+
meta.iov_len = len;
bt_bap_debug_metadata(meta.iov_base, meta.iov_len, print_ltv,
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread