* [PATCH BlueZ 1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac()
@ 2026-11-22 11:50 Simon Mikuda
2026-11-22 11:50 ` [PATCH BlueZ 2/4] unit/test-bap: Check that a broadcast sink PAC can be removed Simon Mikuda
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Simon Mikuda @ 2026-11-22 11:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
bt_bap_remove_pac() looked for the PAC in the sink, source and broadcast
source lists only, so a broadcast sink PAC stayed in broadcast_sinks
after its endpoint was freed. When the endpoint owner goes away, like
WirePlumber restarting, the next BIGInfo matches the stale PAC and
bluetoothd crashes:
pac_bcast_config (endpoint=<freed>) at profiles/audio/media.c
pac_config () at profiles/audio/media.c
bap_bcast_config () at src/shared/bap.c
bt_bap_stream_config () at src/shared/bap.c
create_stream_for_bis () at profiles/audio/bap.c
bis_handler () at profiles/audio/bap.c
bt_bap_parse_base () at src/shared/bap.c
big_info_report_cb () at profiles/audio/bap.c
Fixes: d49ea14f70da ("shared/bap: Add support for BAP broadcast sink")
Assisted-by: Claude:claude-opus-5-5
---
src/shared/bap.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/shared/bap.c b/src/shared/bap.c
index 8fc28de52..9404bddba 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -4864,6 +4864,9 @@ bool bt_bap_remove_pac(struct bt_bap_pac *pac)
if (queue_remove_if(pac->bdb->broadcast_sources, NULL, pac))
goto found;
+ if (queue_remove_if(pac->bdb->broadcast_sinks, NULL, pac))
+ goto found;
+
return false;
found:
base-commit: 1adfe662efeff12997df9ddd0960dbd0de9c8ea7
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH BlueZ 2/4] unit/test-bap: Check that a broadcast sink PAC can be removed
2026-11-22 11:50 [PATCH BlueZ 1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac() Simon Mikuda
@ 2026-11-22 11:50 ` Simon Mikuda
2026-11-22 11:50 ` [PATCH BlueZ 3/4] bap: Don't leak the io of a PA sync that failed Simon Mikuda
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Simon Mikuda @ 2026-11-22 11:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
bt_bap_remove_pac() did not find a broadcast sink PAC, which left the
PAC of an unregistered endpoint in use. Check in the teardown of every
test that registers one that its removal succeeds.
Assisted-by: Claude:claude-opus-5-5
---
unit/test-bap.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/unit/test-bap.c b/unit/test-bap.c
index bfe98a885..9508c503e 100644
--- a/unit/test-bap.c
+++ b/unit/test-bap.c
@@ -1307,7 +1307,10 @@ static void test_teardown(const void *user_data)
bt_bap_remove_pac(data->snk);
bt_bap_remove_pac(data->src);
bt_bap_remove_pac(data->bsrc);
- bt_bap_remove_pac(data->bsnk);
+
+ if (data->bsnk)
+ g_assert(bt_bap_remove_pac(data->bsnk));
+
gatt_db_unref(data->db);
bt_gatt_server_unref(data->server);
data->server = NULL;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH BlueZ 3/4] bap: Don't leak the io of a PA sync that failed
2026-11-22 11:50 [PATCH BlueZ 1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac() Simon Mikuda
2026-11-22 11:50 ` [PATCH BlueZ 2/4] unit/test-bap: Check that a broadcast sink PAC can be removed Simon Mikuda
@ 2026-11-22 11:50 ` Simon Mikuda
2026-11-22 11:50 ` [PATCH BlueZ 4/4] bap: Close a pending PA or BIG sync when a broadcast sink session ends Simon Mikuda
2026-11-22 19:01 ` [BlueZ,1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac() bluez.test.bot
3 siblings, 0 replies; 5+ messages in thread
From: Simon Mikuda @ 2026-11-22 11:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
From: Simon Mikuda <simon.mikuda@gmail.com>
The kernel reports a PA sync that times out twice.
iso_pa_sync_confirm_cb() replaced data->io_id for the second io, so the
watch of the first one stayed, holding the last reference of its io and
keeping the failed sync in the kernel. Where PA syncs are BIS
connections on BIG 0, a broadcast source on BIG 0 then fails to bind
with EADDRINUSE until bluetoothd restarts.
Remove the previous watch, which also closes its io.
Fixes: 2748c60a2c6b ("bap: Wait for BIG Info report event before creating streams")
Assisted-by: Claude:claude-opus-5-5
---
profiles/audio/bap.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index 457ba5de8..5e717cbef 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -1896,6 +1896,13 @@ static void iso_pa_sync_confirm_cb(GIOChannel *io, void *user_data)
* encryption flag is also available.
*/
DBG("PA Sync done");
+
+ /* A failed PA sync is reported twice. Dropping the previous watch also
+ * closes its io, as the watch holds the last reference.
+ */
+ if (data->io_id)
+ g_source_remove(data->io_id);
+
data->io_id = g_io_add_watch(io, G_IO_OUT, big_info_report_cb,
user_data);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH BlueZ 4/4] bap: Close a pending PA or BIG sync when a broadcast sink session ends
2026-11-22 11:50 [PATCH BlueZ 1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac() Simon Mikuda
2026-11-22 11:50 ` [PATCH BlueZ 2/4] unit/test-bap: Check that a broadcast sink PAC can be removed Simon Mikuda
2026-11-22 11:50 ` [PATCH BlueZ 3/4] bap: Don't leak the io of a PA sync that failed Simon Mikuda
@ 2026-11-22 11:50 ` Simon Mikuda
2026-11-22 19:01 ` [BlueZ,1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac() bluez.test.bot
3 siblings, 0 replies; 5+ messages in thread
From: Simon Mikuda @ 2026-11-22 11:50 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
bap_bcast_disconnect() frees the broadcast sink setups, but listen_io
stays open with a callback on one of them. A PA sync that completes
after the session ended crashes bluetoothd:
#4 iso_do_big_sync (io=0xaaaad1ab3a30, user_data=0xaaaad1a87110)
at profiles/audio/bap.c:3689
#5 server_cb (io=0xaaaad1aabd30, cond=<optimized out>,
user_data=0xaaaad1ad1310) at btio/btio.c:285
Close listen_io before freeing the setups.
Fixes: feb4ee9dcd4b ("bap: Fix use-after-free in broadcast sink cleanup")
Assisted-by: Claude:claude-opus-5-5
---
profiles/audio/bap.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index 5e717cbef..af532537b 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -4284,6 +4284,16 @@ static int bap_bcast_disconnect(struct btd_service *service)
error("BAP service not handled by profile");
return -EINVAL;
}
+
+ /* A pending PA or BIG sync calls back with one of the setups freed
+ * below, close it.
+ */
+ if (data->listen_io) {
+ g_io_channel_shutdown(data->listen_io, TRUE, NULL);
+ g_io_channel_unref(data->listen_io);
+ data->listen_io = NULL;
+ }
+
/* Clean up broadcast sinks before detach (like unicast does) */
if (data->bcast_snks) {
bcast_snks = data->bcast_snks;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* RE: [BlueZ,1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac()
2026-11-22 11:50 [PATCH BlueZ 1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac() Simon Mikuda
` (2 preceding siblings ...)
2026-11-22 11:50 ` [PATCH BlueZ 4/4] bap: Close a pending PA or BIG sync when a broadcast sink session ends Simon Mikuda
@ 2026-11-22 19:01 ` bluez.test.bot
3 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2026-11-22 19:01 UTC (permalink / raw)
To: linux-bluetooth, simon.mikuda
[-- Attachment #1: Type: text/plain, Size: 2153 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/1218594/
---Test result---
Test Summary:
CheckPatch PASS 2.01 seconds
GitLint FAIL 1.40 seconds
BuildEll PASS 21.50 seconds
BluezMake PASS 321.48 seconds
MakeCheck PASS 14.99 seconds
MakeDistcheck PASS 154.29 seconds
CheckValgrind PASS 361.07 seconds
CheckSmatch WARNING 352.83 seconds
bluezmakeextell PASS 102.40 seconds
TestFunctional FAIL 1306.56 seconds
IncrementalBuild PASS 354.59 seconds
ScanBuild PASS 1252.88 seconds
Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[BlueZ,4/4] bap: Close a pending PA or BIG sync when a broadcast sink session ends
1: T1 Title exceeds max length (82>80): "[BlueZ,4/4] bap: Close a pending PA or BIG sync when a broadcast sink session ends"
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
src/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structures
##############################
Test: TestFunctional - FAIL
Desc: Run test-functional
Output:
FAIL functional.test_bap::test_bass_past_earbuds_transport_acquire[hosts11-vm3]: AssertionError: Failed to acquire: org.bluez.Error.Failed
https://github.com/bluez/bluez/pull/2875
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-22 19:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 11:50 [PATCH BlueZ 1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac() Simon Mikuda
2026-11-22 11:50 ` [PATCH BlueZ 2/4] unit/test-bap: Check that a broadcast sink PAC can be removed Simon Mikuda
2026-11-22 11:50 ` [PATCH BlueZ 3/4] bap: Don't leak the io of a PA sync that failed Simon Mikuda
2026-11-22 11:50 ` [PATCH BlueZ 4/4] bap: Close a pending PA or BIG sync when a broadcast sink session ends Simon Mikuda
2026-11-22 19:01 ` [BlueZ,1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac() bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox