Blame SOURCES/CVE-2021-32399.patch

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