Bluetooth: ISO: Don't drop the hold of a closed BIS socket twice
Subsystems (2)
PATCH 1/1 Bluetooth: ISO: Don't drop the hold of a closed BIS socket twice
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.
--- net/bluetooth/iso.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
net/bluetooth/iso.c +8 -1
@@ -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
Signature · 1 line
2.43.0
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/1218954/
---Test result---
Test Summary:
CheckPatch PASS 0.62 seconds VerifyFixes PASS 0.11 seconds VerifySignedoff PASS 0.10 seconds GitLint PASS 0.28 seconds SubjectPrefix PASS 0.10 seconds BuildKernel PASS 24.14 seconds CheckAllWarning PASS 27.11 seconds CheckSparse PASS 29.06 seconds BuildKernel32 PASS 23.46 seconds CheckKernelLLVM PASS 24.45 seconds TestRunnerSetup PASS 557.51 seconds TestRunner_iso-tester PASS 14.10 seconds IncrementalBuild PASS 23.61 seconds
https://github.com/bluez/bluetooth-next/pull/1199
---
Regards,
Linux Bluetooth