]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
bluetooth: eliminate the potential race condition when removing the HCI controller
authorLin Ma <linma@zju.edu.cn>
Mon, 12 Apr 2021 11:17:57 +0000 (19:17 +0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 26 May 2021 13:39:02 +0000 (15:39 +0200)
commitf232b714228f389936ebb8b708afc0517a6125af
treeedabdf87bc89f4e7275952c073b1c7eb044e34e1
parent9692a215490ebd5bd79a54dc50e45a26006cbb53
bluetooth: eliminate the potential race condition when removing the HCI controller

BugLink: https://bugs.launchpad.net/bugs/1929615
commit e2cb6b891ad2b8caa9131e3be70f45243df82a80 upstream.

There is a possible race condition vulnerability between issuing a HCI
command and removing the cont.  Specifically, functions hci_req_sync()
and hci_dev_do_close() can race each other like below:

thread-A in hci_req_sync()      |   thread-B in hci_dev_do_close()
                                |   hci_req_sync_lock(hdev);
test_bit(HCI_UP, &hdev->flags); |
...                             |   test_and_clear_bit(HCI_UP, &hdev->flags)
hci_req_sync_lock(hdev);        |
                                |
In this commit we alter the sequence in function hci_req_sync(). Hence,
the thread-A cannot issue th.

Signed-off-by: Lin Ma <linma@zju.edu.cn>
Cc: Marcel Holtmann <marcel@holtmann.org>
Fixes: 7c6a329e4447 ("[Bluetooth] Fix regression from using default link policy")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
net/bluetooth/hci_request.c