Skip to content

Commit 385315d

Browse files
Jesse Melhuishholtmann
authored andcommitted
Bluetooth: Don't initialize msft/aosp when using user channel
A race condition is triggered when usermode control is given to userspace before the kernel's MSFT query responds, resulting in an unexpected response to userspace's reset command. Issue can be observed in btmon: < HCI Command: Vendor (0x3f|0x001e) plen 2 #3 [hci0] 05 01 .. @ USER Open: bt_stack_manage (privileged) version 2.22 {0x0002} [hci0] < HCI Command: Reset (0x03|0x0003) plen 0 #4 [hci0] > HCI Event: Command Complete (0x0e) plen 5 #5 [hci0] Vendor (0x3f|0x001e) ncmd 1 Status: Command Disallowed (0x0c) 05 . > HCI Event: Command Complete (0x0e) plen 4 #6 [hci0] Reset (0x03|0x0003) ncmd 2 Status: Success (0x00) Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> Signed-off-by: Jesse Melhuish <melhuishj@chromium.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent a27c519 commit 385315d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

net/bluetooth/hci_sync.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3887,8 +3887,10 @@ int hci_dev_open_sync(struct hci_dev *hdev)
38873887
hci_dev_test_flag(hdev, HCI_VENDOR_DIAG) && hdev->set_diag)
38883888
ret = hdev->set_diag(hdev, true);
38893889

3890-
msft_do_open(hdev);
3891-
aosp_do_open(hdev);
3890+
if (!hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) {
3891+
msft_do_open(hdev);
3892+
aosp_do_open(hdev);
3893+
}
38923894

38933895
clear_bit(HCI_INIT, &hdev->flags);
38943896

@@ -4031,8 +4033,10 @@ int hci_dev_close_sync(struct hci_dev *hdev)
40314033

40324034
hci_sock_dev_event(hdev, HCI_DEV_DOWN);
40334035

4034-
aosp_do_close(hdev);
4035-
msft_do_close(hdev);
4036+
if (!hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) {
4037+
aosp_do_close(hdev);
4038+
msft_do_close(hdev);
4039+
}
40364040

40374041
if (hdev->flush)
40384042
hdev->flush(hdev);

0 commit comments

Comments
 (0)