Patch "Bluetooth: hci_sync: Avoid use-after-free in dbg for hci_remove_adv_monitor()" has been added to the 6.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    Bluetooth: hci_sync: Avoid use-after-free in dbg for hci_remove_adv_monitor()

to the 6.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     bluetooth-hci_sync-avoid-use-after-free-in-dbg-for-h.patch
and it can be found in the queue-6.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit a1ee2560c82046e851ecf0268f802f2e15a138aa
Author: Douglas Anderson <dianders@xxxxxxxxxxxx>
Date:   Fri Jun 30 15:33:14 2023 -0700

    Bluetooth: hci_sync: Avoid use-after-free in dbg for hci_remove_adv_monitor()
    
    [ Upstream commit de6dfcefd107667ce2dbedf4d9337f5ed557a4a1 ]
    
    KASAN reports that there's a use-after-free in
    hci_remove_adv_monitor(). Trawling through the disassembly, you can
    see that the complaint is from the access in bt_dev_dbg() under the
    HCI_ADV_MONITOR_EXT_MSFT case. The problem case happens because
    msft_remove_monitor() can end up freeing the monitor
    structure. Specifically:
      hci_remove_adv_monitor() ->
      msft_remove_monitor() ->
      msft_remove_monitor_sync() ->
      msft_le_cancel_monitor_advertisement_cb() ->
      hci_free_adv_monitor()
    
    Let's fix the problem by just stashing the relevant data when it's
    still valid.
    
    Fixes: 7cf5c2978f23 ("Bluetooth: hci_sync: Refactor remove Adv Monitor")
    Signed-off-by: Douglas Anderson <dianders@xxxxxxxxxxxx>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index b421e196f60c3..1ec83985f1ab0 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1972,6 +1972,7 @@ static int hci_remove_adv_monitor(struct hci_dev *hdev,
 				  struct adv_monitor *monitor)
 {
 	int status = 0;
+	int handle;
 
 	switch (hci_get_adv_monitor_offload_ext(hdev)) {
 	case HCI_ADV_MONITOR_EXT_NONE: /* also goes here when powered off */
@@ -1980,9 +1981,10 @@ static int hci_remove_adv_monitor(struct hci_dev *hdev,
 		goto free_monitor;
 
 	case HCI_ADV_MONITOR_EXT_MSFT:
+		handle = monitor->handle;
 		status = msft_remove_monitor(hdev, monitor);
 		bt_dev_dbg(hdev, "%s remove monitor %d msft status %d",
-			   hdev->name, monitor->handle, status);
+			   hdev->name, handle, status);
 		break;
 	}
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux