Skip to content

Conversation

@BluezTestBot
Copy link
Owner

When protocol sets HCI_PROTO_DEFER, hci_conn_request_evt() calls
hci_connect_cfm(conn) without hdev->lock. Only SCO and ISO set
HCI_PROTO_DEFER (for listening socket with defer setup).

Nothing guarantees conn remains alive after unlock. In all other code
paths (also listening socket without defer setup), hci_connect_cfm(conn)
is called with hdev->lock held.

Fix by holding the lock.

Fixes: 70c4642 ("Bluetooth: Refactor connection request handling")
Signed-off-by: Pauli Virtanen pav@iki.fi

Notes:
These two patches are pending some further testing in practice, but
lockdep is now happy about how this works.

net/bluetooth/hci_event.c | 3 ---
1 file changed, 3 deletions(-)

tedd-an and others added 3 commits December 3, 2025 20:30
This patch adds workflow files for ci:

[sync.yml]
 - The workflow file for scheduled work
 - Sync the repo with upstream repo and rebase the workflow branch
 - Review the patches in the patchwork and creates the PR if needed

[ci.yml]
 - The workflow file for CI tasks
 - Run CI tests when PR is created

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
When protocol sets HCI_PROTO_DEFER, hci_conn_request_evt() calls
hci_connect_cfm(conn) without hdev->lock.  Only SCO and ISO set
HCI_PROTO_DEFER (for listening socket with defer setup).

Nothing guarantees conn remains alive after unlock.  In all other code
paths (also listening socket without defer setup), hci_connect_cfm(conn)
is called with hdev->lock held.

Fix by holding the lock.

Fixes: 70c4642 ("Bluetooth: Refactor connection request handling")
Signed-off-by: Pauli Virtanen <pav@iki.fi>
hci_conn::sco_data does not own a refcount to sco_conn and the field is
updated also without hdev->lock, so it cannot be safely accessed in
sco_connect_cfm(). UAF observed due to wrong refcounting is reported.

Revise the sco_conn ownership and locking:

- hci_conn::sco_data owns refcount; field protected by hdev->lock
- sco_pi(sk)::conn owns refcount; field protected by lock_sock()
- sco_conn::hcon and sk own no refcount; fields protected by conn->lock

Use lockdep + Sparse to try to enforce proper locking.  Add locks where
they were missing.

Use separate functions that detach sco_conn from hcon and sk. Don't do
operations that take locks in sco_conn_free() so that sco_conn_put() is
safe to use with locks.

Handle the race when hcon obtains locked sk via sco_conn, which requires
sco_conn_unlock due to lock ordering.

In sco_conn_ready() fix calling sleeping functions under spinlock.

Fixes: ecb9a84 ("Bluetooth: SCO: Fix UAF on sco_conn_free")
Reported-by: Cen Zhang <rollkingzzc@gmail.com>
Closes: https://lore.kernel.org/linux-bluetooth/44091d60.3570.19a40a89dd8.Coremail.zzzccc427@163.com/
Signed-off-by: Pauli Virtanen <pav@iki.fi>
@github-actions
Copy link

github-actions bot commented Dec 9, 2025

CheckPatch
Desc: Run checkpatch.pl script
Duration: 0.35 seconds
Result: PENDING

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

GitLint
Desc: Run gitlint
Duration: 0.38 seconds
Result: PENDING

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

SubjectPrefix
Desc: Check subject contains "Bluetooth" prefix
Duration: 0.22 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

BuildKernel
Desc: Build Kernel for Bluetooth
Duration: 25.26 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

CheckAllWarning
Desc: Run linux kernel with all warning enabled
Duration: 29.22 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

CheckSparse
Desc: Run sparse tool with linux kernel
Duration: 32.99 seconds
Result: WARNING
Output:

net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):net/bluetooth/sco.c: note: in included file:./include/net/bluetooth/hci_core.h:153:35: warning: array of flexible structures

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

BuildKernel32
Desc: Build 32bit Kernel for Bluetooth
Duration: 26.25 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

TestRunnerSetup
Desc: Setup kernel and bluez for test-runner
Duration: 562.60 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

TestRunner_l2cap-tester
Desc: Run l2cap-tester with test-runner
Duration: 24.39 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

TestRunner_iso-tester
Desc: Run iso-tester with test-runner
Duration: 83.69 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

TestRunner_bnep-tester
Desc: Run bnep-tester with test-runner
Duration: 6.28 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

TestRunner_mgmt-tester
Desc: Run mgmt-tester with test-runner
Duration: 114.47 seconds
Result: FAIL
Output:

Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4

Failed Test Cases
Read Exp Feature - Success                           Failed       0.103 seconds

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

TestRunner_rfcomm-tester
Desc: Run rfcomm-tester with test-runner
Duration: 9.40 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

TestRunner_sco-tester
Desc: Run sco-tester with test-runner
Duration: 14.35 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

TestRunner_ioctl-tester
Desc: Run ioctl-tester with test-runner
Duration: 10.21 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

TestRunner_mesh-tester
Desc: Run mesh-tester with test-runner
Duration: 11.56 seconds
Result: FAIL
Output:

Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0

Failed Test Cases
Mesh - Send cancel - 1                               Timed out    1.898 seconds
Mesh - Send cancel - 2                               Timed out    1.997 seconds

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

TestRunner_smp-tester
Desc: Run smp-tester with test-runner
Duration: 10.89 seconds
Result: FAIL
Output:

WARNING: CPU: 0 PID: 56 at net/bluetooth/hci_conn.c:567 hci_conn_timeout+0x15a/0x190
Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

TestRunner_userchan-tester
Desc: Run userchan-tester with test-runner
Duration: 6.56 seconds
Result: PASS

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

IncrementalBuild
Desc: Incremental build with the patches in the series
Duration: 0.83 seconds
Result: PENDING

@github-actions github-actions bot force-pushed the workflow branch 4 times, most recently from dbdc24e to 7b93eea Compare December 15, 2025 18:36
@github-actions github-actions bot force-pushed the workflow branch 4 times, most recently from 1e7b027 to 8eabaf6 Compare December 18, 2025 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants