Patch "Bluetooth: Fix hci_link_tx_to RCU lock usage" has been added to the 6.5-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: Fix hci_link_tx_to RCU lock usage

to the 6.5-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-fix-hci_link_tx_to-rcu-lock-usage.patch
and it can be found in the queue-6.5 subdirectory.

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



commit 04ccb12162d600467a8b7797bc70620b75f20357
Author: Ying Hsu <yinghsu@xxxxxxxxxxxx>
Date:   Mon Sep 4 14:11:51 2023 +0000

    Bluetooth: Fix hci_link_tx_to RCU lock usage
    
    [ Upstream commit c7eaf80bfb0c8cef852cce9501b95dd5a6bddcb9 ]
    
    Syzbot found a bug "BUG: sleeping function called from invalid context
    at kernel/locking/mutex.c:580". It is because hci_link_tx_to holds an
    RCU read lock and calls hci_disconnect which would hold a mutex lock
    since the commit a13f316e90fd ("Bluetooth: hci_conn: Consolidate code
    for aborting connections"). Here's an example call trace:
    
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0xfc/0x174 lib/dump_stack.c:106
       ___might_sleep+0x4a9/0x4d3 kernel/sched/core.c:9663
       __mutex_lock_common kernel/locking/mutex.c:576 [inline]
       __mutex_lock+0xc7/0x6e7 kernel/locking/mutex.c:732
       hci_cmd_sync_queue+0x3a/0x287 net/bluetooth/hci_sync.c:388
       hci_abort_conn+0x2cd/0x2e4 net/bluetooth/hci_conn.c:1812
       hci_disconnect+0x207/0x237 net/bluetooth/hci_conn.c:244
       hci_link_tx_to net/bluetooth/hci_core.c:3254 [inline]
       __check_timeout net/bluetooth/hci_core.c:3419 [inline]
       __check_timeout+0x310/0x361 net/bluetooth/hci_core.c:3399
       hci_sched_le net/bluetooth/hci_core.c:3602 [inline]
       hci_tx_work+0xe8f/0x12d0 net/bluetooth/hci_core.c:3652
       process_one_work+0x75c/0xba1 kernel/workqueue.c:2310
       worker_thread+0x5b2/0x73a kernel/workqueue.c:2457
       kthread+0x2f7/0x30b kernel/kthread.c:319
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
    
    This patch releases RCU read lock before calling hci_disconnect and
    reacquires it afterward to fix the bug.
    
    Fixes: a13f316e90fd ("Bluetooth: hci_conn: Consolidate code for aborting connections")
    Signed-off-by: Ying Hsu <yinghsu@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 29ae9b254a34e..e57d7c25511f4 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3418,7 +3418,12 @@ static void hci_link_tx_to(struct hci_dev *hdev, __u8 type)
 		if (c->type == type && c->sent) {
 			bt_dev_err(hdev, "killing stalled connection %pMR",
 				   &c->dst);
+			/* hci_disconnect might sleep, so, we have to release
+			 * the RCU read lock before calling it.
+			 */
+			rcu_read_unlock();
 			hci_disconnect(c, HCI_ERROR_REMOTE_USER_TERM);
+			rcu_read_lock();
 		}
 	}
 



[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