* [PATCH] Bluetooth: SCO: Fix use-after-free in sco_conn_ready() due to missing sock_hold
@ 2026-03-19 15:12 Hyunwoo Kim
2026-03-19 16:37 ` bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Hyunwoo Kim @ 2026-03-19 15:12 UTC (permalink / raw)
To: marcel, johan.hedberg, luiz.dentz; +Cc: linux-bluetooth, imv4bel
sco_get_sock_listen() returns a pointer to a listening socket without
incrementing its reference count. If the listening socket is concurrently
closed and freed before sco_conn_ready() calls lock_sock(parent), a
use-after-free occurs. The listening socket has no sco_conn association
(sco_pi(sk)->conn == NULL), so sco_conn_lock does not prevent it.
Fix by adding sock_hold()/sock_put() in sco_get_sock_listen() following
the iso_get_sock() pattern.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
---
net/bluetooth/sco.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index e7db50165879..7ad6d9208de5 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -449,14 +449,23 @@ static struct sock *sco_get_sock_listen(bdaddr_t *src)
continue;
/* Exact match. */
- if (!bacmp(&sco_pi(sk)->src, src))
+ if (!bacmp(&sco_pi(sk)->src, src)) {
+ sock_hold(sk);
break;
+ }
/* Closest match */
- if (!bacmp(&sco_pi(sk)->src, BDADDR_ANY))
+ if (!bacmp(&sco_pi(sk)->src, BDADDR_ANY)) {
+ if (sk1)
+ sock_put(sk1);
sk1 = sk;
+ sock_hold(sk1);
+ }
}
+ if (sk && sk1)
+ sock_put(sk1);
+
read_unlock(&sco_sk_list.lock);
return sk ? sk : sk1;
@@ -1376,6 +1385,7 @@ static void sco_conn_ready(struct sco_conn *conn)
if (!sk) {
release_sock(parent);
sco_conn_unlock(conn);
+ sock_put(parent);
return;
}
@@ -1399,6 +1409,7 @@ static void sco_conn_ready(struct sco_conn *conn)
release_sock(parent);
sco_conn_unlock(conn);
+ sock_put(parent);
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: Bluetooth: SCO: Fix use-after-free in sco_conn_ready() due to missing sock_hold
2026-03-19 15:12 [PATCH] Bluetooth: SCO: Fix use-after-free in sco_conn_ready() due to missing sock_hold Hyunwoo Kim
@ 2026-03-19 16:37 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-03-19 16:37 UTC (permalink / raw)
To: linux-bluetooth, imv4bel
[-- Attachment #1: Type: text/plain, Size: 3440 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=1069343
---Test result---
Test Summary:
CheckPatch PENDING 0.45 seconds
GitLint PENDING 0.26 seconds
SubjectPrefix PASS 0.07 seconds
BuildKernel PASS 26.66 seconds
CheckAllWarning PASS 29.30 seconds
CheckSparse PASS 28.05 seconds
BuildKernel32 PASS 25.49 seconds
TestRunnerSetup PASS 576.43 seconds
TestRunner_l2cap-tester FAIL 29.41 seconds
TestRunner_iso-tester FAIL 35.97 seconds
TestRunner_bnep-tester PASS 6.38 seconds
TestRunner_mgmt-tester FAIL 115.59 seconds
TestRunner_rfcomm-tester PASS 9.66 seconds
TestRunner_sco-tester FAIL 14.31 seconds
TestRunner_ioctl-tester PASS 10.16 seconds
TestRunner_mesh-tester FAIL 12.55 seconds
TestRunner_smp-tester FAIL 11.03 seconds
TestRunner_userchan-tester PASS 6.69 seconds
IncrementalBuild PENDING 0.55 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: TestRunner_l2cap-tester - FAIL
Desc: Run l2cap-tester with test-runner
Output:
Total: 96, Passed: 94 (97.9%), Failed: 2, Not Run: 0
Failed Test Cases
L2CAP BR/EDR Server - Set PHY 1M Failed 0.123 seconds
L2CAP BR/EDR Server - Set PHY 2M Failed 0.122 seconds
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
BUG: KASAN: slab-use-after-free in le_read_features_complete+0x7e/0x2b0
Total: 141, Passed: 141 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4
Failed Test Cases
Read Exp Feature - Success Failed 0.106 seconds
##############################
Test: TestRunner_sco-tester - FAIL
Desc: Run sco-tester with test-runner
Output:
WARNING: possible circular locking dependency detected
BUG: sleeping function called from invalid context at net/core/sock.c:3782
Total: 30, Passed: 30 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 1 Timed out 2.738 seconds
Mesh - Send cancel - 2 Timed out 1.999 seconds
##############################
Test: TestRunner_smp-tester - FAIL
Desc: Run smp-tester with test-runner
Output:
WARNING: net/bluetooth/hci_conn.c:567 at hci_conn_timeout+0x15a/0x190, CPU#0: kworker/u5:2/54
Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-19 16:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 15:12 [PATCH] Bluetooth: SCO: Fix use-after-free in sco_conn_ready() due to missing sock_hold Hyunwoo Kim
2026-03-19 16:37 ` 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