* [PATCH v9] Bluetooth: mgmt: Fix race condition in mesh handling
@ 2026-02-14 13:06 Maiquel Paiva
2026-02-14 14:02 ` [v9] " bluez.test.bot
2026-02-17 18:50 ` [PATCH v9] " patchwork-bot+bluetooth
0 siblings, 2 replies; 3+ messages in thread
From: Maiquel Paiva @ 2026-02-14 13:06 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz, gregkh, marcel; +Cc: stable, Maiquel Paiva
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.
Fixes: b338d91703fa ("Bluetooth: Implement support for Mesh")
Cc: stable@vger.kernel.org
Signed-off-by: Maiquel Paiva <maiquelpaiva@gmail.com>
---
net/bluetooth/mgmt_util.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/mgmt_util.c b/net/bluetooth/mgmt_util.c
index 6ccc3a3f68de..eee4bc05f6e5 100644
--- a/net/bluetooth/mgmt_util.c
+++ b/net/bluetooth/mgmt_util.c
@@ -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++;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [v9] Bluetooth: mgmt: Fix race condition in mesh handling
2026-02-14 13:06 [PATCH v9] Bluetooth: mgmt: Fix race condition in mesh handling Maiquel Paiva
@ 2026-02-14 14:02 ` bluez.test.bot
2026-02-17 18:50 ` [PATCH v9] " patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-02-14 14:02 UTC (permalink / raw)
To: linux-bluetooth, maiquelpaiva
[-- Attachment #1: Type: text/plain, Size: 2593 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=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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v9] Bluetooth: mgmt: Fix race condition in mesh handling
2026-02-14 13:06 [PATCH v9] Bluetooth: mgmt: Fix race condition in mesh handling Maiquel Paiva
2026-02-14 14:02 ` [v9] " bluez.test.bot
@ 2026-02-17 18:50 ` patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2026-02-17 18:50 UTC (permalink / raw)
To: Maiquel Paiva; +Cc: linux-bluetooth, luiz.dentz, gregkh, marcel, stable
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
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_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.
>
> [...]
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-17 18:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-14 13:06 [PATCH v9] Bluetooth: mgmt: Fix race condition in mesh handling Maiquel Paiva
2026-02-14 14:02 ` [v9] " bluez.test.bot
2026-02-17 18:50 ` [PATCH v9] " patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox