Bluetooth: mgmt: Fix race condition in mesh handling
Subsystems (3)
PATCH v9 1/1 Bluetooth: mgmt: Fix race condition in mesh handling
This patch addresses race conditions in mesh handling within mgmt_util.c.
The functions mgmt_mesh_add and mgmt_mesh_find modify or traverse the mesh_pending list without locking. This patch uses guard(mutex) with the existing mgmt_pending_lock to protect the critical sections, as suggested by maintainers in previous reviews.
Note: The heap buffer overflow fix previously included in earlier versions of this patch series has already been merged upstream.
--- net/bluetooth/mgmt_util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/bluetooth/mgmt_util.c +3 -2
@@ -397,8 +397,7 @@ struct mgmt_mesh_tx *mgmt_mesh_find(struct hci_dev *hdev, u8 handle) {struct mgmt_mesh_tx *mesh_tx; -if (list_empty (&hdev->mesh_pending)) -return NULL ; +guard (mutex)(&hdev->mgmt_pending_lock);list_for_each_entry (mesh_tx, &hdev->mesh_pending, list) {if (mesh_tx->handle == handle)
@@ -420,6 +419,8 @@ struct mgmt_mesh_tx *mgmt_mesh_add(struct sock *sk, struct hci_dev *hdev,if (!mesh_tx)return NULL ; +guard (mutex)(&hdev->mgmt_pending_lock); + hdev->mesh_send_ref++;if (!hdev->mesh_send_ref) hdev->mesh_send_ref++;
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/project/bluetooth/list/?series=1054169
---Test result---
Test Summary:
CheckPatch PENDING 0.30 seconds GitLint PENDING 0.24 seconds SubjectPrefix PASS 0.11 seconds BuildKernel PASS 26.27 seconds CheckAllWarning PASS 28.36 seconds CheckSparse PASS 32.64 seconds BuildKernel32 PASS 25.68 seconds TestRunnerSetup PASS 564.35 seconds TestRunner_l2cap-tester PASS 29.19 seconds TestRunner_iso-tester PASS 86.52 seconds TestRunner_bnep-tester PASS 6.58 seconds TestRunner_mgmt-tester FAIL 129.21 seconds TestRunner_rfcomm-tester PASS 9.87 seconds TestRunner_sco-tester FAIL 14.96 seconds TestRunner_ioctl-tester PASS 10.59 seconds TestRunner_mesh-tester FAIL 12.74 seconds TestRunner_smp-tester PASS 9.04 seconds TestRunner_userchan-tester PASS 7.01 seconds IncrementalBuild PENDING 0.60 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
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.113 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.769 seconds Mesh - Send cancel - 2 Timed out 1.992 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 8 lines · On Sat, 14 Feb 2026 13:06:10 +0000 you wrote:
This patch addresses race conditions in mesh handling within
mgmt_util.c.The functions
mgmt_mesh_addandmgmt_mesh_findmodify or traverse themesh_pendinglist without locking. This patch uses guard(mutex) with the existingmgmt_pending_lockto protect the critical sections, as suggested by maintainers in previous reviews.[...]
Here is the summary with links:
- [v9] Bluetooth: mgmt: Fix race condition in mesh handling
https://git.kernel.org/bluetooth/bluetooth-next/c/003ca042a386
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html