Skip to content

Commit 579028d

Browse files
committed
Merge tag 'for-net-2021-06-03' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth
bluetooth pull request for net: - Fixes UAF and CVE-2021-3564 - Fix VIRTIO_ID_BT to use an unassigned ID - Fix firmware loading on some Intel Controllers Signed-off-by: David S. Miller <[email protected]>
2 parents 1a80242 + 1f14a62 commit 579028d

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

drivers/bluetooth/btusb.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,10 +2527,17 @@ static int btusb_intel_download_firmware_newgen(struct hci_dev *hdev,
25272527
}
25282528

25292529
btusb_setup_intel_newgen_get_fw_name(ver, fwname, sizeof(fwname), "sfi");
2530-
err = request_firmware(&fw, fwname, &hdev->dev);
2530+
err = firmware_request_nowarn(&fw, fwname, &hdev->dev);
25312531
if (err < 0) {
2532+
if (!test_bit(BTUSB_BOOTLOADER, &data->flags)) {
2533+
/* Firmware has already been loaded */
2534+
set_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
2535+
return 0;
2536+
}
2537+
25322538
bt_dev_err(hdev, "Failed to load Intel firmware file %s (%d)",
25332539
fwname, err);
2540+
25342541
return err;
25352542
}
25362543

@@ -2680,12 +2687,24 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev,
26802687
err = btusb_setup_intel_new_get_fw_name(ver, params, fwname,
26812688
sizeof(fwname), "sfi");
26822689
if (err < 0) {
2690+
if (!test_bit(BTUSB_BOOTLOADER, &data->flags)) {
2691+
/* Firmware has already been loaded */
2692+
set_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
2693+
return 0;
2694+
}
2695+
26832696
bt_dev_err(hdev, "Unsupported Intel firmware naming");
26842697
return -EINVAL;
26852698
}
26862699

2687-
err = request_firmware(&fw, fwname, &hdev->dev);
2700+
err = firmware_request_nowarn(&fw, fwname, &hdev->dev);
26882701
if (err < 0) {
2702+
if (!test_bit(BTUSB_BOOTLOADER, &data->flags)) {
2703+
/* Firmware has already been loaded */
2704+
set_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
2705+
return 0;
2706+
}
2707+
26892708
bt_dev_err(hdev, "Failed to load Intel firmware file %s (%d)",
26902709
fwname, err);
26912710
return err;

include/uapi/linux/virtio_ids.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#define VIRTIO_ID_SOUND 25 /* virtio sound */
5555
#define VIRTIO_ID_FS 26 /* virtio filesystem */
5656
#define VIRTIO_ID_PMEM 27 /* virtio pmem */
57-
#define VIRTIO_ID_BT 28 /* virtio bluetooth */
5857
#define VIRTIO_ID_MAC80211_HWSIM 29 /* virtio mac80211-hwsim */
58+
#define VIRTIO_ID_BT 40 /* virtio bluetooth */
5959

6060
#endif /* _LINUX_VIRTIO_IDS_H */

net/bluetooth/hci_core.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1610,8 +1610,13 @@ static int hci_dev_do_open(struct hci_dev *hdev)
16101610
} else {
16111611
/* Init failed, cleanup */
16121612
flush_work(&hdev->tx_work);
1613-
flush_work(&hdev->cmd_work);
1613+
1614+
/* Since hci_rx_work() is possible to awake new cmd_work
1615+
* it should be flushed first to avoid unexpected call of
1616+
* hci_cmd_work()
1617+
*/
16141618
flush_work(&hdev->rx_work);
1619+
flush_work(&hdev->cmd_work);
16151620

16161621
skb_queue_purge(&hdev->cmd_q);
16171622
skb_queue_purge(&hdev->rx_q);

net/bluetooth/hci_sock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event)
762762
/* Detach sockets from device */
763763
read_lock(&hci_sk_list.lock);
764764
sk_for_each(sk, &hci_sk_list.head) {
765-
bh_lock_sock_nested(sk);
765+
lock_sock(sk);
766766
if (hci_pi(sk)->hdev == hdev) {
767767
hci_pi(sk)->hdev = NULL;
768768
sk->sk_err = EPIPE;
@@ -771,7 +771,7 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event)
771771

772772
hci_dev_put(hdev);
773773
}
774-
bh_unlock_sock(sk);
774+
release_sock(sk);
775775
}
776776
read_unlock(&hci_sk_list.lock);
777777
}

0 commit comments

Comments
 (0)