From: Simon Mikuda <simon.mikuda@streamunlimited.com>
To: linux-bluetooth@vger.kernel.org
Cc: Simon Mikuda <simon.mikuda@streamunlimited.com>,
Marcel Holtmann <marcel@holtmann.org>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Subject: [PATCH] Bluetooth: ISO: Don't drop the hold of a closed BIS socket twice
Date: Sun, 22 Nov 2026 21:14:16 +0100 [thread overview]
Message-ID: <20261122201416.2856484-1-simon.mikuda@streamunlimited.com> (raw)
When a broadcast source BIS socket is closed while its BIG is being
created, its hold on the BIS is dropped and its iso_conn is freed. When LE
Setup ISO Data Path of that BIS completes, iso_connect_cfm() creates a new
iso_conn for it, and freeing that iso_conn drops the hold a second time.
The first BIS of a BIG is the parent of the others, so the extra drop
deletes it together with them while the BIG is still running. The sockets
of the other BISes get ECONNRESET, and the BIG is terminated twice. The
controller rejects the second LE Terminate BIG:
< LE Create Broadcast Isochronous Group BIG handle: 0x00, 2 BISes
(BIS 1 socket closed)
> LE Broadcast Isochronous Group Complete Connection handles: 16, 17
< LE Setup Isochronous Data Path Handle: 16
< LE Setup Isochronous Data Path Handle: 17
< LE Terminate Broadcast Isochronous Group BIG handle: 0x00
> LE Broadcast Isochronous Group Terminate BIG handle: 0x00
< LE Remove Advertising Set Handle: 1
< LE Terminate Broadcast Isochronous Group BIG handle: 0x00
> Command Status Unknown Advertising Identifier (0x42)
Fix this by looking up the iso_conn that a source BIS got in connect()
instead of creating a new one. If it is gone, the socket is closed and
there is nothing to make ready. The lookup takes hcon->proto_lock, as
iso_conn_del() does, because the closing socket frees the iso_conn after
clearing hcon->iso_data under that lock.
Steps to reproduce:
1. Run btmon.
2. Open two broadcast source BIS sockets for one BIG and connect them, the
first with BT_DEFER_SETUP, as isotest -N 2 does.
3. Close the first socket right away, before LE BIG Complete.
4. The second socket always gets ECONNRESET, and btmon shows LE Terminate
BIG twice, the second one failing with Unknown Advertising Identifier.
Fixes: fdfde532ab1c ("Bluetooth: ISO: fix refcounting of iso_conn")
Signed-off-by: Simon Mikuda <simon.mikuda@streamunlimited.com>
---
net/bluetooth/iso.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c
index 06f1e7ba2cb1..fd33a1ec53d6 100644
--- a/net/bluetooth/iso.c
+++ b/net/bluetooth/iso.c
@@ -2680,7 +2680,14 @@ static void iso_connect_cfm(struct hci_conn *hcon, __u8 status)
test_bit(HCI_CONN_PA_SYNC_FAILED, hcon->flags)) {
struct iso_conn *conn;
- conn = iso_conn_add(hcon);
+ if (hcon->type == BIS_LINK && hcon->role == HCI_ROLE_MASTER) {
+ spin_lock(&hcon->proto_lock);
+ conn = iso_conn_hold_unless_zero(hcon->iso_data);
+ spin_unlock(&hcon->proto_lock);
+ } else {
+ conn = iso_conn_add(hcon);
+ }
+
if (conn) {
iso_conn_ready(conn);
iso_conn_put(conn);
base-commit: 4fe38719e6738feaa90486e36b0790dd5d960a96
--
2.43.0
next reply other threads:[~2026-11-22 20:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 20:14 Simon Mikuda [this message]
2026-11-22 22:46 ` Bluetooth: ISO: Don't drop the hold of a closed BIS socket twice bluez.test.bot
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=20261122201416.2856484-1-simon.mikuda@streamunlimited.com \
--to=simon.mikuda@streamunlimited.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.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