* [PATCH v2] Bluetooth: mgmt: fix race in read_unconf_index_list()
@ 2026-09-15 15:59 Aldo Ariel Panzardo
2026-09-15 17:43 ` [v2] " bluez.test.bot
2026-09-16 18:00 ` [PATCH v2] " patchwork-bot+bluetooth
0 siblings, 2 replies; 3+ messages in thread
From: Aldo Ariel Panzardo @ 2026-09-15 15:59 UTC (permalink / raw)
To: Luiz Augusto von Dentz
Cc: linux-bluetooth, linux-kernel, stable, Aldo Ariel Panzardo
read_unconf_index_list() counts unconfigured controllers before allocating
its response, then checks the device flags again while filling it.
hci_dev_list_lock stabilizes list membership, but it does not serialize the
per-device flags. During asynchronous controller setup, the worker can set
HCI_UNCONFIGURED and clear HCI_SETUP between the two passes. A controller
omitted from the allocation count can then become eligible for the fill
pass, causing an out-of-bounds write to rp->index[].
Allocate space for every device on hci_dev_list. Since list membership
cannot change while hci_dev_list_lock is held, the response remains large
enough regardless of flag transitions. The reported count and response
length still include only eligible unconfigured controllers.
Fixes: 73d1df2a7a10 ("Bluetooth: Add support for Read Unconfigured Index List command")
Cc: stable@vger.kernel.org
Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
---
net/bluetooth/mgmt.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 167d75e34..1f6691278 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -496,13 +496,9 @@ static int read_unconf_index_list(struct sock *sk, struct hci_dev *hdev,
read_lock(&hci_dev_list_lock);
- count = 0;
- list_for_each_entry(d, &hci_dev_list, list) {
- if (hci_dev_test_flag(d, HCI_UNCONFIGURED))
- count++;
- }
+ count = list_count_nodes(&hci_dev_list);
- rp_len = sizeof(*rp) + (2 * count);
+ rp_len = sizeof(*rp) + (sizeof(__le16) * count);
rp = kmalloc(rp_len, GFP_ATOMIC);
if (!rp) {
read_unlock(&hci_dev_list_lock);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [v2] Bluetooth: mgmt: fix race in read_unconf_index_list()
2026-09-15 15:59 [PATCH v2] Bluetooth: mgmt: fix race in read_unconf_index_list() Aldo Ariel Panzardo
@ 2026-09-15 17:43 ` bluez.test.bot
2026-09-16 18:00 ` [PATCH v2] " patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-09-15 17:43 UTC (permalink / raw)
To: linux-bluetooth, qwe.aldo
[-- Attachment #1: Type: text/plain, Size: 1403 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/series/1165728/
---Test result---
Test Summary:
CheckPatch PASS 0.74 seconds
VerifyFixes PASS 0.12 seconds
VerifySignedoff PASS 0.12 seconds
GitLint PASS 0.33 seconds
SubjectPrefix PASS 0.11 seconds
BuildKernel PASS 29.77 seconds
CheckAllWarning PASS 33.94 seconds
CheckSparse PASS 37.81 seconds
BuildKernel32 PASS 29.75 seconds
CheckKernelLLVM PASS 35.40 seconds
TestRunnerSetup PASS 818.19 seconds
TestRunner_mgmt-tester FAIL 9.09 seconds
TestRunner_mesh-tester FAIL 7.86 seconds
IncrementalBuild PASS 28.25 seconds
Details
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
No test result found
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
No test result found
https://github.com/bluez/bluetooth-next/pull/773
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] Bluetooth: mgmt: fix race in read_unconf_index_list()
2026-09-15 15:59 [PATCH v2] Bluetooth: mgmt: fix race in read_unconf_index_list() Aldo Ariel Panzardo
2026-09-15 17:43 ` [v2] " bluez.test.bot
@ 2026-09-16 18:00 ` patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2026-09-16 18:00 UTC (permalink / raw)
To: Aldo Ariel Panzardo; +Cc: luiz.dentz, linux-bluetooth, linux-kernel, stable
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Tue, 15 Sep 2026 12:59:52 -0300 you wrote:
> read_unconf_index_list() counts unconfigured controllers before allocating
> its response, then checks the device flags again while filling it.
>
> hci_dev_list_lock stabilizes list membership, but it does not serialize the
> per-device flags. During asynchronous controller setup, the worker can set
> HCI_UNCONFIGURED and clear HCI_SETUP between the two passes. A controller
> omitted from the allocation count can then become eligible for the fill
> pass, causing an out-of-bounds write to rp->index[].
>
> [...]
Here is the summary with links:
- [v2] Bluetooth: mgmt: fix race in read_unconf_index_list()
https://git.kernel.org/bluetooth/bluetooth-next/c/b5dbb41b212c
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-09-16 18:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-15 15:59 [PATCH v2] Bluetooth: mgmt: fix race in read_unconf_index_list() Aldo Ariel Panzardo
2026-09-15 17:43 ` [v2] " bluez.test.bot
2026-09-16 18:00 ` [PATCH v2] " patchwork-bot+bluetooth
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.