|
|
e07557 |
From: Artem Savkov <asavkov@redhat.com>
|
|
|
e07557 |
Subject: [RHEL-7.9 CVE-2021-32399 KPATCH] bluetooth: eliminate the potential race condition when removing the HCI controller
|
|
|
e07557 |
Date: Wed, 7 Jul 2021 17:13:32 +0200
|
|
|
e07557 |
|
|
|
e07557 |
Kernels:
|
|
|
e07557 |
3.10.0-1160.el7
|
|
|
e07557 |
3.10.0-1160.2.1.el7
|
|
|
e07557 |
3.10.0-1160.2.2.el7
|
|
|
e07557 |
3.10.0-1160.6.1.el7
|
|
|
e07557 |
3.10.0-1160.11.1.el7
|
|
|
e07557 |
3.10.0-1160.15.2.el7
|
|
|
e07557 |
3.10.0-1160.21.1.el7
|
|
|
e07557 |
3.10.0-1160.24.1.el7
|
|
|
e07557 |
3.10.0-1160.25.1.el7
|
|
|
e07557 |
3.10.0-1160.31.1.el7
|
|
|
e07557 |
|
|
|
e07557 |
Changes since last build:
|
|
|
e07557 |
[x86_64]:
|
|
|
e07557 |
hci_request.o: changed function: hci_req_sync
|
|
|
e07557 |
|
|
|
e07557 |
[ppc64le]:
|
|
|
e07557 |
hci_request.o: changed function: bg_scan_update
|
|
|
e07557 |
hci_request.o: changed function: connectable_update_work
|
|
|
e07557 |
hci_request.o: changed function: discov_off
|
|
|
e07557 |
hci_request.o: changed function: discov_update
|
|
|
e07557 |
hci_request.o: changed function: discoverable_update_work
|
|
|
e07557 |
hci_request.o: changed function: hci_req_sync
|
|
|
e07557 |
hci_request.o: changed function: le_scan_disable_work
|
|
|
e07557 |
hci_request.o: changed function: le_scan_restart_work
|
|
|
e07557 |
hci_request.o: changed function: scan_update_work
|
|
|
e07557 |
|
|
|
e07557 |
---------------------------
|
|
|
e07557 |
|
|
|
e07557 |
Kernels:
|
|
|
e07557 |
3.10.0-1160.el7
|
|
|
e07557 |
3.10.0-1160.2.1.el7
|
|
|
e07557 |
3.10.0-1160.2.2.el7
|
|
|
e07557 |
3.10.0-1160.6.1.el7
|
|
|
e07557 |
3.10.0-1160.11.1.el7
|
|
|
e07557 |
3.10.0-1160.15.2.el7
|
|
|
e07557 |
3.10.0-1160.21.1.el7
|
|
|
e07557 |
3.10.0-1160.24.1.el7
|
|
|
e07557 |
3.10.0-1160.25.1.el7
|
|
|
e07557 |
3.10.0-1160.31.1.el7
|
|
|
e07557 |
3.10.0-1160.36.2.el7
|
|
|
e07557 |
|
|
|
e07557 |
Modifications: none
|
|
|
e07557 |
Z-MR: https://gitlab.com/redhat/rhel/src/kernel/rhel-7/-/merge_requests/171
|
|
|
e07557 |
|
|
|
e07557 |
commit 168b363c94eac82c2e3531bd2ae9dfa2f369d4be
|
|
|
e07557 |
Author: Gopal Tiwari <gtiwari@redhat.com>
|
|
|
e07557 |
Date: Mon Jun 14 13:04:00 2021 +0530
|
|
|
e07557 |
|
|
|
e07557 |
bluetooth: eliminate the potential race condition when removing the HCI controller
|
|
|
e07557 |
|
|
|
e07557 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1971457
|
|
|
e07557 |
|
|
|
e07557 |
Upstream: merged.
|
|
|
e07557 |
|
|
|
e07557 |
Testing: Sanity_only.
|
|
|
e07557 |
|
|
|
e07557 |
commit e2cb6b891ad2b8caa9131e3be70f45243df82a80
|
|
|
e07557 |
Author: Lin Ma <linma@zju.edu.cn>
|
|
|
e07557 |
Date: Mon Apr 12 19:17:57 2021 +0800
|
|
|
e07557 |
|
|
|
e07557 |
bluetooth: eliminate the potential race condition when removing the HCI controller
|
|
|
e07557 |
|
|
|
e07557 |
There is a possible race condition vulnerability between issuing a HCI
|
|
|
e07557 |
command and removing the cont. Specifically, functions hci_req_sync()
|
|
|
e07557 |
and hci_dev_do_close() can race each other like below:
|
|
|
e07557 |
|
|
|
e07557 |
thread-A in hci_req_sync() | thread-B in hci_dev_do_close()
|
|
|
e07557 |
| hci_req_sync_lock(hdev);
|
|
|
e07557 |
test_bit(HCI_UP, &hdev->flags); |
|
|
|
e07557 |
... | test_and_clear_bit(HCI_UP, &hdev->flags)
|
|
|
e07557 |
hci_req_sync_lock(hdev); |
|
|
|
e07557 |
|
|
|
|
e07557 |
In this commit we alter the sequence in function hci_req_sync(). Hence,
|
|
|
e07557 |
the thread-A cannot issue th.
|
|
|
e07557 |
|
|
|
e07557 |
Signed-off-by: Lin Ma <linma@zju.edu.cn>
|
|
|
e07557 |
Cc: Marcel Holtmann <marcel@holtmann.org>
|
|
|
e07557 |
Fixes: 7c6a329e4447 ("[Bluetooth] Fix regression from using default link policy")
|
|
|
e07557 |
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
|
|
e07557 |
|
|
|
e07557 |
Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
|
|
|
e07557 |
|
|
|
e07557 |
Signed-off-by: Artem Savkov <asavkov@redhat.com>
|
|
|
e07557 |
Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
|
|
|
e07557 |
Acked-by: Yannick Cote <ycote@redhat.com>
|
|
|
e07557 |
---
|
|
|
e07557 |
net/bluetooth/hci_request.c | 12 ++++++++----
|
|
|
e07557 |
1 file changed, 8 insertions(+), 4 deletions(-)
|
|
|
e07557 |
|
|
|
e07557 |
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
|
|
|
e07557 |
index 1015d9c8d97dd..9e25e77042503 100644
|
|
|
e07557 |
--- a/net/bluetooth/hci_request.c
|
|
|
e07557 |
+++ b/net/bluetooth/hci_request.c
|
|
|
e07557 |
@@ -275,12 +275,16 @@ int hci_req_sync(struct hci_dev *hdev, int (*req)(struct hci_request *req,
|
|
|
e07557 |
{
|
|
|
e07557 |
int ret;
|
|
|
e07557 |
|
|
|
e07557 |
- if (!test_bit(HCI_UP, &hdev->flags))
|
|
|
e07557 |
- return -ENETDOWN;
|
|
|
e07557 |
-
|
|
|
e07557 |
/* Serialize all requests */
|
|
|
e07557 |
hci_req_sync_lock(hdev);
|
|
|
e07557 |
- ret = __hci_req_sync(hdev, req, opt, timeout, hci_status);
|
|
|
e07557 |
+ /* check the state after obtaing the lock to protect the HCI_UP
|
|
|
e07557 |
+ * against any races from hci_dev_do_close when the controller
|
|
|
e07557 |
+ * gets removed.
|
|
|
e07557 |
+ */
|
|
|
e07557 |
+ if (test_bit(HCI_UP, &hdev->flags))
|
|
|
e07557 |
+ ret = __hci_req_sync(hdev, req, opt, timeout, hci_status);
|
|
|
e07557 |
+ else
|
|
|
e07557 |
+ ret = -ENETDOWN;
|
|
|
e07557 |
hci_req_sync_unlock(hdev);
|
|
|
e07557 |
|
|
|
e07557 |
return ret;
|
|
|
e07557 |
--
|
|
|
e07557 |
2.26.3
|
|
|
e07557 |
|
|
|
e07557 |
|