Skip to contentSkip to conversation

Bluetooth: ISO: drop unbalanced sock_put() in iso_conn_ready()

PATCH Applied Andrey Misiurov 3 participants 3 messages Nov 2 – Nov 3

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: ISO: drop unbalanced sock_put() in iso_conn_ready()

Commit 1702f12cf59a ("Bluetooth: ISO: fix use-after-free of listener socket in iso_conn_ready"), the 6.1.y backport of upstream 560bef609fa5, puts the listener when it is no longer listening. Upstream that put balances the reference taken by iso_get_sock(). On 6.1.y iso_get_sock_listen() takes no reference (it got one only in v6.8 with fa224d0c094a), and no other exit of iso_conn_ready() puts the parent.

No race is needed to hit it: shutdown() of a bound socket sets SOCK_ZAPPED and keeps BT_BOUND, so listen() still succeeds and the listener stays BT_LISTEN with SOCK_ZAPPED. Every incoming connection then takes the new branch, and the second one frees the listener while it is still on iso_sk_list and attached to its file.

Drop the put.

Found while reviewing a backport of this fix; not reproduced at runtime.

Fixes 1702f12cf59a ("Bluetooth: ISO: fix use-after-free of listener socket in iso_conn_ready")

---
6.1.y only: 6.6.y and later have the reference-taking lookup.

The closed-listener race that 560bef609fa5 fixes does not free the listener on 6.1.y: iso_sock_release() calls sock_orphan() before iso_sock_kill(), which then returns early on SOCK_DEAD, so a released ISO socket is never freed (fixed upstream by ce57442a3792 "Bluetooth:
ISO: fix leaking sk after socket release", not in 6.1.y). If that commit is backported, iso_get_sock_listen() needs to take a reference as upstream does.

 net/bluetooth/iso.c | 1 -
 1 file changed, 1 deletion(-)
net/bluetooth/iso.c +0 -1
@@ -1536,7 +1536,6 @@ static void iso_conn_ready(struct iso_conn *conn)
 		if (parent->sk_state != BT_LISTEN ||
 		    sock_flag(parent, SOCK_ZAPPED)) {
 			release_sock(parent);
-			sock_put(parent);
 			return;
 		}
 
#1 lore raw

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/1198824/

---Test result---

Test Summary:

CheckPatch                    PASS      0.79 seconds
VerifyFixes                   PASS      0.13 seconds
VerifySignedoff               PASS      0.40 seconds
GitLint                       PASS      0.35 seconds
SubjectPrefix                 PASS      0.13 seconds
BuildKernel                   PASS      30.09 seconds
CheckAllWarning               PASS      34.29 seconds
CheckSparse                   PASS      36.95 seconds
BuildKernel32                 PASS      30.17 seconds
CheckKernelLLVM               PASS      31.51 seconds
TestRunnerSetup               PASS      694.21 seconds
TestRunner_iso-tester         PASS      11.54 seconds
IncrementalBuild              PASS      28.16 seconds

https://github.com/bluez/bluetooth-next/pull/1042

---
Regards,
Linux Bluetooth

maintainer Applied
#2 lore raw
In reply to Andrey Misiurov
Quoted 3 lines

Commit 1702f12cf59a ("Bluetooth: ISO: fix use-after-free of listener socket in iso_conn_ready"), the 6.1.y backport of upstream 560bef609fa5, puts the listener when it is no longer listening.

Queued for 6.1, thanks.

Signature · 2 lines
Thanks,
Sasha