Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ v2 0/6] monitor: Fix reads beyond advertising data
@ 2026-11-23 22:23 Roland Schober
  2026-11-23 22:23 ` [PATCH BlueZ v2 1/6] monitor: Fix overflow of the name buffer in print_eir Roland Schober
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Roland Schober @ 2026-11-23 22:23 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Roland Schober

print_eir() and the decoders it calls take advertising data, which a
remote device chooses. This series fixes six places where btmon reads
or writes beyond that data, or decodes it from the wrong place:

 - a Shortened Local Name, Complete Local Name or Broadcast Name of
   240 or more octets is copied beyond a buffer of 239 octets,
 - the Flags and the Security Manager OOB Flags are read from an AD
   structure which has no data,
 - an Unprovisioned Device Beacon of 18 octets is decoded although its
   OOB Information lacks an octet,
 - the Apple identifier is printed as a string which nothing
   terminates,
 - the Program Info metadata is printed without a limit to its
   length,
 - a Public Broadcast Announcement is reported as invalid when it is
   well formed, and decoded from uninitialised variables when it is
   too short.

Copilot found the first one in its review of "monitor: Decode Periodic
Advertising with Responses" v4, whose new decoders hand advertising
data to print_eir() as well. The bug is older than that series and
can be reached without it, e.g. by an LE Periodic Advertising Report,
so the fixes come as a series of their own. A v5 of the decoding
series will follow on top of it.

The others were found by feeding print_eir() one AD structure of every
type with every length up to 250 octets, in a buffer of exactly that
size with AddressSanitizer, and by review. The same test passes with
the series applied. The reads of patches 1 to 5 show there as
AddressSanitizer reports; patch 6 was tested with hand-made btsnoop
traces only.

For v2 the advertising data was also fuzzed with libFuzzer and
AddressSanitizer, part of the time with UndefinedBehaviorSanitizer as
well, as LE advertising data and as an Extended Inquiry Response.
Without the series it finds the reads of patches 1 to 5 within a
minute, the one of patch 5 through a Basic Audio Announcement. With
it, more than 200 million inputs, which run every line of
print_eir(), found nothing.

v2:
 - Add patch 5. Copilot found that the fix of the Public Broadcast
   Announcements, now patch 6, lets them reach the Program Info
   decoding, which reads beyond the string.
 - Rebase.

Roland Schober (6):
  monitor: Fix overflow of the name buffer in print_eir
  monitor: Fix reading Flags beyond empty AD structures
  monitor: Fix reading beyond a short Mesh Beacon
  monitor: Fix reading beyond the Apple manufacturer data
  shared/bap: Fix reading beyond the Program Info
  monitor: Fix decoding of Public Broadcast Announcements

 monitor/packet.c       | 29 ++++++++++++++++++-----------
 src/shared/bap-debug.c |  2 +-
 2 files changed, 19 insertions(+), 12 deletions(-)

-- 
2.47.3


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

end of thread, other threads:[~2026-11-23 22:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 22:23 [PATCH BlueZ v2 0/6] monitor: Fix reads beyond advertising data Roland Schober
2026-11-23 22:23 ` [PATCH BlueZ v2 1/6] monitor: Fix overflow of the name buffer in print_eir Roland Schober
2026-11-23 22:23 ` [PATCH BlueZ v2 2/6] monitor: Fix reading Flags beyond empty AD structures Roland Schober
2026-11-23 22:23 ` [PATCH BlueZ v2 3/6] monitor: Fix reading beyond a short Mesh Beacon Roland Schober
2026-11-23 22:23 ` [PATCH BlueZ v2 4/6] monitor: Fix reading beyond the Apple manufacturer data Roland Schober
2026-11-23 22:23 ` [PATCH BlueZ v2 5/6] shared/bap: Fix reading beyond the Program Info Roland Schober
2026-11-23 22:23 ` [PATCH BlueZ v2 6/6] monitor: Fix decoding of Public Broadcast Announcements Roland Schober

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