Blame SOURCES/CVE-2021-32399.patch

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