* [PATCH] Bluetooth: btusb: reorder cleanup in btusb_disconnect to avoid UAF
@ 2025-11-05 19:28 Raphael Pinsonneault-Thibeault
2025-11-05 19:57 ` bluez.test.bot
2025-11-07 19:10 ` [PATCH] " patchwork-bot+bluetooth
0 siblings, 2 replies; 3+ messages in thread
From: Raphael Pinsonneault-Thibeault @ 2025-11-05 19:28 UTC (permalink / raw)
To: marcel, luiz.dentz
Cc: linux-bluetooth, linux-kernel, linux-kernel-mentees,
syzbot+2fc81b50a4f8263a159b, skhan,
Raphael Pinsonneault-Thibeault
There is a KASAN: slab-use-after-free read in btusb_disconnect().
Calling "usb_driver_release_interface(&btusb_driver, data->intf)" will
free the btusb data associated with the interface. The same data is
then used later in the function, hence the UAF.
Fix by moving the accesses to btusb data to before the data is free'd.
Reported-by: syzbot+2fc81b50a4f8263a159b@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=2fc81b50a4f8263a159b
Tested-by: syzbot+2fc81b50a4f8263a159b@syzkaller.appspotmail.com
Fixes: fd913ef7ce619 ("Bluetooth: btusb: Add out-of-band wakeup support")
Signed-off-by: Raphael Pinsonneault-Thibeault <rpthibeault@gmail.com>
---
Syzbot opens a usb device with out of order interface descriptors:
Interface 3 (ISOC) in position 0, Interface 2 (DIAG) in position 1,
Interface 1 (INTF) in position 2.
So, ISOC is the first interface to get disconnected by usb_disconnect()
-> usb_disable_device() -> ... -> btusb_disconnect().
I don't think this is a problem on hardware, where the bInterfaceNumber
matches the position in the dev->actconfig->interface list; and in
btusb_disconnect() it would only ever go into the first if
statement: "if (intf == data->intf)" and not into any of the others.
drivers/bluetooth/btusb.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 9ab661d2d1e6..1f8d4af184de 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -4269,6 +4269,11 @@ static void btusb_disconnect(struct usb_interface *intf)
hci_unregister_dev(hdev);
+ if (data->oob_wake_irq)
+ device_init_wakeup(&data->udev->dev, false);
+ if (data->reset_gpio)
+ gpiod_put(data->reset_gpio);
+
if (intf == data->intf) {
if (data->isoc)
usb_driver_release_interface(&btusb_driver, data->isoc);
@@ -4279,17 +4284,11 @@ static void btusb_disconnect(struct usb_interface *intf)
usb_driver_release_interface(&btusb_driver, data->diag);
usb_driver_release_interface(&btusb_driver, data->intf);
} else if (intf == data->diag) {
- usb_driver_release_interface(&btusb_driver, data->intf);
if (data->isoc)
usb_driver_release_interface(&btusb_driver, data->isoc);
+ usb_driver_release_interface(&btusb_driver, data->intf);
}
- if (data->oob_wake_irq)
- device_init_wakeup(&data->udev->dev, false);
-
- if (data->reset_gpio)
- gpiod_put(data->reset_gpio);
-
hci_free_dev(hdev);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: Bluetooth: btusb: reorder cleanup in btusb_disconnect to avoid UAF
2025-11-05 19:28 [PATCH] Bluetooth: btusb: reorder cleanup in btusb_disconnect to avoid UAF Raphael Pinsonneault-Thibeault
@ 2025-11-05 19:57 ` bluez.test.bot
2025-11-07 19:10 ` [PATCH] " patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2025-11-05 19:57 UTC (permalink / raw)
To: linux-bluetooth, rpthibeault
[-- Attachment #1: Type: text/plain, Size: 2376 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/project/bluetooth/list/?series=1020056
---Test result---
Test Summary:
CheckPatch PENDING 0.49 seconds
GitLint PENDING 0.36 seconds
SubjectPrefix PASS 0.06 seconds
BuildKernel PASS 23.14 seconds
CheckAllWarning PASS 25.12 seconds
CheckSparse PASS 28.09 seconds
BuildKernel32 PASS 22.63 seconds
TestRunnerSetup PASS 454.63 seconds
TestRunner_l2cap-tester PASS 23.58 seconds
TestRunner_iso-tester PASS 91.87 seconds
TestRunner_bnep-tester PASS 6.11 seconds
TestRunner_mgmt-tester FAIL 112.40 seconds
TestRunner_rfcomm-tester PASS 9.21 seconds
TestRunner_sco-tester PASS 14.16 seconds
TestRunner_ioctl-tester PASS 9.81 seconds
TestRunner_mesh-tester FAIL 11.54 seconds
TestRunner_smp-tester PASS 8.29 seconds
TestRunner_userchan-tester PASS 6.42 seconds
IncrementalBuild PENDING 0.99 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 490, Passed: 484 (98.8%), Failed: 2, Not Run: 4
Failed Test Cases
Read Exp Feature - Success Failed 0.098 seconds
LL Privacy - Set Flags 1 (Add to RL) Failed 0.142 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 1 Timed out 2.116 seconds
Mesh - Send cancel - 2 Timed out 1.998 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Bluetooth: btusb: reorder cleanup in btusb_disconnect to avoid UAF
2025-11-05 19:28 [PATCH] Bluetooth: btusb: reorder cleanup in btusb_disconnect to avoid UAF Raphael Pinsonneault-Thibeault
2025-11-05 19:57 ` bluez.test.bot
@ 2025-11-07 19:10 ` patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2025-11-07 19:10 UTC (permalink / raw)
To: Raphael Pinsonneault-Thibeault
Cc: marcel, luiz.dentz, linux-bluetooth, linux-kernel,
linux-kernel-mentees, syzbot+2fc81b50a4f8263a159b, skhan
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Wed, 5 Nov 2025 14:28:41 -0500 you wrote:
> There is a KASAN: slab-use-after-free read in btusb_disconnect().
> Calling "usb_driver_release_interface(&btusb_driver, data->intf)" will
> free the btusb data associated with the interface. The same data is
> then used later in the function, hence the UAF.
>
> Fix by moving the accesses to btusb data to before the data is free'd.
>
> [...]
Here is the summary with links:
- Bluetooth: btusb: reorder cleanup in btusb_disconnect to avoid UAF
https://git.kernel.org/bluetooth/bluetooth-next/c/162d88a68ccb
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:[~2025-11-07 19:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-05 19:28 [PATCH] Bluetooth: btusb: reorder cleanup in btusb_disconnect to avoid UAF Raphael Pinsonneault-Thibeault
2025-11-05 19:57 ` bluez.test.bot
2025-11-07 19:10 ` [PATCH] " 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