* [PATCH v3] Bluetooth: btusb: fix use-after-free in force_poll_sync
@ 2026-11-05 5:56 YuanZhe Liu
2026-11-05 9:17 ` [v3] " bluez.test.bot
2026-11-05 16:32 ` [PATCH v3] " patchwork-bot+bluetooth
0 siblings, 2 replies; 3+ messages in thread
From: YuanZhe Liu @ 2026-11-05 5:56 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz
Cc: linux-bluetooth, linux-kernel, stable, Bin Yu, Cheng Wen
The force_poll_sync debugfs file uses the driver's struct btusb_data as
its private data. The file is created under hdev->debugfs and is removed
only when the HCI device is released, while btusb_disconnect() frees
btusb_data unconditionally. The HCI device can outlive the driver data,
for example when an HCI socket still references it, so reading or
writing the already opened file then dereferences freed memory:
BUG: KASAN: slab-use-after-free in force_poll_sync_read+0x129/0x140
Read of size 1 at addr ffff88800cfb7038
...
Freed by task ...:
kfree
btusb_disconnect
Remove the debugfs file before the private data is freed.
debugfs_remove() waits for callers that are already inside the file
operations, and any later access fails with -EIO instead of reaching the
driver, so the force_poll_sync file can no longer dereference btusb_data
after it is gone.
Fixes: 800fe5ec302e ("Bluetooth: btusb: Add support for queuing during polling interval")
Cc: stable@vger.kernel.org
Co-developed-by: Bin Yu <byu@xidian.edu.cn>
Signed-off-by: Bin Yu <byu@xidian.edu.cn>
Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
---
Changes in v3:
- Scope the changelog claim to the force_poll_sync file: the
vendor_diag file used by Broadcom devices has a separate,
pre-existing lifetime problem and is not covered here.
drivers/bluetooth/btusb_main.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/bluetooth/btusb_main.c b/drivers/bluetooth/btusb_main.c
index 92a78a7e6039..95398e2ca098 100644
--- a/drivers/bluetooth/btusb_main.c
+++ b/drivers/bluetooth/btusb_main.c
@@ -1088,6 +1088,8 @@ struct btusb_data {
int (*disconnect)(struct hci_dev *hdev);
int oob_wake_irq; /* irq for out-of-band wake-on-bt */
+
+ struct dentry *force_poll_sync_dentry;
};
static void btusb_reset(struct hci_dev *hdev)
@@ -4820,8 +4822,9 @@ static int btusb_probe(struct usb_interface *intf,
usb_set_intfdata(intf, data);
- debugfs_create_file("force_poll_sync", 0644, hdev->debugfs, data,
- &force_poll_sync_fops);
+ data->force_poll_sync_dentry =
+ debugfs_create_file("force_poll_sync", 0644, hdev->debugfs,
+ data, &force_poll_sync_fops);
return 0;
@@ -4862,6 +4865,9 @@ static void btusb_disconnect(struct usb_interface *intf)
if (!data)
return;
+ debugfs_remove(data->force_poll_sync_dentry);
+ data->force_poll_sync_dentry = NULL;
+
hdev = data->hdev;
usb_set_intfdata(data->intf, NULL);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* RE: [v3] Bluetooth: btusb: fix use-after-free in force_poll_sync
2026-11-05 5:56 [PATCH v3] Bluetooth: btusb: fix use-after-free in force_poll_sync YuanZhe Liu
@ 2026-11-05 9:17 ` bluez.test.bot
2026-11-05 16:32 ` [PATCH v3] " patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-11-05 9:17 UTC (permalink / raw)
To: linux-bluetooth, 25031212351
[-- Attachment #1: Type: text/plain, Size: 1021 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/1202754/
---Test result---
Test Summary:
CheckPatch PASS 12.14 seconds
VerifyFixes PASS 0.20 seconds
VerifySignedoff PASS 0.11 seconds
GitLint PASS 0.29 seconds
SubjectPrefix PASS 0.13 seconds
BuildKernel PASS 25.56 seconds
CheckAllWarning PASS 22.95 seconds
CheckSparse PASS 24.46 seconds
BuildKernel32 PASS 20.30 seconds
CheckKernelLLVM PASS 20.38 seconds
TestRunnerSetup PASS 493.90 seconds
IncrementalBuild PASS 75.69 seconds
https://github.com/bluez/bluetooth-next/pull/1069
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] Bluetooth: btusb: fix use-after-free in force_poll_sync
2026-11-05 5:56 [PATCH v3] Bluetooth: btusb: fix use-after-free in force_poll_sync YuanZhe Liu
2026-11-05 9:17 ` [v3] " bluez.test.bot
@ 2026-11-05 16:32 ` patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2026-11-05 16:32 UTC (permalink / raw)
To: YuanZhe Liu
Cc: marcel, luiz.dentz, linux-bluetooth, linux-kernel, stable, byu,
wencheng
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Thu, 5 Nov 2026 13:56:39 +0800 you wrote:
> The force_poll_sync debugfs file uses the driver's struct btusb_data as
> its private data. The file is created under hdev->debugfs and is removed
> only when the HCI device is released, while btusb_disconnect() frees
> btusb_data unconditionally. The HCI device can outlive the driver data,
> for example when an HCI socket still references it, so reading or
> writing the already opened file then dereferences freed memory:
>
> [...]
Here is the summary with links:
- [v3] Bluetooth: btusb: fix use-after-free in force_poll_sync
https://git.kernel.org/bluetooth/bluetooth-next/c/868c886f45f7
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-11-05 16:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-05 5:56 [PATCH v3] Bluetooth: btusb: fix use-after-free in force_poll_sync YuanZhe Liu
2026-11-05 9:17 ` [v3] " bluez.test.bot
2026-11-05 16:32 ` [PATCH v3] " 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