|
|
040390 |
From d50512e6312824861ce342eb68bb1eb7dea984e2 Mon Sep 17 00:00:00 2001
|
|
|
040390 |
From: Artem Savkov <asavkov@redhat.com>
|
|
|
040390 |
Date: Mon, 21 Jun 2021 12:09:28 +0200
|
|
|
040390 |
Subject: [PATCH] bluetooth: eliminate the potential race condition when
|
|
|
040390 |
removing the HCI controller
|
|
|
040390 |
|
|
|
040390 |
Kernels:
|
|
|
040390 |
4.18.0-305.el8
|
|
|
040390 |
4.18.0-305.3.1.el8_4
|
|
|
040390 |
4.18.0-305.7.1.el8_4
|
|
|
040390 |
|
|
|
040390 |
Changes since last build:
|
|
|
040390 |
[x86_64]:
|
|
|
040390 |
hci_request.o: changed function: hci_req_sync
|
|
|
040390 |
|
|
|
040390 |
[ppc64le]:
|
|
|
040390 |
hci_request.o: changed function: bg_scan_update
|
|
|
040390 |
hci_request.o: changed function: connectable_update_work
|
|
|
040390 |
hci_request.o: changed function: discov_off
|
|
|
040390 |
hci_request.o: changed function: discov_update
|
|
|
040390 |
hci_request.o: changed function: discoverable_update_work
|
|
|
040390 |
hci_request.o: changed function: hci_req_sync
|
|
|
040390 |
hci_request.o: changed function: le_scan_disable_work
|
|
|
040390 |
hci_request.o: changed function: le_scan_restart_work
|
|
|
040390 |
hci_request.o: changed function: scan_update_work
|
|
|
040390 |
|
|
|
040390 |
---------------------------
|
|
|
040390 |
|
|
|
040390 |
Kernels:
|
|
|
040390 |
4.18.0-305.el8
|
|
|
040390 |
4.18.0-305.3.1.el8_4
|
|
|
040390 |
4.18.0-305.7.1.el8_4
|
|
|
040390 |
|
|
|
040390 |
Modifications: none
|
|
|
040390 |
Z-MR: https://gitlab.com/redhat/rhel/src/kernel/rhel-8/-/merge_requests/804
|
|
|
040390 |
|
|
|
040390 |
commit 84466ca3bdf0d5d77d4c8a851336406627de2628
|
|
|
040390 |
Author: Gopal Tiwari <gtiwari@redhat.com>
|
|
|
040390 |
Date: Mon Jun 14 13:47:30 2021 +0530
|
|
|
040390 |
|
|
|
040390 |
bluetooth: eliminate the potential race condition when removing the HCI controller
|
|
|
040390 |
|
|
|
040390 |
Bugzilla: https://bugzilla.redhat.com/1971464
|
|
|
040390 |
CVE: CVE-2021-32399
|
|
|
040390 |
Y-Commit: 54c81477df19422cbc3c8cf3b555159ff642f15b
|
|
|
040390 |
|
|
|
040390 |
O-Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1971488
|
|
|
040390 |
|
|
|
040390 |
Upstream: Merged
|
|
|
040390 |
|
|
|
040390 |
Testing: Sanity_only.
|
|
|
040390 |
|
|
|
040390 |
commit e2cb6b891ad2b8caa9131e3be70f45243df82a80
|
|
|
040390 |
Author: Lin Ma <linma@zju.edu.cn>
|
|
|
040390 |
Date: Mon Apr 12 19:17:57 2021 +0800
|
|
|
040390 |
|
|
|
040390 |
bluetooth: eliminate the potential race condition when removing the HCI controller
|
|
|
040390 |
|
|
|
040390 |
There is a possible race condition vulnerability between issuing a HCI
|
|
|
040390 |
command and removing the cont. Specifically, functions hci_req_sync()
|
|
|
040390 |
and hci_dev_do_close() can race each other like below:
|
|
|
040390 |
|
|
|
040390 |
thread-A in hci_req_sync() | thread-B in hci_dev_do_close()
|
|
|
040390 |
| hci_req_sync_lock(hdev);
|
|
|
040390 |
test_bit(HCI_UP, &hdev->flags); |
|
|
|
040390 |
... | test_and_clear_bit(HCI_UP, &hdev->flags)
|
|
|
040390 |
hci_req_sync_lock(hdev); |
|
|
|
040390 |
|
|
|
|
040390 |
In this commit we alter the sequence in function hci_req_sync(). Hence,
|
|
|
040390 |
the thread-A cannot issue th.
|
|
|
040390 |
|
|
|
040390 |
Signed-off-by: Lin Ma <linma@zju.edu.cn>
|
|
|
040390 |
Cc: Marcel Holtmann <marcel@holtmann.org>
|
|
|
040390 |
Fixes: 7c6a329e4447 ("[Bluetooth] Fix regression from using default link policy")
|
|
|
040390 |
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
|
|
040390 |
(cherry picked from commit e2cb6b891ad2b8caa9131e3be70f45243df82a80)
|
|
|
040390 |
Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
|
|
|
040390 |
Signed-off-by: Jan Stancek <jstancek@redhat.com>
|
|
|
040390 |
|
|
|
040390 |
Signed-off-by: Artem Savkov <asavkov@redhat.com>
|
|
|
040390 |
Acked-by: Yannick Cote <ycote@redhat.com>
|
|
|
040390 |
Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
|
|
|
040390 |
---
|
|
|
040390 |
net/bluetooth/hci_request.c | 12 ++++++++----
|
|
|
040390 |
1 file changed, 8 insertions(+), 4 deletions(-)
|
|
|
040390 |
|
|
|
040390 |
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
|
|
|
040390 |
index cf1b42ec40af97..ca9088d439460e 100644
|
|
|
040390 |
--- a/net/bluetooth/hci_request.c
|
|
|
040390 |
+++ b/net/bluetooth/hci_request.c
|
|
|
040390 |
@@ -274,12 +274,16 @@ int hci_req_sync(struct hci_dev *hdev, int (*req)(struct hci_request *req,
|
|
|
040390 |
{
|
|
|
040390 |
int ret;
|
|
|
040390 |
|
|
|
040390 |
- if (!test_bit(HCI_UP, &hdev->flags))
|
|
|
040390 |
- return -ENETDOWN;
|
|
|
040390 |
-
|
|
|
040390 |
/* Serialize all requests */
|
|
|
040390 |
hci_req_sync_lock(hdev);
|
|
|
040390 |
- ret = __hci_req_sync(hdev, req, opt, timeout, hci_status);
|
|
|
040390 |
+ /* check the state after obtaing the lock to protect the HCI_UP
|
|
|
040390 |
+ * against any races from hci_dev_do_close when the controller
|
|
|
040390 |
+ * gets removed.
|
|
|
040390 |
+ */
|
|
|
040390 |
+ if (test_bit(HCI_UP, &hdev->flags))
|
|
|
040390 |
+ ret = __hci_req_sync(hdev, req, opt, timeout, hci_status);
|
|
|
040390 |
+ else
|
|
|
040390 |
+ ret = -ENETDOWN;
|
|
|
040390 |
hci_req_sync_unlock(hdev);
|
|
|
040390 |
|
|
|
040390 |
return ret;
|
|
|
040390 |
--
|
|
|
040390 |
2.26.3
|
|
|
040390 |
|