From: Roland Schober <rolandschober1968@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Roland Schober <rolandschober1968@gmail.com>
Subject: [PATCH BlueZ v2 0/6] monitor: Fix reads beyond advertising data
Date: Mon, 23 Nov 2026 23:23:09 +0100 [thread overview]
Message-ID: <20261123222315.223450-1-rolandschober1968@gmail.com> (raw)
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
next reply other threads:[~2026-11-23 22:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 22:23 Roland Schober [this message]
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
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=20261123222315.223450-1-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox