CVE-2026-139371: Bluetooth: MSFT: Serialize handle map cleanup with event processing
In the Linux kernel, the following vulnerability has been resolved:
Bluetooth: MSFT: Serialize handle map cleanup with event processing
MSFT monitor handle mappings must remain valid while vendor events look up and use them under hdev->lock. msftdoclose() removes and frees the mappings without that lock.
hcidevclosesync() clears HCIUP and drains the RX workqueue before MSFT cleanup. However, a transport callback that already passed hcirecvframe()'s state check can queue a vendor event after the drain returns, if no earlier shutdown callback has quiesced reception. The driver close callback runs after MSFT cleanup, so event processing can overlap the unlocked removal. msftmonitordeviceevt() can then traverse freed list entries or read handledata->mgmthandle after it is freed.
Take hdev->lock while resetting monitor states and removing handle mappings in msftdoclose(), as normal monitor cancellation already does. An active event reader then finishes before its mapping is freed, and later lookups see an empty handle map.
An instrumented kernel produced this KASAN report (timestamps removed and unrelated frames omitted):
BUG: KASAN: slab-use-after-free in msftvendorevt+0x1906/0x1990 Read of size 2 at addr ffff888104df3602 by task kworker/u17:2/502
Workqueue: hci0 hcirxwork Call Trace: [...] msftvendorevt+0x1906/0x1990 hcivendorevt+0x6f/0x90 hcieventpacket+0x894/0xc70 [...] hcirxwork+0x3f8/0xfa0 [...]
Allocated by task 499: [...] msftaddmonitorsync+0x6a8/0x10a0 msftaddmonitorpattern+0x7f/0xb0 hciaddadvmonitor+0x1fa/0x2e0 [...]
Freed by task 499: [...] kfree+0x307/0x580 msftdoclose+0x238/0x750 hcidevclosesync+0x546/0x1380 [...]
The buggy address belongs to the object at ffff888104df3600 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 2 bytes inside of freed 32-byte region [ffff888104df3600, ffff888104df3620) [...]
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In msft_do_close(), take hdev->lock while resetting monitor states and removing handle mappings, so cleanup is serialized with event processing.
Event History
Frequently Asked Questions
What conditions are required for this race to occur?
A Bluetooth transport callback must already have passed hci_recv_frame()'s state check and queue a Microsoft vendor event after hci_dev_close_sync() has drained the RX workqueue. This can overlap with msft_do_close() removing handle mappings without hdev->lock.
What is the practical impact if the race is triggered?
Vendor-event processing can traverse freed handle-map list entries or read handle_data->mgmt_handle after the underlying object has been freed. The reported failure mode is a KASAN-detected slab use-after-free in msft_vendor_evt.
How does the fix prevent the issue?
The fix takes hdev->lock while msft_do_close() resets monitor states and removes handle mappings. Any active event reader completes before its mapping is freed, and subsequent lookups find an empty handle map.