* [PATCH v3] Bluetooth: ISO: fix use-after-free of listener socket in iso_conn_ready
@ 2026-08-18 11:33 Hang Nan
2026-08-18 12:08 ` [v3] " bluez.test.bot
2026-08-18 18:08 ` [PATCH v3] " Luiz Augusto von Dentz
0 siblings, 2 replies; 3+ messages in thread
From: Hang Nan @ 2026-08-18 11:33 UTC (permalink / raw)
To: linux-bluetooth; +Cc: marcel, luiz.dentz, linux-kernel, stable, pav
iso_conn_ready() looks up the BIS listener socket with iso_get_sock(),
which takes a reference, and then, without re-checking its state,
creates a child socket from it:
parent = iso_get_sock(hdev, ...);
if (!parent)
return;
lock_sock(parent);
sk = iso_sock_alloc(sock_net(parent), NULL, BTPROTO_ISO, ...);
...
iso_chan_add(conn, sk, parent);
...
release_sock(parent);
sock_put(parent);
If the listener socket is closed concurrently, between iso_get_sock()
and lock_sock(), the reference taken by iso_get_sock() may be the last
one: the close path drops the link-list reference, and once
iso_conn_ready() drops its own reference at the end of the function the
socket is freed. The child socket, however, is already linked to the
freed parent, and a later disconnect of the child runs iso_chan_del()
-> bt_accept_unlink(), which dereferences the dangling parent pointer
into the freed accept queue (a use-after-free). The same dangling
pointer is also dereferenced through parent->***() in
iso_chan_del().
Fix it the same way the connected (non-BIS) path was fixed in commit
0d255e63fcf3 ("Bluetooth: ISO: hold sk properly in iso_conn_ready"):
after taking the socket lock, re-check that the parent is still a
listening, alive socket, and bail out otherwise.
Fixes: ccf74f2390d60 ("Bluetooth: Add BTPROTO_ISO socket type")
Cc: stable@vger.kernel.org
Signed-off-by: Hang Nan <2122295973@qq.com>
---
Changes in v3:
- Move the changelog below the "---" separator so it is not part
of the commit message
- Shorten the comment in iso_conn_ready()
Changes in v2:
- Fix GitLint B3: replace hard tabs with spaces in the commit
message code snippet (no functional change)
net/bluetooth/iso.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c
index aa2ce78f56a2..069fc87a4e18 100644
--- a/net/bluetooth/iso.c
+++ b/net/bluetooth/iso.c
@@ -2277,6 +2277,14 @@ static void iso_conn_ready(struct iso_conn *conn)
lock_sock(parent);
+ /* The listener may have been closed concurrently. */
+ if (parent->sk_state != BT_LISTEN ||
+ (parent, SOCK_ZAPPED)) {
+ release_sock_flagsock(parent);
+ sock_put(parent);
+ return;
+ }
+
sk = iso_sock_alloc(sock_net(parent), NULL,
BTPROTO_ISO, GFP_ATOMIC, 0);
if (!sk) {
^ permalink raw reply related [flat|nested] 3+ messages in thread* RE: [v3] Bluetooth: ISO: fix use-after-free of listener socket in iso_conn_ready
2026-08-18 11:33 [PATCH v3] Bluetooth: ISO: fix use-after-free of listener socket in iso_conn_ready Hang Nan
@ 2026-08-18 12:08 ` bluez.test.bot
2026-08-18 18:08 ` [PATCH v3] " Luiz Augusto von Dentz
1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-08-18 12:08 UTC (permalink / raw)
To: linux-bluetooth, 2122295973
[-- Attachment #1: Type: text/plain, Size: 8414 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/project/bluetooth/list/?series=1147774
---Test result---
Test Summary:
CheckPatch PASS 0.62 seconds
VerifyFixes PASS 0.09 seconds
VerifySignedoff PASS 0.09 seconds
GitLint PASS 0.25 seconds
SubjectPrefix PASS 0.08 seconds
BuildKernel FAIL 27.01 seconds
CheckAllWarning FAIL 29.51 seconds
CheckSparse FAIL 28.14 seconds
BuildKernel32 FAIL 25.77 seconds
CheckKernelLLVM SKIP 0.00 seconds
TestRunnerSetup FAIL 480.59 seconds
TestRunner_iso-tester FAIL 0.09 seconds
IncrementalBuild FAIL 24.59 seconds
Details
##############################
Test: BuildKernel - FAIL
Desc: Build Kernel for Bluetooth
Output:
net/bluetooth/iso.c: In function ‘iso_conn_ready’:
net/bluetooth/iso.c:2282:14: warning: left-hand operand of comma expression has no effect [-Wunused-value]
2282 | (parent, SOCK_ZAPPED)) {
| ^
net/bluetooth/iso.c:2283:4: error: implicit declaration of function ‘release_sock_flagsock’ [-Werror=implicit-function-declaration]
2283 | release_sock_flagsock(parent);
| ^~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:289: net/bluetooth/iso.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:549: net/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:549: net] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/github/workspace/src/src/Makefile:2187: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
##############################
Test: CheckAllWarning - FAIL
Desc: Run linux kernel with all warning enabled
Output:
net/bluetooth/iso.c: In function ‘iso_conn_ready’:
net/bluetooth/iso.c:2282:14: warning: left-hand operand of comma expression has no effect [-Wunused-value]
2282 | (parent, SOCK_ZAPPED)) {
| ^
net/bluetooth/iso.c:2283:4: error: implicit declaration of function ‘release_sock_flagsock’ [-Werror=implicit-function-declaration]
2283 | release_sock_flagsock(parent);
| ^~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:289: net/bluetooth/iso.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:549: net/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:549: net] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/github/workspace/src/src/Makefile:2187: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
##############################
Test: CheckSparse - FAIL
Desc: Run sparse tool with linux kernel
Output:
/github/workspace/src/src/Makefile:1283: C=1 specified, but sparse is not available or not up to date
/github/workspace/src/src/Makefile:1283: C=1 specified, but sparse is not available or not up to date
net/bluetooth/iso.c: In function ‘iso_conn_ready’:
net/bluetooth/iso.c:2282:14: warning: left-hand operand of comma expression has no effect [-Wunused-value]
2282 | (parent, SOCK_ZAPPED)) {
| ^
net/bluetooth/iso.c:2283:4: error: implicit declaration of function ‘release_sock_flagsock’ [-Werror=implicit-function-declaration]
2283 | release_sock_flagsock(parent);
| ^~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:289: net/bluetooth/iso.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:549: net/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:549: net] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/github/workspace/src/src/Makefile:2187: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
##############################
Test: BuildKernel32 - FAIL
Desc: Build 32bit Kernel for Bluetooth
Output:
net/bluetooth/iso.c: In function ‘iso_conn_ready’:
net/bluetooth/iso.c:2282:14: warning: left-hand operand of comma expression has no effect [-Wunused-value]
2282 | (parent, SOCK_ZAPPED)) {
| ^
net/bluetooth/iso.c:2283:4: error: implicit declaration of function ‘release_sock_flagsock’ [-Werror=implicit-function-declaration]
2283 | release_sock_flagsock(parent);
| ^~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:289: net/bluetooth/iso.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:549: net/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:549: net] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/github/workspace/src/src/Makefile:2187: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis
Output:
Clang not found
##############################
Test: TestRunnerSetup - FAIL
Desc: Setup kernel and bluez for test-runner
Output:
Kernel:
net/bluetooth/iso.c: In function ‘iso_conn_ready’:
net/bluetooth/iso.c:2282:14: warning: left-hand operand of comma expression has no effect [-Wunused-value]
2282 | (parent, SOCK_ZAPPED)) {
| ^
net/bluetooth/iso.c:2283:4: error: implicit declaration of function ‘release_sock_flagsock’ [-Werror=implicit-function-declaration]
2283 | release_sock_flagsock(parent);
| ^~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:289: net/bluetooth/iso.o] Error 1
make[3]: *** [scripts/Makefile.build:549: net/bluetooth] Error 2
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [scripts/Makefile.build:549: net] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/github/workspace/src/src/Makefile:2187: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
No kernel image found
##############################
Test: IncrementalBuild - FAIL
Desc: Incremental build with the patches in the series
Output:
net/bluetooth/iso.c: In function ‘iso_conn_ready’:
net/bluetooth/iso.c:2282:14: warning: left-hand operand of comma expression has no effect [-Wunused-value]
2282 | (parent, SOCK_ZAPPED)) {
| ^
net/bluetooth/iso.c:2283:4: error: implicit declaration of function ‘release_sock_flagsock’ [-Werror=implicit-function-declaration]
2283 | release_sock_flagsock(parent);
| ^~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:289: net/bluetooth/iso.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:549: net/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:549: net] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/github/workspace/src/src/Makefile:2187: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
[v3] Bluetooth: ISO: fix use-after-free of listener socket in iso_conn_ready
net/bluetooth/iso.c: In function ‘iso_conn_ready’:
net/bluetooth/iso.c:2282:14: warning: left-hand operand of comma expression has no effect [-Wunused-value]
2282 | (parent, SOCK_ZAPPED)) {
| ^
net/bluetooth/iso.c:2283:4: error: implicit declaration of function ‘release_sock_flagsock’ [-Werror=implicit-function-declaration]
2283 | release_sock_flagsock(parent);
| ^~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:289: net/bluetooth/iso.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:549: net/bluetooth] Error 2
make[2]: *** [scripts/Makefile.build:549: net] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/github/workspace/src/src/Makefile:2187: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
https://github.com/bluez/bluetooth-next/pull/608
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v3] Bluetooth: ISO: fix use-after-free of listener socket in iso_conn_ready
2026-08-18 11:33 [PATCH v3] Bluetooth: ISO: fix use-after-free of listener socket in iso_conn_ready Hang Nan
2026-08-18 12:08 ` [v3] " bluez.test.bot
@ 2026-08-18 18:08 ` Luiz Augusto von Dentz
1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2026-08-18 18:08 UTC (permalink / raw)
To: Hang Nan; +Cc: linux-bluetooth, marcel, linux-kernel, stable, pav
Hi Hang,
On Tue, Aug 18, 2026 at 7:33 AM Hang Nan <2122295973@qq.com> wrote:
>
> iso_conn_ready() looks up the BIS listener socket with iso_get_sock(),
> which takes a reference, and then, without re-checking its state,
> creates a child socket from it:
>
> parent = iso_get_sock(hdev, ...);
> if (!parent)
> return;
>
> lock_sock(parent);
> sk = iso_sock_alloc(sock_net(parent), NULL, BTPROTO_ISO, ...);
> ...
> iso_chan_add(conn, sk, parent);
> ...
> release_sock(parent);
> sock_put(parent);
>
> If the listener socket is closed concurrently, between iso_get_sock()
> and lock_sock(), the reference taken by iso_get_sock() may be the last
> one: the close path drops the link-list reference, and once
> iso_conn_ready() drops its own reference at the end of the function the
> socket is freed. The child socket, however, is already linked to the
> freed parent, and a later disconnect of the child runs iso_chan_del()
> -> bt_accept_unlink(), which dereferences the dangling parent pointer
> into the freed accept queue (a use-after-free). The same dangling
> pointer is also dereferenced through parent->***() in
> iso_chan_del().
>
> Fix it the same way the connected (non-BIS) path was fixed in commit
> 0d255e63fcf3 ("Bluetooth: ISO: hold sk properly in iso_conn_ready"):
> after taking the socket lock, re-check that the parent is still a
> listening, alive socket, and bail out otherwise.
>
> Fixes: ccf74f2390d60 ("Bluetooth: Add BTPROTO_ISO socket type")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hang Nan <2122295973@qq.com>
> ---
> Changes in v3:
> - Move the changelog below the "---" separator so it is not part
> of the commit message
> - Shorten the comment in iso_conn_ready()
>
> Changes in v2:
> - Fix GitLint B3: replace hard tabs with spaces in the commit
> message code snippet (no functional change)
>
> net/bluetooth/iso.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c
> index aa2ce78f56a2..069fc87a4e18 100644
> --- a/net/bluetooth/iso.c
> +++ b/net/bluetooth/iso.c
> @@ -2277,6 +2277,14 @@ static void iso_conn_ready(struct iso_conn *conn)
>
> lock_sock(parent);
>
> + /* The listener may have been closed concurrently. */
> + if (parent->sk_state != BT_LISTEN ||
> + (parent, SOCK_ZAPPED)) {
> + release_sock_flagsock(parent);
> + sock_put(parent);
> + return;
> + }
Looks like there is a typo and this should have been release_sock
rather than release_sock_flagsock (or there is a new function called
that introduced via some other tree?)
> sk = iso_sock_alloc(sock_net(parent), NULL,
> BTPROTO_ISO, GFP_ATOMIC, 0);
> if (!sk) {
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-18 18:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-18 11:33 [PATCH v3] Bluetooth: ISO: fix use-after-free of listener socket in iso_conn_ready Hang Nan
2026-08-18 12:08 ` [v3] " bluez.test.bot
2026-08-18 18:08 ` [PATCH v3] " Luiz Augusto von Dentz
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.