* [PATCH bluetooth v1] Bluetooth: hci_core: Initialize LTK before publication
@ 2026-10-19 10:56 Binbin Deng
2026-10-19 14:42 ` [v1] " bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Binbin Deng @ 2026-10-19 10:56 UTC (permalink / raw)
To: marcel, luiz.dentz, johan.hedberg
Cc: linux-bluetooth, linux-kernel, Binbin Deng
hci_add_ltk() publishes a newly allocated LTK on hdev->long_term_keys
before initializing its address, type, value, authentication state,
encryption size, EDIV, and random value. hci_find_ltk() and the debugfs
long_term_keys_show() traverse this list under RCU and can therefore see
a zero or partially initialized key before those stores complete.
The race is reachable by racing an LTK addition with another CPU looking
up or dumping long-term keys. For example, userspace can issue
MGMT_OP_LOAD_LONG_TERM_KEYS while another process reads the corresponding
debugfs file.
Initialize all fields of a new LTK before list_add_rcu() makes it visible
to RCU readers. Existing LTKs remain published and continue to be updated
in place.
Found during a static-analysis-assisted audit: candidate sites were
surfaced by a Coccinelle rule, and the reader/writer paths were
confirmed by LLM-assisted (GLM-5.3) code inspection. The issue was
not observed at runtime; it is identified by code inspection only.
Fixes: 970d0f1b2803 ("Bluetooth: Convert LTK list to RCU")
Assisted-by: GLM-5.3 coccinelle
Signed-off-by: Binbin Deng <18983559317@163.com>
---
net/bluetooth/hci_core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index d183efaf9063..9500da51af85 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1297,7 +1297,6 @@ struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,
key = kzalloc_obj(*key);
if (!key)
return NULL;
- list_add_rcu(&key->list, &hdev->long_term_keys);
}
bacpy(&key->bdaddr, bdaddr);
@@ -1309,6 +1308,9 @@ struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,
key->enc_size = enc_size;
key->type = type;
+ if (!old_key)
+ list_add_rcu(&key->list, &hdev->long_term_keys);
+
return key;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [v1] Bluetooth: hci_core: Initialize LTK before publication
2026-10-19 10:56 [PATCH bluetooth v1] Bluetooth: hci_core: Initialize LTK before publication Binbin Deng
@ 2026-10-19 14:42 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-10-19 14:42 UTC (permalink / raw)
To: linux-bluetooth, 18983559317
[-- Attachment #1: Type: text/plain, Size: 1605 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/1188810/
---Test result---
Test Summary:
CheckPatch PASS 0.85 seconds
VerifyFixes PASS 0.13 seconds
VerifySignedoff PASS 0.13 seconds
GitLint PASS 0.34 seconds
SubjectPrefix PASS 0.12 seconds
BuildKernel PASS 29.77 seconds
CheckAllWarning PASS 34.06 seconds
CheckSparse PASS 36.67 seconds
BuildKernel32 PASS 30.36 seconds
CheckKernelLLVM PASS 33.16 seconds
TestRunnerSetup PASS 720.35 seconds
TestRunner_l2cap-tester PASS 12.80 seconds
TestRunner_iso-tester PASS 10.91 seconds
TestRunner_bnep-tester PASS 3.16 seconds
TestRunner_mgmt-tester PASS 88.00 seconds
TestRunner_rfcomm-tester PASS 4.51 seconds
TestRunner_sco-tester PASS 5.65 seconds
TestRunner_ioctl-tester PASS 4.72 seconds
TestRunner_mesh-tester PASS 5.56 seconds
TestRunner_smp-tester PASS 4.40 seconds
TestRunner_userchan-tester PASS 3.23 seconds
TestRunner_6lowpan-tester PASS 4.48 seconds
IncrementalBuild PASS 28.19 seconds
https://github.com/bluez/bluetooth-next/pull/964
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-19 14:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-19 10:56 [PATCH bluetooth v1] Bluetooth: hci_core: Initialize LTK before publication Binbin Deng
2026-10-19 14:42 ` [v1] " 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