All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v2] a2dp: Fix crash on NULL stream in transport_cb
@ 2026-09-21 20:47 Iaroslav Voitovych
  2026-09-21 23:20 ` [BlueZ,v2] " bluez.test.bot
  2026-10-07  0:04 ` bluez.test.bot
  0 siblings, 2 replies; 3+ messages in thread
From: Iaroslav Voitovych @ 2026-09-21 20:47 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Iaroslav Voitovych

transport_cb() runs from bt_io_accept() and begins by confirming that
the a2dp_setup it was handed still exists:

    if (!g_slist_find(setups, setup)) {
        warn("bt_io_accept: setup %p no longer valid", setup);
        ...
    }

That establishes the lifetime of the setup, not of the stream it
points at. Several paths in a2dp.c clear setup->stream while leaving
the setup itself on the list, so by the time the accept completes the
setup can be valid and its stream NULL. confirm_cb() already refuses
to start the accept when setup->stream is NULL; nothing re-checks it
when the accept completes, and it is then passed on unchecked:

    if (!avdtp_stream_set_transport(setup->stream,
                    g_io_channel_unix_get_fd(io),
                    imtu, omtu))

and avdtp_stream_set_transport() dereferences it immediately:

    gboolean avdtp_stream_set_transport(struct avdtp_stream *stream, ...)
    {
        GIOChannel *io = g_io_channel_unix_new(fd);

        if (stream != stream->session->pending_open) {

Observed as a crash on a QCA9377 (13d3:3503) whose controller stops
answering HCI during audio use. From the retained core, %r13 held NULL
and the faulting instruction was the first field load off it:

  bluetoothd[398112]: segfault at 10 ip 0000635d944b47e5 \
      sp 00007ffefcba28d0 error 4 in bluetoothd[367e5,635d944a3000+f3000]

  r13  0x0
  => 0x635d944b47e5:  mov 0x10(%r13),%rdi

With the check in place and the daemon logging before it bails, the
guard fired four times in 19 days of ordinary use on the same machine
(once on 2026-08-26, three times on 2026-09-02, across two daemon
lifetimes and three distinct setup pointers). Each of those is an
accept that completed after the stream had been cleared; unpatched,
each is the dereference above.

Check the stream immediately before it is used, so every existing path
keeps its current behaviour up to the point that was previously
unsafe. In particular a bt_io_accept() error or a bt_io_get() failure
still reports the real I/O error rather than this secondary lifecycle
condition.

commit 125a2e237e7c ("a2dp: Fix possible crash when accepting stream
transport") previously hardened this same asynchronous accept window
against the whole setup disappearing while the accept was pending.
This covers the remaining case where the setup survives and its stream
does not.

commit 90a600895d80 ("avdtp: Handle case where remote send L2CAP
connect ahead of Open") also changed avdtp_stream_set_transport()
itself, to handle a transport arriving before Open. The function still
dereferences stream before reaching that handling, so it does not
cover a NULL argument from transport_cb().
---
v2: quoted code indented with spaces instead of tabs; the quoted fault
    lines re-wrapped to 75 columns. No change to the code.

Context, not part of the change: the crash was recorded on a QCA9377
(13d3:3503) laptop under Ubuntu 24.04 / bluez 5.72-0ubuntu5.5 and the
site was resolved from the stripped distro binary, then checked against
a retained core. The record, including the four logged firings of this
guard and the crash-site method, is public:
https://github.com/ivoitovych/qca9377-bt-hang  (patches/bluez/README.md)

 profiles/audio/a2dp.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -2672,6 +2672,11 @@
 		goto drop;
 	}

+	if (!setup->stream) {
+		error("bt_io_accept: setup %p has no stream", setup);
+		goto drop;
+	}
+
 	if (!avdtp_stream_set_transport(setup->stream,
 					g_io_channel_unix_get_fd(io),
 					imtu, omtu))
--
2.43.0

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

* RE: [BlueZ,v2] a2dp: Fix crash on NULL stream in transport_cb
  2026-09-21 20:47 [PATCH BlueZ v2] a2dp: Fix crash on NULL stream in transport_cb Iaroslav Voitovych
@ 2026-09-21 23:20 ` bluez.test.bot
  2026-10-07  0:04 ` bluez.test.bot
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-09-21 23:20 UTC (permalink / raw)
  To: linux-bluetooth, yaroslav.voytovych

[-- Attachment #1: Type: text/plain, Size: 1017 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1170691/

---Test result---

Test Summary:
CheckPatch                    PASS      0.38 seconds
GitLint                       PASS      0.26 seconds
BuildEll                      PASS      12.38 seconds
BluezMake                     PASS      219.43 seconds
MakeCheck                     PASS      2.79 seconds
MakeDistcheck                 PASS      95.13 seconds
CheckValgrind                 PASS      95.24 seconds
CheckSmatch                   PASS      158.03 seconds
bluezmakeextell               PASS      59.00 seconds
TestFunctional                PASS      745.80 seconds
IncrementalBuild              PASS      220.35 seconds
ScanBuild                     PASS      596.49 seconds



https://github.com/bluez/bluez/pull/2559

---
Regards,
Linux Bluetooth


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

* RE: [BlueZ,v2] a2dp: Fix crash on NULL stream in transport_cb
  2026-09-21 20:47 [PATCH BlueZ v2] a2dp: Fix crash on NULL stream in transport_cb Iaroslav Voitovych
  2026-09-21 23:20 ` [BlueZ,v2] " bluez.test.bot
@ 2026-10-07  0:04 ` bluez.test.bot
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-10-07  0:04 UTC (permalink / raw)
  To: linux-bluetooth, yaroslav.voytovych

[-- Attachment #1: Type: text/plain, Size: 697 bytes --]

This is an automated email and please do not reply to this email.

Dear Submitter,

This series was picked up by the CI more than 2 weeks ago and the pull
request created for it is still open, which means the series was never
applied to the tree.

   Series:       [BlueZ,v2] a2dp: Fix crash on NULL stream in transport_cb
   Pull Request: https://github.com/bluez/bluez/pull/2559
   Created:      2026-09-21 22:42:40+00:00

The pull request has been closed and no further action is taken on this
series.

If the change should still be considered, it must be resent to the Linux
Bluetooth mailing list (linux-bluetooth@vger.kernel.org) so that it is
picked up again.

---
Regards,
Linux Bluetooth

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

end of thread, other threads:[~2026-10-07  0:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-21 20:47 [PATCH BlueZ v2] a2dp: Fix crash on NULL stream in transport_cb Iaroslav Voitovych
2026-09-21 23:20 ` [BlueZ,v2] " bluez.test.bot
2026-10-07  0:04 ` bluez.test.bot

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.