[PATCH 2/2] Bluetooth: btintel: hold req_lock when triggering coredump

From: Praneeth Balasubramanian

Date: Sat Dec 05 2026 - 01:36:37 EST


btintel_coredump() calls __hci_cmd_sync() while running from the
devcoredump sysfs store, which only holds the device lock. The
__hci_cmd_sync() contract requires hdev->req_lock. Without it the
coredump trigger command shares hdev->req_status and hdev->req_rsp with
the cmd_sync work.

A management command issued through MGMT_OP_HCI_CMD_SYNC runs in that
work with req_lock held. If both callers are in flight, a single
completion stores one skb in hdev->req_rsp and wakes both waiters. Each
can read that skb before the other clears the pointer. One path frees it
and the other frees it again, a use-after-free followed by a double
free.

The coredump sysfs file is only writable by root, so the exposure is
limited. I found no path in btusb that takes req_lock before the device
lock, so taking req_lock here should not deadlock.

Wrap the trigger command with hci_req_sync_lock() and
hci_req_sync_unlock() so it is serialized against the cmd_sync work as
the contract requires.

This was found by an LLM-based audit that checks code against the rules
stated in kernel comments.

Fixes: af395330abed ("Bluetooth: btintel: Add Intel devcoredump support")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Praneeth Balasubramanian <praneethb2002@xxxxxxxxx>
---

Notes:
This was found by an LLM-based audit, part of research at UCSB SecLab.
An LLM turned a kernel comment into a rule, and three LLM votes checked
the code against it. The fix and changelog were drafted with GLM-5.3,
then checked against the source and partly rewritten with Claude Opus
5.5. I reviewed the patch and take responsibility for it.

Testing: builds without new warnings with W=1 (x86_64 allmodconfig),
clang 23. checkpatch.pl is clean. Not runtime-tested, and there is no
reproducer. I do not have this hardware.

drivers/bluetooth/btintel.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c
index ca98bd106b86..c6cfbfcfed09 100644
--- a/drivers/bluetooth/btintel.c
+++ b/drivers/bluetooth/btintel.c
@@ -1713,7 +1713,10 @@ static void btintel_coredump(struct hci_dev *hdev)
{
struct sk_buff *skb;

+ hci_req_sync_lock(hdev);
skb = __hci_cmd_sync(hdev, 0xfc4e, 0, NULL, HCI_CMD_TIMEOUT);
+ hci_req_sync_unlock(hdev);
+
if (IS_ERR(skb)) {
bt_dev_err(hdev, "Coredump failed (%ld)", PTR_ERR(skb));
return;
--
2.25.1