]> git.baikalelectronics.ru Git - 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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Apr 2021 11:25:04 +0000 (13:25 +0200)
commita99b2883b977911f11d83a294326f87d43bf79d7
treed90080640acfe6a6b6885e96b171154b77cbabf5
parent62100008dc2e9ef1fb367602327c55079dbfd310
bluetooth: eliminate the potential race condition when removing the HCI controller

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: f779c853ee72 ("[Bluetooth] Fix regression from using default link policy")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/bluetooth/hci_request.c